1 /* SPDX-License-Identifier: (GPL-2.0 OR MIT) */
2 /* Microsemi Ocelot Switch driver
3 * Copyright (c) 2019 Microsemi Corporation
6 #ifndef _MSCC_OCELOT_ACE_H_
7 #define _MSCC_OCELOT_ACE_H_
10 #include "ocelot_police.h"
11 #include <net/sch_generic.h>
12 #include <net/pkt_cls.h>
18 enum ocelot_vcap_bit
{
24 struct ocelot_vcap_u8
{
29 struct ocelot_vcap_u16
{
34 struct ocelot_vcap_u24
{
39 struct ocelot_vcap_u32
{
44 struct ocelot_vcap_u40
{
49 struct ocelot_vcap_u48
{
54 struct ocelot_vcap_u64
{
59 struct ocelot_vcap_u128
{
64 struct ocelot_vcap_vid
{
69 struct ocelot_vcap_ipv4
{
70 struct ocelot_ipv4 value
;
71 struct ocelot_ipv4 mask
;
74 struct ocelot_vcap_udp_tcp
{
79 enum ocelot_ace_type
{
81 OCELOT_ACE_TYPE_ETYPE
,
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
{
189 struct ocelot_ace_rule
{
190 struct list_head list
;
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
;
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
;
213 struct ocelot_policer pol
;
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
,
230 #endif /* _MSCC_OCELOT_ACE_H_ */