xref: /openbmc/linux/drivers/net/ethernet/sfc/tc.h (revision 747f7a29)
1 /* SPDX-License-Identifier: GPL-2.0-only */
2 /****************************************************************************
3  * Driver for Solarflare network controllers and boards
4  * Copyright 2019 Solarflare Communications Inc.
5  * Copyright 2020-2022 Xilinx Inc.
6  *
7  * This program is free software; you can redistribute it and/or modify it
8  * under the terms of the GNU General Public License version 2 as published
9  * by the Free Software Foundation, incorporated herein by reference.
10  */
11 
12 #ifndef EFX_TC_H
13 #define EFX_TC_H
14 #include "net_driver.h"
15 
16 struct efx_tc_action_set {
17 	u16 deliver:1;
18 	u32 dest_mport;
19 	u32 fw_id; /* index of this entry in firmware actions table */
20 	struct list_head list;
21 };
22 
23 struct efx_tc_match_fields {
24 	/* L1 */
25 	u32 ingress_port;
26 };
27 
28 struct efx_tc_match {
29 	struct efx_tc_match_fields value;
30 	struct efx_tc_match_fields mask;
31 };
32 
33 struct efx_tc_action_set_list {
34 	struct list_head list;
35 	u32 fw_id;
36 };
37 
38 struct efx_tc_flow_rule {
39 	struct efx_tc_match match;
40 	struct efx_tc_action_set_list acts;
41 	u32 fw_id;
42 };
43 
44 enum efx_tc_rule_prios {
45 	EFX_TC_PRIO_DFLT, /* Default switch rule; one of efx_tc_default_rules */
46 	EFX_TC_PRIO__NUM
47 };
48 
49 /**
50  * struct efx_tc_state - control plane data for TC offload
51  *
52  * @reps_mport_id: MAE port allocated for representor RX
53  * @reps_filter_uc: VNIC filter for representor unicast RX (promisc)
54  * @reps_filter_mc: VNIC filter for representor multicast RX (allmulti)
55  * @reps_mport_vport_id: vport_id for representor RX filters
56  * @dflt: Match-action rules for default switching; at priority
57  *	%EFX_TC_PRIO_DFLT.  Named by *ingress* port
58  * @dflt.pf: rule for traffic ingressing from PF (egresses to wire)
59  * @dflt.wire: rule for traffic ingressing from wire (egresses to PF)
60  */
61 struct efx_tc_state {
62 	u32 reps_mport_id, reps_mport_vport_id;
63 	s32 reps_filter_uc, reps_filter_mc;
64 	struct {
65 		struct efx_tc_flow_rule pf;
66 		struct efx_tc_flow_rule wire;
67 	} dflt;
68 };
69 
70 struct efx_rep;
71 
72 int efx_tc_configure_default_rule_rep(struct efx_rep *efv);
73 void efx_tc_deconfigure_default_rule(struct efx_nic *efx,
74 				     struct efx_tc_flow_rule *rule);
75 
76 int efx_tc_insert_rep_filters(struct efx_nic *efx);
77 void efx_tc_remove_rep_filters(struct efx_nic *efx);
78 
79 int efx_init_tc(struct efx_nic *efx);
80 void efx_fini_tc(struct efx_nic *efx);
81 
82 int efx_init_struct_tc(struct efx_nic *efx);
83 void efx_fini_struct_tc(struct efx_nic *efx);
84 
85 #endif /* EFX_TC_H */
86