1
2
3
4
5
6#ifndef _MSCC_OCELOT_VCAP_H_
7#define _MSCC_OCELOT_VCAP_H_
8
9#include "ocelot.h"
10#include "ocelot_police.h"
11#include <net/sch_generic.h>
12#include <net/pkt_cls.h>
13
14struct ocelot_ipv4 {
15 u8 addr[4];
16};
17
18enum ocelot_vcap_bit {
19 OCELOT_VCAP_BIT_ANY,
20 OCELOT_VCAP_BIT_0,
21 OCELOT_VCAP_BIT_1
22};
23
24struct ocelot_vcap_u8 {
25 u8 value[1];
26 u8 mask[1];
27};
28
29struct ocelot_vcap_u16 {
30 u8 value[2];
31 u8 mask[2];
32};
33
34struct ocelot_vcap_u24 {
35 u8 value[3];
36 u8 mask[3];
37};
38
39struct ocelot_vcap_u32 {
40 u8 value[4];
41 u8 mask[4];
42};
43
44struct ocelot_vcap_u40 {
45 u8 value[5];
46 u8 mask[5];
47};
48
49struct ocelot_vcap_u48 {
50 u8 value[6];
51 u8 mask[6];
52};
53
54struct ocelot_vcap_u64 {
55 u8 value[8];
56 u8 mask[8];
57};
58
59struct ocelot_vcap_u128 {
60 u8 value[16];
61 u8 mask[16];
62};
63
64struct ocelot_vcap_vid {
65 u16 value;
66 u16 mask;
67};
68
69struct ocelot_vcap_ipv4 {
70 struct ocelot_ipv4 value;
71 struct ocelot_ipv4 mask;
72};
73
74struct ocelot_vcap_udp_tcp {
75 u16 value;
76 u16 mask;
77};
78
79enum ocelot_vcap_key_type {
80 OCELOT_VCAP_KEY_ANY,
81 OCELOT_VCAP_KEY_ETYPE,
82 OCELOT_VCAP_KEY_LLC,
83 OCELOT_VCAP_KEY_SNAP,
84 OCELOT_VCAP_KEY_ARP,
85 OCELOT_VCAP_KEY_IPV4,
86 OCELOT_VCAP_KEY_IPV6
87};
88
89struct ocelot_vcap_key_vlan {
90 struct ocelot_vcap_vid vid;
91 struct ocelot_vcap_u8 pcp;
92 enum ocelot_vcap_bit dei;
93 enum ocelot_vcap_bit tagged;
94};
95
96struct ocelot_vcap_key_etype {
97 struct ocelot_vcap_u48 dmac;
98 struct ocelot_vcap_u48 smac;
99 struct ocelot_vcap_u16 etype;
100 struct ocelot_vcap_u16 data;
101};
102
103struct ocelot_vcap_key_llc {
104 struct ocelot_vcap_u48 dmac;
105 struct ocelot_vcap_u48 smac;
106
107
108 struct ocelot_vcap_u32 llc;
109};
110
111struct ocelot_vcap_key_snap {
112 struct ocelot_vcap_u48 dmac;
113 struct ocelot_vcap_u48 smac;
114
115
116 struct ocelot_vcap_u40 snap;
117};
118
119struct ocelot_vcap_key_arp {
120 struct ocelot_vcap_u48 smac;
121 enum ocelot_vcap_bit arp;
122 enum ocelot_vcap_bit req;
123 enum ocelot_vcap_bit unknown;
124 enum ocelot_vcap_bit smac_match;
125 enum ocelot_vcap_bit dmac_match;
126
127
128 enum ocelot_vcap_bit length;
129
130 enum ocelot_vcap_bit ip;
131 enum ocelot_vcap_bit ethernet;
132 struct ocelot_vcap_ipv4 sip;
133 struct ocelot_vcap_ipv4 dip;
134};
135
136struct ocelot_vcap_key_ipv4 {
137 enum ocelot_vcap_bit ttl;
138 enum ocelot_vcap_bit fragment;
139 enum ocelot_vcap_bit options;
140 struct ocelot_vcap_u8 ds;
141 struct ocelot_vcap_u8 proto;
142 struct ocelot_vcap_ipv4 sip;
143 struct ocelot_vcap_ipv4 dip;
144 struct ocelot_vcap_u48 data;
145 struct ocelot_vcap_udp_tcp sport;
146 struct ocelot_vcap_udp_tcp dport;
147 enum ocelot_vcap_bit tcp_fin;
148 enum ocelot_vcap_bit tcp_syn;
149 enum ocelot_vcap_bit tcp_rst;
150 enum ocelot_vcap_bit tcp_psh;
151 enum ocelot_vcap_bit tcp_ack;
152 enum ocelot_vcap_bit tcp_urg;
153 enum ocelot_vcap_bit sip_eq_dip;
154 enum ocelot_vcap_bit sport_eq_dport;
155 enum ocelot_vcap_bit seq_zero;
156};
157
158struct ocelot_vcap_key_ipv6 {
159 struct ocelot_vcap_u8 proto;
160 struct ocelot_vcap_u128 sip;
161 enum ocelot_vcap_bit ttl;
162 struct ocelot_vcap_u8 ds;
163 struct ocelot_vcap_u48 data;
164 struct ocelot_vcap_udp_tcp sport;
165 struct ocelot_vcap_udp_tcp dport;
166 enum ocelot_vcap_bit tcp_fin;
167 enum ocelot_vcap_bit tcp_syn;
168 enum ocelot_vcap_bit tcp_rst;
169 enum ocelot_vcap_bit tcp_psh;
170 enum ocelot_vcap_bit tcp_ack;
171 enum ocelot_vcap_bit tcp_urg;
172 enum ocelot_vcap_bit sip_eq_dip;
173 enum ocelot_vcap_bit sport_eq_dport;
174 enum ocelot_vcap_bit seq_zero;
175};
176
177enum ocelot_vcap_action {
178 OCELOT_VCAP_ACTION_DROP,
179 OCELOT_VCAP_ACTION_TRAP,
180 OCELOT_VCAP_ACTION_POLICE,
181};
182
183struct ocelot_vcap_stats {
184 u64 bytes;
185 u64 pkts;
186 u64 used;
187};
188
189struct ocelot_vcap_filter {
190 struct list_head list;
191
192 u16 prio;
193 u32 id;
194
195 enum ocelot_vcap_action action;
196 struct ocelot_vcap_stats stats;
197 unsigned long ingress_port_mask;
198
199 enum ocelot_vcap_bit dmac_mc;
200 enum ocelot_vcap_bit dmac_bc;
201 struct ocelot_vcap_key_vlan vlan;
202
203 enum ocelot_vcap_key_type key_type;
204 union {
205
206 struct ocelot_vcap_key_etype etype;
207 struct ocelot_vcap_key_llc llc;
208 struct ocelot_vcap_key_snap snap;
209 struct ocelot_vcap_key_arp arp;
210 struct ocelot_vcap_key_ipv4 ipv4;
211 struct ocelot_vcap_key_ipv6 ipv6;
212 } key;
213 struct ocelot_policer pol;
214 u32 pol_ix;
215};
216
217int ocelot_vcap_filter_add(struct ocelot *ocelot,
218 struct ocelot_vcap_filter *rule,
219 struct netlink_ext_ack *extack);
220int ocelot_vcap_filter_del(struct ocelot *ocelot,
221 struct ocelot_vcap_filter *rule);
222int ocelot_vcap_filter_stats_update(struct ocelot *ocelot,
223 struct ocelot_vcap_filter *rule);
224
225int ocelot_vcap_init(struct ocelot *ocelot);
226
227int ocelot_setup_tc_cls_flower(struct ocelot_port_private *priv,
228 struct flow_cls_offload *f,
229 bool ingress);
230
231#endif
232