Commit | Line | Data |
---|---|---|
da56552d EC |
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 EF100_MAE_H | |
13 | #define EF100_MAE_H | |
14 | /* MCDI interface for the ef100 Match-Action Engine */ | |
15 | ||
25414b2a | 16 | #include <net/devlink.h> |
da56552d | 17 | #include "net_driver.h" |
67ab160e EC |
18 | #include "tc.h" |
19 | #include "mcdi_pcol.h" /* needed for various MC_CMD_MAE_*_NULL defines */ | |
da56552d | 20 | |
e37f3b15 EC |
21 | int efx_mae_allocate_mport(struct efx_nic *efx, u32 *id, u32 *label); |
22 | int efx_mae_free_mport(struct efx_nic *efx, u32 id); | |
23 | ||
6f6838aa | 24 | void efx_mae_mport_wire(struct efx_nic *efx, u32 *out); |
67ab160e | 25 | void efx_mae_mport_uplink(struct efx_nic *efx, u32 *out); |
da56552d | 26 | void efx_mae_mport_vf(struct efx_nic *efx, u32 vf_id, u32 *out); |
67ab160e | 27 | void efx_mae_mport_mport(struct efx_nic *efx, u32 mport_id, u32 *out); |
da56552d EC |
28 | |
29 | int efx_mae_lookup_mport(struct efx_nic *efx, u32 selector, u32 *id); | |
30 | ||
a6a15aca AL |
31 | struct mae_mport_desc { |
32 | u32 mport_id; | |
33 | u32 flags; | |
34 | u32 caller_flags; /* enum mae_mport_desc_caller_flags */ | |
35 | u32 mport_type; /* MAE_MPORT_DESC_MPORT_TYPE_* */ | |
36 | union { | |
37 | u32 port_idx; /* for mport_type == NET_PORT */ | |
38 | u32 alias_mport_id; /* for mport_type == ALIAS */ | |
39 | struct { /* for mport_type == VNIC */ | |
40 | u32 vnic_client_type; /* MAE_MPORT_DESC_VNIC_CLIENT_TYPE_* */ | |
41 | u32 interface_idx; | |
42 | u16 pf_idx; | |
43 | u16 vf_idx; | |
44 | }; | |
45 | }; | |
46 | struct rhash_head linkage; | |
25414b2a | 47 | struct devlink_port dl_port; |
a6a15aca AL |
48 | }; |
49 | ||
50 | int efx_mae_enumerate_mports(struct efx_nic *efx); | |
51 | struct mae_mport_desc *efx_mae_get_mport(struct efx_nic *efx, u32 mport_id); | |
52 | void efx_mae_put_mport(struct efx_nic *efx, struct mae_mport_desc *desc); | |
53 | ||
54 | /** | |
55 | * struct efx_mae - MAE information | |
56 | * | |
57 | * @efx: The associated NIC | |
58 | * @mports_ht: m-port descriptions from MC_CMD_MAE_MPORT_READ_JOURNAL | |
59 | */ | |
60 | struct efx_mae { | |
61 | struct efx_nic *efx; | |
62 | struct rhashtable mports_ht; | |
63 | }; | |
64 | ||
e5731274 EC |
65 | int efx_mae_start_counters(struct efx_nic *efx, struct efx_rx_queue *rx_queue); |
66 | int efx_mae_stop_counters(struct efx_nic *efx, struct efx_rx_queue *rx_queue); | |
67 | void efx_mae_counters_grant_credits(struct work_struct *work); | |
68 | ||
7ce3e235 EC |
69 | #define MAE_NUM_FIELDS (MAE_FIELD_ENC_VNET_ID + 1) |
70 | ||
71 | struct mae_caps { | |
72 | u32 match_field_count; | |
17654d84 | 73 | u32 encap_types; |
7ce3e235 EC |
74 | u32 action_prios; |
75 | u8 action_rule_fields[MAE_NUM_FIELDS]; | |
b9d5c9b7 | 76 | u8 outer_rule_fields[MAE_NUM_FIELDS]; |
7ce3e235 EC |
77 | }; |
78 | ||
79 | int efx_mae_get_caps(struct efx_nic *efx, struct mae_caps *caps); | |
80 | ||
d902e1a7 EC |
81 | int efx_mae_match_check_caps(struct efx_nic *efx, |
82 | const struct efx_tc_match_fields *mask, | |
83 | struct netlink_ext_ack *extack); | |
b9d5c9b7 | 84 | int efx_mae_check_encap_match_caps(struct efx_nic *efx, bool ipv6, |
b6583d5e | 85 | u8 ip_tos_mask, __be16 udp_sport_mask, |
b9d5c9b7 | 86 | struct netlink_ext_ack *extack); |
17654d84 EC |
87 | int efx_mae_check_encap_type_supported(struct efx_nic *efx, |
88 | enum efx_encap_type typ); | |
d902e1a7 | 89 | |
0363aa29 EC |
90 | int efx_mae_allocate_counter(struct efx_nic *efx, struct efx_tc_counter *cnt); |
91 | int efx_mae_free_counter(struct efx_nic *efx, struct efx_tc_counter *cnt); | |
92 | ||
f1363154 EC |
93 | int efx_mae_allocate_encap_md(struct efx_nic *efx, |
94 | struct efx_tc_encap_action *encap); | |
95 | int efx_mae_update_encap_md(struct efx_nic *efx, | |
96 | struct efx_tc_encap_action *encap); | |
97 | int efx_mae_free_encap_md(struct efx_nic *efx, | |
98 | struct efx_tc_encap_action *encap); | |
99 | ||
67ab160e EC |
100 | int efx_mae_alloc_action_set(struct efx_nic *efx, struct efx_tc_action_set *act); |
101 | int efx_mae_free_action_set(struct efx_nic *efx, u32 fw_id); | |
102 | ||
103 | int efx_mae_alloc_action_set_list(struct efx_nic *efx, | |
104 | struct efx_tc_action_set_list *acts); | |
105 | int efx_mae_free_action_set_list(struct efx_nic *efx, | |
106 | struct efx_tc_action_set_list *acts); | |
107 | ||
2245eb00 EC |
108 | int efx_mae_register_encap_match(struct efx_nic *efx, |
109 | struct efx_tc_encap_match *encap); | |
110 | int efx_mae_unregister_encap_match(struct efx_nic *efx, | |
111 | struct efx_tc_encap_match *encap); | |
112 | ||
67ab160e EC |
113 | int efx_mae_insert_rule(struct efx_nic *efx, const struct efx_tc_match *match, |
114 | u32 prio, u32 acts_id, u32 *id); | |
69819d3b | 115 | int efx_mae_update_rule(struct efx_nic *efx, u32 acts_id, u32 id); |
67ab160e EC |
116 | int efx_mae_delete_rule(struct efx_nic *efx, u32 id); |
117 | ||
a6a15aca AL |
118 | int efx_init_mae(struct efx_nic *efx); |
119 | void efx_fini_mae(struct efx_nic *efx); | |
120 | void efx_mae_remove_mport(void *desc, void *arg); | |
5227adff AL |
121 | int efx_mae_fw_lookup_mport(struct efx_nic *efx, u32 selector, u32 *id); |
122 | int efx_mae_lookup_mport(struct efx_nic *efx, u32 vf, u32 *id); | |
da56552d | 123 | #endif /* EF100_MAE_H */ |