1 /* SPDX-License-Identifier: GPL-2.0-only */
2 /* Copyright (C) 2019 Chelsio Communications.  All rights reserved. */
3 
4 #ifndef __CXGB4_TC_MATCHALL_H__
5 #define __CXGB4_TC_MATCHALL_H__
6 
7 #include <net/pkt_cls.h>
8 
9 enum cxgb4_matchall_state {
10 	CXGB4_MATCHALL_STATE_DISABLED = 0,
11 	CXGB4_MATCHALL_STATE_ENABLED,
12 };
13 
14 struct cxgb4_matchall_egress_entry {
15 	enum cxgb4_matchall_state state; /* Current MATCHALL offload state */
16 	u8 hwtc; /* Traffic class bound to port */
17 	u64 cookie; /* Used to identify the MATCHALL rule offloaded */
18 };
19 
20 struct cxgb4_matchall_ingress_entry {
21 	enum cxgb4_matchall_state state; /* Current MATCHALL offload state */
22 	u32 tid; /* Index to hardware filter entry */
23 	struct ch_filter_specification fs; /* Filter entry */
24 	u16 viid_mirror; /* Identifier for allocated Mirror VI */
25 	u64 bytes; /* # of bytes hitting the filter */
26 	u64 packets; /* # of packets hitting the filter */
27 	u64 last_used; /* Last updated jiffies time */
28 };
29 
30 struct cxgb4_tc_port_matchall {
31 	struct cxgb4_matchall_egress_entry egress; /* Egress offload info */
32 	struct cxgb4_matchall_ingress_entry ingress; /* Ingress offload info */
33 };
34 
35 struct cxgb4_tc_matchall {
36 	struct cxgb4_tc_port_matchall *port_matchall; /* Per port entry */
37 };
38 
39 int cxgb4_tc_matchall_replace(struct net_device *dev,
40 			      struct tc_cls_matchall_offload *cls_matchall,
41 			      bool ingress);
42 int cxgb4_tc_matchall_destroy(struct net_device *dev,
43 			      struct tc_cls_matchall_offload *cls_matchall,
44 			      bool ingress);
45 int cxgb4_tc_matchall_stats(struct net_device *dev,
46 			    struct tc_cls_matchall_offload *cls_matchall);
47 
48 int cxgb4_init_tc_matchall(struct adapter *adap);
49 void cxgb4_cleanup_tc_matchall(struct adapter *adap);
50 #endif /* __CXGB4_TC_MATCHALL_H__ */
51