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 <net/sch_generic.h>
11 #include <net/pkt_cls.h>
17 enum ocelot_vcap_bit
{
23 struct ocelot_vcap_u8
{
28 struct ocelot_vcap_u16
{
33 struct ocelot_vcap_u24
{
38 struct ocelot_vcap_u32
{
43 struct ocelot_vcap_u40
{
48 struct ocelot_vcap_u48
{
53 struct ocelot_vcap_u64
{
58 struct ocelot_vcap_u128
{
63 struct ocelot_vcap_vid
{
68 struct ocelot_vcap_ipv4
{
69 struct ocelot_ipv4 value
;
70 struct ocelot_ipv4 mask
;
73 struct ocelot_vcap_udp_tcp
{
78 enum ocelot_ace_type
{
80 OCELOT_ACE_TYPE_ETYPE
,
88 struct ocelot_ace_vlan
{
89 struct ocelot_vcap_vid vid
; /* VLAN ID (12 bit) */
90 struct ocelot_vcap_u8 pcp
; /* PCP (3 bit) */
91 enum ocelot_vcap_bit dei
; /* DEI */
92 enum ocelot_vcap_bit tagged
; /* Tagged/untagged frame */
95 struct ocelot_ace_frame_etype
{
96 struct ocelot_vcap_u48 dmac
;
97 struct ocelot_vcap_u48 smac
;
98 struct ocelot_vcap_u16 etype
;
99 struct ocelot_vcap_u16 data
; /* MAC data */
102 struct ocelot_ace_frame_llc
{
103 struct ocelot_vcap_u48 dmac
;
104 struct ocelot_vcap_u48 smac
;
106 /* LLC header: DSAP at byte 0, SSAP at byte 1, Control at byte 2 */
107 struct ocelot_vcap_u32 llc
;
110 struct ocelot_ace_frame_snap
{
111 struct ocelot_vcap_u48 dmac
;
112 struct ocelot_vcap_u48 smac
;
114 /* SNAP header: Organization Code at byte 0, Type at byte 3 */
115 struct ocelot_vcap_u40 snap
;
118 struct ocelot_ace_frame_arp
{
119 struct ocelot_vcap_u48 smac
;
120 enum ocelot_vcap_bit arp
; /* Opcode ARP/RARP */
121 enum ocelot_vcap_bit req
; /* Opcode request/reply */
122 enum ocelot_vcap_bit unknown
; /* Opcode unknown */
123 enum ocelot_vcap_bit smac_match
; /* Sender MAC matches SMAC */
124 enum ocelot_vcap_bit dmac_match
; /* Target MAC matches DMAC */
126 /**< Protocol addr. length 4, hardware length 6 */
127 enum ocelot_vcap_bit length
;
129 enum ocelot_vcap_bit ip
; /* Protocol address type IP */
130 enum ocelot_vcap_bit ethernet
; /* Hardware address type Ethernet */
131 struct ocelot_vcap_ipv4 sip
; /* Sender IP address */
132 struct ocelot_vcap_ipv4 dip
; /* Target IP address */
135 struct ocelot_ace_frame_ipv4
{
136 enum ocelot_vcap_bit ttl
; /* TTL zero */
137 enum ocelot_vcap_bit fragment
; /* Fragment */
138 enum ocelot_vcap_bit options
; /* Header options */
139 struct ocelot_vcap_u8 ds
;
140 struct ocelot_vcap_u8 proto
; /* Protocol */
141 struct ocelot_vcap_ipv4 sip
; /* Source IP address */
142 struct ocelot_vcap_ipv4 dip
; /* Destination IP address */
143 struct ocelot_vcap_u48 data
; /* Not UDP/TCP: IP data */
144 struct ocelot_vcap_udp_tcp sport
; /* UDP/TCP: Source port */
145 struct ocelot_vcap_udp_tcp dport
; /* UDP/TCP: Destination port */
146 enum ocelot_vcap_bit tcp_fin
;
147 enum ocelot_vcap_bit tcp_syn
;
148 enum ocelot_vcap_bit tcp_rst
;
149 enum ocelot_vcap_bit tcp_psh
;
150 enum ocelot_vcap_bit tcp_ack
;
151 enum ocelot_vcap_bit tcp_urg
;
152 enum ocelot_vcap_bit sip_eq_dip
; /* SIP equals DIP */
153 enum ocelot_vcap_bit sport_eq_dport
; /* SPORT equals DPORT */
154 enum ocelot_vcap_bit seq_zero
; /* TCP sequence number is zero */
157 struct ocelot_ace_frame_ipv6
{
158 struct ocelot_vcap_u8 proto
; /* IPv6 protocol */
159 struct ocelot_vcap_u128 sip
; /* IPv6 source (byte 0-7 ignored) */
160 enum ocelot_vcap_bit ttl
; /* TTL zero */
161 struct ocelot_vcap_u8 ds
;
162 struct ocelot_vcap_u48 data
; /* Not UDP/TCP: IP data */
163 struct ocelot_vcap_udp_tcp sport
;
164 struct ocelot_vcap_udp_tcp dport
;
165 enum ocelot_vcap_bit tcp_fin
;
166 enum ocelot_vcap_bit tcp_syn
;
167 enum ocelot_vcap_bit tcp_rst
;
168 enum ocelot_vcap_bit tcp_psh
;
169 enum ocelot_vcap_bit tcp_ack
;
170 enum ocelot_vcap_bit tcp_urg
;
171 enum ocelot_vcap_bit sip_eq_dip
; /* SIP equals DIP */
172 enum ocelot_vcap_bit sport_eq_dport
; /* SPORT equals DPORT */
173 enum ocelot_vcap_bit seq_zero
; /* TCP sequence number is zero */
176 enum ocelot_ace_action
{
177 OCELOT_ACL_ACTION_DROP
,
178 OCELOT_ACL_ACTION_TRAP
,
181 struct ocelot_ace_stats
{
187 struct ocelot_ace_rule
{
188 struct list_head list
;
189 struct ocelot_port
*port
;
194 enum ocelot_ace_action action
;
195 struct ocelot_ace_stats stats
;
198 enum ocelot_vcap_bit dmac_mc
;
199 enum ocelot_vcap_bit dmac_bc
;
200 struct ocelot_ace_vlan vlan
;
202 enum ocelot_ace_type type
;
204 /* ocelot_ACE_TYPE_ANY: No specific fields */
205 struct ocelot_ace_frame_etype etype
;
206 struct ocelot_ace_frame_llc llc
;
207 struct ocelot_ace_frame_snap snap
;
208 struct ocelot_ace_frame_arp arp
;
209 struct ocelot_ace_frame_ipv4 ipv4
;
210 struct ocelot_ace_frame_ipv6 ipv6
;
214 struct ocelot_acl_block
{
215 struct list_head rules
;
216 struct ocelot
*ocelot
;
220 int ocelot_ace_rule_offload_add(struct ocelot_ace_rule
*rule
);
221 int ocelot_ace_rule_offload_del(struct ocelot_ace_rule
*rule
);
222 int ocelot_ace_rule_stats_update(struct ocelot_ace_rule
*rule
);
224 int ocelot_ace_init(struct ocelot
*ocelot
);
225 void ocelot_ace_deinit(void);
227 int ocelot_setup_tc_block_flower_bind(struct ocelot_port_private
*priv
,
228 struct flow_block_offload
*f
);
229 void ocelot_setup_tc_block_flower_unbind(struct ocelot_port_private
*priv
,
230 struct flow_block_offload
*f
);
232 #endif /* _MSCC_OCELOT_ACE_H_ */