gpio: rcar: Fix runtime PM imbalance on error
[linux/fpc-iii.git] / drivers / net / ethernet / mscc / ocelot_ace.h
blob29d22c5667865bc664afa1471c5e040d8de7af1c
1 /* SPDX-License-Identifier: (GPL-2.0 OR MIT) */
2 /* Microsemi Ocelot Switch driver
3 * Copyright (c) 2019 Microsemi Corporation
4 */
6 #ifndef _MSCC_OCELOT_ACE_H_
7 #define _MSCC_OCELOT_ACE_H_
9 #include "ocelot.h"
10 #include "ocelot_police.h"
11 #include <net/sch_generic.h>
12 #include <net/pkt_cls.h>
14 struct ocelot_ipv4 {
15 u8 addr[4];
18 enum ocelot_vcap_bit {
19 OCELOT_VCAP_BIT_ANY,
20 OCELOT_VCAP_BIT_0,
21 OCELOT_VCAP_BIT_1
24 struct ocelot_vcap_u8 {
25 u8 value[1];
26 u8 mask[1];
29 struct ocelot_vcap_u16 {
30 u8 value[2];
31 u8 mask[2];
34 struct ocelot_vcap_u24 {
35 u8 value[3];
36 u8 mask[3];
39 struct ocelot_vcap_u32 {
40 u8 value[4];
41 u8 mask[4];
44 struct ocelot_vcap_u40 {
45 u8 value[5];
46 u8 mask[5];
49 struct ocelot_vcap_u48 {
50 u8 value[6];
51 u8 mask[6];
54 struct ocelot_vcap_u64 {
55 u8 value[8];
56 u8 mask[8];
59 struct ocelot_vcap_u128 {
60 u8 value[16];
61 u8 mask[16];
64 struct ocelot_vcap_vid {
65 u16 value;
66 u16 mask;
69 struct ocelot_vcap_ipv4 {
70 struct ocelot_ipv4 value;
71 struct ocelot_ipv4 mask;
74 struct ocelot_vcap_udp_tcp {
75 u16 value;
76 u16 mask;
79 enum ocelot_ace_type {
80 OCELOT_ACE_TYPE_ANY,
81 OCELOT_ACE_TYPE_ETYPE,
82 OCELOT_ACE_TYPE_LLC,
83 OCELOT_ACE_TYPE_SNAP,
84 OCELOT_ACE_TYPE_ARP,
85 OCELOT_ACE_TYPE_IPV4,
86 OCELOT_ACE_TYPE_IPV6
89 struct ocelot_ace_vlan {
90 struct ocelot_vcap_vid vid; /* VLAN ID (12 bit) */
91 struct ocelot_vcap_u8 pcp; /* PCP (3 bit) */
92 enum ocelot_vcap_bit dei; /* DEI */
93 enum ocelot_vcap_bit tagged; /* Tagged/untagged frame */
96 struct ocelot_ace_frame_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; /* MAC data */
103 struct ocelot_ace_frame_llc {
104 struct ocelot_vcap_u48 dmac;
105 struct ocelot_vcap_u48 smac;
107 /* LLC header: DSAP at byte 0, SSAP at byte 1, Control at byte 2 */
108 struct ocelot_vcap_u32 llc;
111 struct ocelot_ace_frame_snap {
112 struct ocelot_vcap_u48 dmac;
113 struct ocelot_vcap_u48 smac;
115 /* SNAP header: Organization Code at byte 0, Type at byte 3 */
116 struct ocelot_vcap_u40 snap;
119 struct ocelot_ace_frame_arp {
120 struct ocelot_vcap_u48 smac;
121 enum ocelot_vcap_bit arp; /* Opcode ARP/RARP */
122 enum ocelot_vcap_bit req; /* Opcode request/reply */
123 enum ocelot_vcap_bit unknown; /* Opcode unknown */
124 enum ocelot_vcap_bit smac_match; /* Sender MAC matches SMAC */
125 enum ocelot_vcap_bit dmac_match; /* Target MAC matches DMAC */
127 /**< Protocol addr. length 4, hardware length 6 */
128 enum ocelot_vcap_bit length;
130 enum ocelot_vcap_bit ip; /* Protocol address type IP */
131 enum ocelot_vcap_bit ethernet; /* Hardware address type Ethernet */
132 struct ocelot_vcap_ipv4 sip; /* Sender IP address */
133 struct ocelot_vcap_ipv4 dip; /* Target IP address */
136 struct ocelot_ace_frame_ipv4 {
137 enum ocelot_vcap_bit ttl; /* TTL zero */
138 enum ocelot_vcap_bit fragment; /* Fragment */
139 enum ocelot_vcap_bit options; /* Header options */
140 struct ocelot_vcap_u8 ds;
141 struct ocelot_vcap_u8 proto; /* Protocol */
142 struct ocelot_vcap_ipv4 sip; /* Source IP address */
143 struct ocelot_vcap_ipv4 dip; /* Destination IP address */
144 struct ocelot_vcap_u48 data; /* Not UDP/TCP: IP data */
145 struct ocelot_vcap_udp_tcp sport; /* UDP/TCP: Source port */
146 struct ocelot_vcap_udp_tcp dport; /* UDP/TCP: Destination port */
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; /* SIP equals DIP */
154 enum ocelot_vcap_bit sport_eq_dport; /* SPORT equals DPORT */
155 enum ocelot_vcap_bit seq_zero; /* TCP sequence number is zero */
158 struct ocelot_ace_frame_ipv6 {
159 struct ocelot_vcap_u8 proto; /* IPv6 protocol */
160 struct ocelot_vcap_u128 sip; /* IPv6 source (byte 0-7 ignored) */
161 enum ocelot_vcap_bit ttl; /* TTL zero */
162 struct ocelot_vcap_u8 ds;
163 struct ocelot_vcap_u48 data; /* Not UDP/TCP: IP 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; /* SIP equals DIP */
173 enum ocelot_vcap_bit sport_eq_dport; /* SPORT equals DPORT */
174 enum ocelot_vcap_bit seq_zero; /* TCP sequence number is zero */
177 enum ocelot_ace_action {
178 OCELOT_ACL_ACTION_DROP,
179 OCELOT_ACL_ACTION_TRAP,
180 OCELOT_ACL_ACTION_POLICE,
183 struct ocelot_ace_stats {
184 u64 bytes;
185 u64 pkts;
186 u64 used;
189 struct ocelot_ace_rule {
190 struct list_head list;
192 u16 prio;
193 u32 id;
195 enum ocelot_ace_action action;
196 struct ocelot_ace_stats stats;
197 u16 ingress_port_mask;
199 enum ocelot_vcap_bit dmac_mc;
200 enum ocelot_vcap_bit dmac_bc;
201 struct ocelot_ace_vlan vlan;
203 enum ocelot_ace_type type;
204 union {
205 /* ocelot_ACE_TYPE_ANY: No specific fields */
206 struct ocelot_ace_frame_etype etype;
207 struct ocelot_ace_frame_llc llc;
208 struct ocelot_ace_frame_snap snap;
209 struct ocelot_ace_frame_arp arp;
210 struct ocelot_ace_frame_ipv4 ipv4;
211 struct ocelot_ace_frame_ipv6 ipv6;
212 } frame;
213 struct ocelot_policer pol;
214 u32 pol_ix;
217 int ocelot_ace_rule_offload_add(struct ocelot *ocelot,
218 struct ocelot_ace_rule *rule);
219 int ocelot_ace_rule_offload_del(struct ocelot *ocelot,
220 struct ocelot_ace_rule *rule);
221 int ocelot_ace_rule_stats_update(struct ocelot *ocelot,
222 struct ocelot_ace_rule *rule);
224 int ocelot_ace_init(struct ocelot *ocelot);
226 int ocelot_setup_tc_cls_flower(struct ocelot_port_private *priv,
227 struct flow_cls_offload *f,
228 bool ingress);
230 #endif /* _MSCC_OCELOT_ACE_H_ */