1 /* SPDX-License-Identifier: GPL-2.0+ */
2 /* Microchip Sparx5 Switch driver VCAP implementation
3  *
4  * Copyright (c) 2022 Microchip Technology Inc. and its subsidiaries.
5  *
6  * The Sparx5 Chip Register Model can be browsed at this location:
7  * https://github.com/microchip-ung/sparx-5_reginfo
8  */
9 
10 #ifndef __SPARX5_VCAP_IMPL_H__
11 #define __SPARX5_VCAP_IMPL_H__
12 
13 #include <linux/types.h>
14 #include <linux/list.h>
15 
16 #include "vcap_api.h"
17 #include "vcap_api_client.h"
18 
19 #define SPARX5_VCAP_CID_IS2_L0 VCAP_CID_INGRESS_STAGE2_L0 /* IS2 lookup 0 */
20 #define SPARX5_VCAP_CID_IS2_L1 VCAP_CID_INGRESS_STAGE2_L1 /* IS2 lookup 1 */
21 #define SPARX5_VCAP_CID_IS2_L2 VCAP_CID_INGRESS_STAGE2_L2 /* IS2 lookup 2 */
22 #define SPARX5_VCAP_CID_IS2_L3 VCAP_CID_INGRESS_STAGE2_L3 /* IS2 lookup 3 */
23 #define SPARX5_VCAP_CID_IS2_MAX \
24 	(VCAP_CID_INGRESS_STAGE2_L3 + VCAP_CID_LOOKUP_SIZE - 1) /* IS2 Max */
25 
26 /* IS2 port keyset selection control */
27 
28 /* IS2 non-ethernet traffic type keyset generation */
29 enum vcap_is2_port_sel_noneth {
30 	VCAP_IS2_PS_NONETH_MAC_ETYPE,
31 	VCAP_IS2_PS_NONETH_CUSTOM_1,
32 	VCAP_IS2_PS_NONETH_CUSTOM_2,
33 	VCAP_IS2_PS_NONETH_NO_LOOKUP
34 };
35 
36 /* IS2 IPv4 unicast traffic type keyset generation */
37 enum vcap_is2_port_sel_ipv4_uc {
38 	VCAP_IS2_PS_IPV4_UC_MAC_ETYPE,
39 	VCAP_IS2_PS_IPV4_UC_IP4_TCP_UDP_OTHER,
40 	VCAP_IS2_PS_IPV4_UC_IP_7TUPLE,
41 };
42 
43 /* IS2 IPv4 multicast traffic type keyset generation */
44 enum vcap_is2_port_sel_ipv4_mc {
45 	VCAP_IS2_PS_IPV4_MC_MAC_ETYPE,
46 	VCAP_IS2_PS_IPV4_MC_IP4_TCP_UDP_OTHER,
47 	VCAP_IS2_PS_IPV4_MC_IP_7TUPLE,
48 	VCAP_IS2_PS_IPV4_MC_IP4_VID,
49 };
50 
51 /* IS2 IPv6 unicast traffic type keyset generation */
52 enum vcap_is2_port_sel_ipv6_uc {
53 	VCAP_IS2_PS_IPV6_UC_MAC_ETYPE,
54 	VCAP_IS2_PS_IPV6_UC_IP_7TUPLE,
55 	VCAP_IS2_PS_IPV6_UC_IP6_STD,
56 	VCAP_IS2_PS_IPV6_UC_IP4_TCP_UDP_OTHER,
57 };
58 
59 /* IS2 IPv6 multicast traffic type keyset generation */
60 enum vcap_is2_port_sel_ipv6_mc {
61 	VCAP_IS2_PS_IPV6_MC_MAC_ETYPE,
62 	VCAP_IS2_PS_IPV6_MC_IP_7TUPLE,
63 	VCAP_IS2_PS_IPV6_MC_IP6_VID,
64 	VCAP_IS2_PS_IPV6_MC_IP6_STD,
65 	VCAP_IS2_PS_IPV6_MC_IP4_TCP_UDP_OTHER,
66 };
67 
68 /* IS2 ARP traffic type keyset generation */
69 enum vcap_is2_port_sel_arp {
70 	VCAP_IS2_PS_ARP_MAC_ETYPE,
71 	VCAP_IS2_PS_ARP_ARP,
72 };
73 
74 /* Get the port keyset for the vcap lookup */
75 int sparx5_vcap_get_port_keyset(struct net_device *ndev,
76 				struct vcap_admin *admin,
77 				int cid,
78 				u16 l3_proto,
79 				struct vcap_keyset_list *kslist);
80 
81 #endif /* __SPARX5_VCAP_IMPL_H__ */
82