Jiri Pirko | 56ade8f | 2015-10-16 14:01:37 +0200 | [diff] [blame] | 1 | /* |
| 2 | * drivers/net/ethernet/mellanox/mlxsw/spectrum.h |
Jiri Pirko | 22a6776 | 2017-02-03 10:29:07 +0100 | [diff] [blame] | 3 | * Copyright (c) 2015-2017 Mellanox Technologies. All rights reserved. |
| 4 | * Copyright (c) 2015-2017 Jiri Pirko <jiri@mellanox.com> |
Jiri Pirko | 56ade8f | 2015-10-16 14:01:37 +0200 | [diff] [blame] | 5 | * Copyright (c) 2015 Ido Schimmel <idosch@mellanox.com> |
| 6 | * Copyright (c) 2015 Elad Raz <eladr@mellanox.com> |
| 7 | * |
| 8 | * Redistribution and use in source and binary forms, with or without |
| 9 | * modification, are permitted provided that the following conditions are met: |
| 10 | * |
| 11 | * 1. Redistributions of source code must retain the above copyright |
| 12 | * notice, this list of conditions and the following disclaimer. |
| 13 | * 2. Redistributions in binary form must reproduce the above copyright |
| 14 | * notice, this list of conditions and the following disclaimer in the |
| 15 | * documentation and/or other materials provided with the distribution. |
| 16 | * 3. Neither the names of the copyright holders nor the names of its |
| 17 | * contributors may be used to endorse or promote products derived from |
| 18 | * this software without specific prior written permission. |
| 19 | * |
| 20 | * Alternatively, this software may be distributed under the terms of the |
| 21 | * GNU General Public License ("GPL") version 2 as published by the Free |
| 22 | * Software Foundation. |
| 23 | * |
| 24 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
| 25 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
| 26 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
| 27 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE |
| 28 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
| 29 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
| 30 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
| 31 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
| 32 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
| 33 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
| 34 | * POSSIBILITY OF SUCH DAMAGE. |
| 35 | */ |
| 36 | |
| 37 | #ifndef _MLXSW_SPECTRUM_H |
| 38 | #define _MLXSW_SPECTRUM_H |
| 39 | |
| 40 | #include <linux/types.h> |
| 41 | #include <linux/netdevice.h> |
Jiri Pirko | 6cf3c97 | 2016-07-05 11:27:39 +0200 | [diff] [blame] | 42 | #include <linux/rhashtable.h> |
Jiri Pirko | 56ade8f | 2015-10-16 14:01:37 +0200 | [diff] [blame] | 43 | #include <linux/bitops.h> |
| 44 | #include <linux/if_vlan.h> |
Ido Schimmel | 7f71eb4 | 2015-12-15 16:03:37 +0100 | [diff] [blame] | 45 | #include <linux/list.h> |
Ido Schimmel | 8e8dfe9 | 2016-04-06 17:10:10 +0200 | [diff] [blame] | 46 | #include <linux/dcbnl.h> |
Jiri Pirko | 5e9c16c | 2016-07-04 08:23:04 +0200 | [diff] [blame] | 47 | #include <linux/in6.h> |
Jiri Pirko | b45f64d | 2016-09-26 12:52:31 +0200 | [diff] [blame] | 48 | #include <linux/notifier.h> |
Yotam Gigi | 98d0f7b | 2017-01-23 11:07:11 +0100 | [diff] [blame] | 49 | #include <net/psample.h> |
Jiri Pirko | 7aa0f5a | 2017-02-03 10:29:09 +0100 | [diff] [blame] | 50 | #include <net/pkt_cls.h> |
Nogah Frankel | 861fb82 | 2017-11-06 07:23:48 +0100 | [diff] [blame] | 51 | #include <net/red.h> |
Jiri Pirko | 56ade8f | 2015-10-16 14:01:37 +0200 | [diff] [blame] | 52 | |
Elad Raz | 3a49b4f | 2016-01-10 21:06:28 +0100 | [diff] [blame] | 53 | #include "port.h" |
Jiri Pirko | 56ade8f | 2015-10-16 14:01:37 +0200 | [diff] [blame] | 54 | #include "core.h" |
Jiri Pirko | 22a6776 | 2017-02-03 10:29:07 +0100 | [diff] [blame] | 55 | #include "core_acl_flex_keys.h" |
| 56 | #include "core_acl_flex_actions.h" |
Jiri Pirko | 56ade8f | 2015-10-16 14:01:37 +0200 | [diff] [blame] | 57 | |
Ido Schimmel | a110748 | 2017-05-26 08:37:39 +0200 | [diff] [blame] | 58 | #define MLXSW_SP_FID_8021D_MAX 1024 |
Ido Schimmel | 7f71eb4 | 2015-12-15 16:03:37 +0100 | [diff] [blame] | 59 | |
Elad Raz | 53ae628 | 2016-01-10 21:06:26 +0100 | [diff] [blame] | 60 | #define MLXSW_SP_MID_MAX 7000 |
| 61 | |
Ido Schimmel | 18f1e70 | 2016-02-26 17:32:31 +0100 | [diff] [blame] | 62 | #define MLXSW_SP_PORTS_PER_CLUSTER_MAX 4 |
| 63 | |
| 64 | #define MLXSW_SP_PORT_BASE_SPEED 25000 /* Mb/s */ |
| 65 | |
Ido Schimmel | f11fbaf | 2017-10-22 23:11:49 +0200 | [diff] [blame] | 66 | #define MLXSW_SP_KVD_LINEAR_SIZE 98304 /* entries */ |
Nogah Frankel | 403547d | 2016-09-20 11:16:52 +0200 | [diff] [blame] | 67 | #define MLXSW_SP_KVD_GRANULARITY 128 |
Jiri Pirko | c602242 | 2016-07-05 11:27:46 +0200 | [diff] [blame] | 68 | |
Jiri Pirko | 56ade8f | 2015-10-16 14:01:37 +0200 | [diff] [blame] | 69 | struct mlxsw_sp_port; |
Ido Schimmel | 4724ba56 | 2017-03-10 08:53:39 +0100 | [diff] [blame] | 70 | struct mlxsw_sp_rif; |
Jiri Pirko | 56ade8f | 2015-10-16 14:01:37 +0200 | [diff] [blame] | 71 | |
Jiri Pirko | 0d65fc1 | 2015-12-03 12:12:28 +0100 | [diff] [blame] | 72 | struct mlxsw_sp_upper { |
| 73 | struct net_device *dev; |
| 74 | unsigned int ref_count; |
| 75 | }; |
| 76 | |
Ido Schimmel | a110748 | 2017-05-26 08:37:39 +0200 | [diff] [blame] | 77 | enum mlxsw_sp_rif_type { |
| 78 | MLXSW_SP_RIF_TYPE_SUBPORT, |
| 79 | MLXSW_SP_RIF_TYPE_VLAN, |
| 80 | MLXSW_SP_RIF_TYPE_FID, |
Petr Machata | 6ddb742 | 2017-09-02 23:49:19 +0200 | [diff] [blame] | 81 | MLXSW_SP_RIF_TYPE_IPIP_LB, /* IP-in-IP loopback. */ |
Ido Schimmel | a110748 | 2017-05-26 08:37:39 +0200 | [diff] [blame] | 82 | MLXSW_SP_RIF_TYPE_MAX, |
| 83 | }; |
| 84 | |
| 85 | enum mlxsw_sp_fid_type { |
| 86 | MLXSW_SP_FID_TYPE_8021Q, |
| 87 | MLXSW_SP_FID_TYPE_8021D, |
| 88 | MLXSW_SP_FID_TYPE_RFID, |
| 89 | MLXSW_SP_FID_TYPE_DUMMY, |
| 90 | MLXSW_SP_FID_TYPE_MAX, |
Ido Schimmel | 7f71eb4 | 2015-12-15 16:03:37 +0100 | [diff] [blame] | 91 | }; |
| 92 | |
Elad Raz | 3a49b4f | 2016-01-10 21:06:28 +0100 | [diff] [blame] | 93 | struct mlxsw_sp_mid { |
| 94 | struct list_head list; |
| 95 | unsigned char addr[ETH_ALEN]; |
Ido Schimmel | 46d0847 | 2016-10-30 10:09:22 +0100 | [diff] [blame] | 96 | u16 fid; |
Elad Raz | 3a49b4f | 2016-01-10 21:06:28 +0100 | [diff] [blame] | 97 | u16 mid; |
Nogah Frankel | 73b433e | 2017-09-20 16:15:06 +0200 | [diff] [blame] | 98 | bool in_hw; |
Nogah Frankel | 4cdc35e | 2017-09-20 16:15:02 +0200 | [diff] [blame] | 99 | unsigned long *ports_in_mid; /* bits array */ |
Elad Raz | 3a49b4f | 2016-01-10 21:06:28 +0100 | [diff] [blame] | 100 | }; |
| 101 | |
Yotam Gigi | 763b4b7 | 2016-07-21 12:03:17 +0200 | [diff] [blame] | 102 | enum mlxsw_sp_span_type { |
| 103 | MLXSW_SP_SPAN_EGRESS, |
| 104 | MLXSW_SP_SPAN_INGRESS |
| 105 | }; |
| 106 | |
| 107 | struct mlxsw_sp_span_inspected_port { |
| 108 | struct list_head list; |
| 109 | enum mlxsw_sp_span_type type; |
| 110 | u8 local_port; |
| 111 | }; |
| 112 | |
| 113 | struct mlxsw_sp_span_entry { |
| 114 | u8 local_port; |
| 115 | bool used; |
| 116 | struct list_head bound_ports_list; |
| 117 | int ref_count; |
| 118 | int id; |
| 119 | }; |
| 120 | |
| 121 | enum mlxsw_sp_port_mall_action_type { |
| 122 | MLXSW_SP_PORT_MALL_MIRROR, |
Yotam Gigi | 98d0f7b | 2017-01-23 11:07:11 +0100 | [diff] [blame] | 123 | MLXSW_SP_PORT_MALL_SAMPLE, |
Yotam Gigi | 763b4b7 | 2016-07-21 12:03:17 +0200 | [diff] [blame] | 124 | }; |
| 125 | |
| 126 | struct mlxsw_sp_port_mall_mirror_tc_entry { |
| 127 | u8 to_local_port; |
| 128 | bool ingress; |
| 129 | }; |
| 130 | |
| 131 | struct mlxsw_sp_port_mall_tc_entry { |
| 132 | struct list_head list; |
| 133 | unsigned long cookie; |
| 134 | enum mlxsw_sp_port_mall_action_type type; |
| 135 | union { |
| 136 | struct mlxsw_sp_port_mall_mirror_tc_entry mirror; |
| 137 | }; |
| 138 | }; |
| 139 | |
Ido Schimmel | 33cbd87 | 2017-05-16 19:38:24 +0200 | [diff] [blame] | 140 | struct mlxsw_sp_sb; |
Ido Schimmel | 5f6935c | 2017-05-16 19:38:26 +0200 | [diff] [blame] | 141 | struct mlxsw_sp_bridge; |
Ido Schimmel | 9011b67 | 2017-05-16 19:38:25 +0200 | [diff] [blame] | 142 | struct mlxsw_sp_router; |
Yotam Gigi | 0e14c77 | 2017-09-27 08:23:18 +0200 | [diff] [blame] | 143 | struct mlxsw_sp_mr; |
Jiri Pirko | 22a6776 | 2017-02-03 10:29:07 +0100 | [diff] [blame] | 144 | struct mlxsw_sp_acl; |
Arkadi Sharshevsky | ff7b0d2 | 2017-03-11 09:42:51 +0100 | [diff] [blame] | 145 | struct mlxsw_sp_counter_pool; |
Ido Schimmel | a110748 | 2017-05-26 08:37:39 +0200 | [diff] [blame] | 146 | struct mlxsw_sp_fid_core; |
Ido Schimmel | a875a2e | 2017-10-22 23:11:44 +0200 | [diff] [blame] | 147 | struct mlxsw_sp_kvdl; |
Jiri Pirko | 22a6776 | 2017-02-03 10:29:07 +0100 | [diff] [blame] | 148 | |
Jiri Pirko | 56ade8f | 2015-10-16 14:01:37 +0200 | [diff] [blame] | 149 | struct mlxsw_sp { |
Jiri Pirko | 56ade8f | 2015-10-16 14:01:37 +0200 | [diff] [blame] | 150 | struct mlxsw_sp_port **ports; |
| 151 | struct mlxsw_core *core; |
| 152 | const struct mlxsw_bus_info *bus_info; |
| 153 | unsigned char base_mac[ETH_ALEN]; |
Nogah Frankel | ce0bd2b | 2016-09-20 11:16:50 +0200 | [diff] [blame] | 154 | struct mlxsw_sp_upper *lags; |
Ido Schimmel | 5ec2ee7 | 2017-03-24 08:02:48 +0100 | [diff] [blame] | 155 | u8 *port_to_module; |
Ido Schimmel | 33cbd87 | 2017-05-16 19:38:24 +0200 | [diff] [blame] | 156 | struct mlxsw_sp_sb *sb; |
Ido Schimmel | 5f6935c | 2017-05-16 19:38:26 +0200 | [diff] [blame] | 157 | struct mlxsw_sp_bridge *bridge; |
Ido Schimmel | 9011b67 | 2017-05-16 19:38:25 +0200 | [diff] [blame] | 158 | struct mlxsw_sp_router *router; |
Yotam Gigi | c011ec1 | 2017-09-27 08:23:17 +0200 | [diff] [blame] | 159 | struct mlxsw_sp_mr *mr; |
Yotam Gigi | d3b939b | 2017-09-19 10:00:09 +0200 | [diff] [blame] | 160 | struct mlxsw_afa *afa; |
Jiri Pirko | 22a6776 | 2017-02-03 10:29:07 +0100 | [diff] [blame] | 161 | struct mlxsw_sp_acl *acl; |
Ido Schimmel | a110748 | 2017-05-26 08:37:39 +0200 | [diff] [blame] | 162 | struct mlxsw_sp_fid_core *fid_core; |
Ido Schimmel | a875a2e | 2017-10-22 23:11:44 +0200 | [diff] [blame] | 163 | struct mlxsw_sp_kvdl *kvdl; |
Petr Machata | c30f5d0 | 2017-10-16 16:26:35 +0200 | [diff] [blame] | 164 | struct notifier_block netdevice_nb; |
Yotam Gigi | 763b4b7 | 2016-07-21 12:03:17 +0200 | [diff] [blame] | 165 | |
Arkadi Sharshevsky | ff7b0d2 | 2017-03-11 09:42:51 +0100 | [diff] [blame] | 166 | struct mlxsw_sp_counter_pool *counter_pool; |
Yotam Gigi | 763b4b7 | 2016-07-21 12:03:17 +0200 | [diff] [blame] | 167 | struct { |
| 168 | struct mlxsw_sp_span_entry *entries; |
| 169 | int entries_count; |
| 170 | } span; |
Jiri Pirko | 56ade8f | 2015-10-16 14:01:37 +0200 | [diff] [blame] | 171 | }; |
| 172 | |
Jiri Pirko | 0d65fc1 | 2015-12-03 12:12:28 +0100 | [diff] [blame] | 173 | static inline struct mlxsw_sp_upper * |
| 174 | mlxsw_sp_lag_get(struct mlxsw_sp *mlxsw_sp, u16 lag_id) |
| 175 | { |
| 176 | return &mlxsw_sp->lags[lag_id]; |
| 177 | } |
| 178 | |
Jiri Pirko | 56ade8f | 2015-10-16 14:01:37 +0200 | [diff] [blame] | 179 | struct mlxsw_sp_port_pcpu_stats { |
| 180 | u64 rx_packets; |
| 181 | u64 rx_bytes; |
| 182 | u64 tx_packets; |
| 183 | u64 tx_bytes; |
| 184 | struct u64_stats_sync syncp; |
| 185 | u32 tx_dropped; |
| 186 | }; |
| 187 | |
Yotam Gigi | 98d0f7b | 2017-01-23 11:07:11 +0100 | [diff] [blame] | 188 | struct mlxsw_sp_port_sample { |
| 189 | struct psample_group __rcu *psample_group; |
| 190 | u32 trunc_size; |
| 191 | u32 rate; |
| 192 | bool truncate; |
| 193 | }; |
| 194 | |
Ido Schimmel | c57529e | 2017-05-26 08:37:31 +0200 | [diff] [blame] | 195 | struct mlxsw_sp_bridge_port; |
Ido Schimmel | a110748 | 2017-05-26 08:37:39 +0200 | [diff] [blame] | 196 | struct mlxsw_sp_fid; |
Ido Schimmel | c57529e | 2017-05-26 08:37:31 +0200 | [diff] [blame] | 197 | |
Ido Schimmel | 31a08a5 | 2017-05-26 08:37:26 +0200 | [diff] [blame] | 198 | struct mlxsw_sp_port_vlan { |
| 199 | struct list_head list; |
| 200 | struct mlxsw_sp_port *mlxsw_sp_port; |
| 201 | struct mlxsw_sp_fid *fid; |
| 202 | u16 vid; |
Ido Schimmel | c57529e | 2017-05-26 08:37:31 +0200 | [diff] [blame] | 203 | struct mlxsw_sp_bridge_port *bridge_port; |
| 204 | struct list_head bridge_vlan_node; |
Ido Schimmel | 31a08a5 | 2017-05-26 08:37:26 +0200 | [diff] [blame] | 205 | }; |
| 206 | |
Nogah Frankel | 96f17e0 | 2017-11-06 07:23:45 +0100 | [diff] [blame] | 207 | enum mlxsw_sp_qdisc_type { |
| 208 | MLXSW_SP_QDISC_NO_QDISC, |
| 209 | MLXSW_SP_QDISC_RED, |
| 210 | }; |
| 211 | |
| 212 | struct mlxsw_sp_qdisc { |
| 213 | u32 handle; |
| 214 | enum mlxsw_sp_qdisc_type type; |
Nogah Frankel | 861fb82 | 2017-11-06 07:23:48 +0100 | [diff] [blame] | 215 | struct red_stats xstats_base; |
| 216 | union { |
| 217 | struct { |
| 218 | u64 tail_drop_base; |
| 219 | u64 ecn_base; |
| 220 | u64 wred_drop_base; |
| 221 | } red; |
| 222 | } xstats; |
Nogah Frankel | 3670756 | 2017-11-06 07:23:49 +0100 | [diff] [blame] | 223 | |
| 224 | u64 tx_bytes; |
| 225 | u64 tx_packets; |
| 226 | u64 drops; |
| 227 | u64 overlimits; |
Nogah Frankel | 96f17e0 | 2017-11-06 07:23:45 +0100 | [diff] [blame] | 228 | }; |
| 229 | |
Nogah Frankel | 075ab8a | 2017-11-06 07:23:47 +0100 | [diff] [blame] | 230 | /* No need an internal lock; At worse - miss a single periodic iteration */ |
| 231 | struct mlxsw_sp_port_xstats { |
| 232 | u64 ecn; |
| 233 | u64 wred_drop[TC_MAX_QUEUE]; |
| 234 | u64 tail_drop[TC_MAX_QUEUE]; |
| 235 | u64 backlog[TC_MAX_QUEUE]; |
| 236 | }; |
| 237 | |
Jiri Pirko | 56ade8f | 2015-10-16 14:01:37 +0200 | [diff] [blame] | 238 | struct mlxsw_sp_port { |
| 239 | struct net_device *dev; |
| 240 | struct mlxsw_sp_port_pcpu_stats __percpu *pcpu_stats; |
| 241 | struct mlxsw_sp *mlxsw_sp; |
| 242 | u8 local_port; |
Ido Schimmel | c57529e | 2017-05-26 08:37:31 +0200 | [diff] [blame] | 243 | u8 lagged:1, |
Ido Schimmel | 18f1e70 | 2016-02-26 17:32:31 +0100 | [diff] [blame] | 244 | split:1; |
Jiri Pirko | 56ade8f | 2015-10-16 14:01:37 +0200 | [diff] [blame] | 245 | u16 pvid; |
Jiri Pirko | 0d65fc1 | 2015-12-03 12:12:28 +0100 | [diff] [blame] | 246 | u16 lag_id; |
Ido Schimmel | 7f71eb4 | 2015-12-15 16:03:37 +0100 | [diff] [blame] | 247 | struct { |
Ido Schimmel | 9f7ec05 | 2016-04-06 17:10:14 +0200 | [diff] [blame] | 248 | u8 tx_pause:1, |
Ido Schimmel | 0c83f88 | 2016-09-12 13:26:23 +0200 | [diff] [blame] | 249 | rx_pause:1, |
| 250 | autoneg:1; |
Ido Schimmel | 9f7ec05 | 2016-04-06 17:10:14 +0200 | [diff] [blame] | 251 | } link; |
| 252 | struct { |
Ido Schimmel | 8e8dfe9 | 2016-04-06 17:10:10 +0200 | [diff] [blame] | 253 | struct ieee_ets *ets; |
Ido Schimmel | cc7cf51 | 2016-04-06 17:10:11 +0200 | [diff] [blame] | 254 | struct ieee_maxrate *maxrate; |
Ido Schimmel | d81a6bd | 2016-04-06 17:10:16 +0200 | [diff] [blame] | 255 | struct ieee_pfc *pfc; |
Ido Schimmel | 8e8dfe9 | 2016-04-06 17:10:10 +0200 | [diff] [blame] | 256 | } dcb; |
Ido Schimmel | d664b41 | 2016-06-09 09:51:40 +0200 | [diff] [blame] | 257 | struct { |
| 258 | u8 module; |
| 259 | u8 width; |
| 260 | u8 lane; |
| 261 | } mapping; |
Yotam Gigi | 763b4b7 | 2016-07-21 12:03:17 +0200 | [diff] [blame] | 262 | /* TC handles */ |
| 263 | struct list_head mall_tc_list; |
Nogah Frankel | fc1bbb0 | 2016-09-16 15:05:38 +0200 | [diff] [blame] | 264 | struct { |
| 265 | #define MLXSW_HW_STATS_UPDATE_TIME HZ |
Nogah Frankel | 9deef43 | 2017-10-26 10:55:32 +0200 | [diff] [blame] | 266 | struct rtnl_link_stats64 stats; |
Nogah Frankel | 075ab8a | 2017-11-06 07:23:47 +0100 | [diff] [blame] | 267 | struct mlxsw_sp_port_xstats xstats; |
Nogah Frankel | fc1bbb0 | 2016-09-16 15:05:38 +0200 | [diff] [blame] | 268 | struct delayed_work update_dw; |
Nogah Frankel | 9deef43 | 2017-10-26 10:55:32 +0200 | [diff] [blame] | 269 | } periodic_hw_stats; |
Yotam Gigi | 98d0f7b | 2017-01-23 11:07:11 +0100 | [diff] [blame] | 270 | struct mlxsw_sp_port_sample *sample; |
Ido Schimmel | 31a08a5 | 2017-05-26 08:37:26 +0200 | [diff] [blame] | 271 | struct list_head vlans_list; |
Nogah Frankel | 96f17e0 | 2017-11-06 07:23:45 +0100 | [diff] [blame] | 272 | struct mlxsw_sp_qdisc root_qdisc; |
Jiri Pirko | 56ade8f | 2015-10-16 14:01:37 +0200 | [diff] [blame] | 273 | }; |
| 274 | |
Ido Schimmel | 9f7ec05 | 2016-04-06 17:10:14 +0200 | [diff] [blame] | 275 | static inline bool |
| 276 | mlxsw_sp_port_is_pause_en(const struct mlxsw_sp_port *mlxsw_sp_port) |
| 277 | { |
| 278 | return mlxsw_sp_port->link.tx_pause || mlxsw_sp_port->link.rx_pause; |
| 279 | } |
| 280 | |
Jiri Pirko | 0d65fc1 | 2015-12-03 12:12:28 +0100 | [diff] [blame] | 281 | static inline struct mlxsw_sp_port * |
| 282 | mlxsw_sp_port_lagged_get(struct mlxsw_sp *mlxsw_sp, u16 lag_id, u8 port_index) |
| 283 | { |
| 284 | struct mlxsw_sp_port *mlxsw_sp_port; |
| 285 | u8 local_port; |
| 286 | |
| 287 | local_port = mlxsw_core_lag_mapping_get(mlxsw_sp->core, |
| 288 | lag_id, port_index); |
| 289 | mlxsw_sp_port = mlxsw_sp->ports[local_port]; |
| 290 | return mlxsw_sp_port && mlxsw_sp_port->lagged ? mlxsw_sp_port : NULL; |
| 291 | } |
| 292 | |
Ido Schimmel | 31a08a5 | 2017-05-26 08:37:26 +0200 | [diff] [blame] | 293 | static inline struct mlxsw_sp_port_vlan * |
| 294 | mlxsw_sp_port_vlan_find_by_vid(const struct mlxsw_sp_port *mlxsw_sp_port, |
| 295 | u16 vid) |
| 296 | { |
| 297 | struct mlxsw_sp_port_vlan *mlxsw_sp_port_vlan; |
| 298 | |
| 299 | list_for_each_entry(mlxsw_sp_port_vlan, &mlxsw_sp_port->vlans_list, |
| 300 | list) { |
| 301 | if (mlxsw_sp_port_vlan->vid == vid) |
| 302 | return mlxsw_sp_port_vlan; |
| 303 | } |
| 304 | |
| 305 | return NULL; |
| 306 | } |
| 307 | |
Ido Schimmel | a110748 | 2017-05-26 08:37:39 +0200 | [diff] [blame] | 308 | enum mlxsw_sp_flood_type { |
| 309 | MLXSW_SP_FLOOD_TYPE_UC, |
| 310 | MLXSW_SP_FLOOD_TYPE_BC, |
| 311 | MLXSW_SP_FLOOD_TYPE_MC, |
Jiri Pirko | 56ade8f | 2015-10-16 14:01:37 +0200 | [diff] [blame] | 312 | }; |
| 313 | |
Ido Schimmel | cb4cc0e | 2017-06-04 16:53:38 +0200 | [diff] [blame] | 314 | /* spectrum_buffers.c */ |
Jiri Pirko | 56ade8f | 2015-10-16 14:01:37 +0200 | [diff] [blame] | 315 | int mlxsw_sp_buffers_init(struct mlxsw_sp *mlxsw_sp); |
Jiri Pirko | 0f433fa | 2016-04-14 18:19:24 +0200 | [diff] [blame] | 316 | void mlxsw_sp_buffers_fini(struct mlxsw_sp *mlxsw_sp); |
Jiri Pirko | 56ade8f | 2015-10-16 14:01:37 +0200 | [diff] [blame] | 317 | int mlxsw_sp_port_buffers_init(struct mlxsw_sp_port *mlxsw_sp_port); |
Jiri Pirko | 0f433fa | 2016-04-14 18:19:24 +0200 | [diff] [blame] | 318 | int mlxsw_sp_sb_pool_get(struct mlxsw_core *mlxsw_core, |
| 319 | unsigned int sb_index, u16 pool_index, |
| 320 | struct devlink_sb_pool_info *pool_info); |
| 321 | int mlxsw_sp_sb_pool_set(struct mlxsw_core *mlxsw_core, |
| 322 | unsigned int sb_index, u16 pool_index, u32 size, |
| 323 | enum devlink_sb_threshold_type threshold_type); |
| 324 | int mlxsw_sp_sb_port_pool_get(struct mlxsw_core_port *mlxsw_core_port, |
| 325 | unsigned int sb_index, u16 pool_index, |
| 326 | u32 *p_threshold); |
| 327 | int mlxsw_sp_sb_port_pool_set(struct mlxsw_core_port *mlxsw_core_port, |
| 328 | unsigned int sb_index, u16 pool_index, |
| 329 | u32 threshold); |
| 330 | int mlxsw_sp_sb_tc_pool_bind_get(struct mlxsw_core_port *mlxsw_core_port, |
| 331 | unsigned int sb_index, u16 tc_index, |
| 332 | enum devlink_sb_pool_type pool_type, |
| 333 | u16 *p_pool_index, u32 *p_threshold); |
| 334 | int mlxsw_sp_sb_tc_pool_bind_set(struct mlxsw_core_port *mlxsw_core_port, |
| 335 | unsigned int sb_index, u16 tc_index, |
| 336 | enum devlink_sb_pool_type pool_type, |
| 337 | u16 pool_index, u32 threshold); |
Jiri Pirko | 2d0ed39 | 2016-04-14 18:19:30 +0200 | [diff] [blame] | 338 | int mlxsw_sp_sb_occ_snapshot(struct mlxsw_core *mlxsw_core, |
| 339 | unsigned int sb_index); |
| 340 | int mlxsw_sp_sb_occ_max_clear(struct mlxsw_core *mlxsw_core, |
| 341 | unsigned int sb_index); |
| 342 | int mlxsw_sp_sb_occ_port_pool_get(struct mlxsw_core_port *mlxsw_core_port, |
| 343 | unsigned int sb_index, u16 pool_index, |
| 344 | u32 *p_cur, u32 *p_max); |
| 345 | int mlxsw_sp_sb_occ_tc_port_bind_get(struct mlxsw_core_port *mlxsw_core_port, |
| 346 | unsigned int sb_index, u16 tc_index, |
| 347 | enum devlink_sb_pool_type pool_type, |
| 348 | u32 *p_cur, u32 *p_max); |
Ido Schimmel | 33cbd87 | 2017-05-16 19:38:24 +0200 | [diff] [blame] | 349 | u32 mlxsw_sp_cells_bytes(const struct mlxsw_sp *mlxsw_sp, u32 cells); |
| 350 | u32 mlxsw_sp_bytes_cells(const struct mlxsw_sp *mlxsw_sp, u32 bytes); |
Jiri Pirko | 56ade8f | 2015-10-16 14:01:37 +0200 | [diff] [blame] | 351 | |
Ido Schimmel | cb4cc0e | 2017-06-04 16:53:38 +0200 | [diff] [blame] | 352 | /* spectrum_switchdev.c */ |
Jiri Pirko | 56ade8f | 2015-10-16 14:01:37 +0200 | [diff] [blame] | 353 | int mlxsw_sp_switchdev_init(struct mlxsw_sp *mlxsw_sp); |
| 354 | void mlxsw_sp_switchdev_fini(struct mlxsw_sp *mlxsw_sp); |
Jiri Pirko | 56ade8f | 2015-10-16 14:01:37 +0200 | [diff] [blame] | 355 | void mlxsw_sp_port_switchdev_init(struct mlxsw_sp_port *mlxsw_sp_port); |
| 356 | void mlxsw_sp_port_switchdev_fini(struct mlxsw_sp_port *mlxsw_sp_port); |
Ido Schimmel | 6e095fd | 2016-07-04 08:23:13 +0200 | [diff] [blame] | 357 | int mlxsw_sp_rif_fdb_op(struct mlxsw_sp *mlxsw_sp, const char *mac, u16 fid, |
| 358 | bool adding); |
Ido Schimmel | c57529e | 2017-05-26 08:37:31 +0200 | [diff] [blame] | 359 | void |
| 360 | mlxsw_sp_port_vlan_bridge_leave(struct mlxsw_sp_port_vlan *mlxsw_sp_port_vlan); |
| 361 | int mlxsw_sp_port_bridge_join(struct mlxsw_sp_port *mlxsw_sp_port, |
| 362 | struct net_device *brport_dev, |
Ido Schimmel | 9b63ef88 | 2017-10-08 11:57:56 +0200 | [diff] [blame] | 363 | struct net_device *br_dev, |
| 364 | struct netlink_ext_ack *extack); |
Ido Schimmel | c57529e | 2017-05-26 08:37:31 +0200 | [diff] [blame] | 365 | void mlxsw_sp_port_bridge_leave(struct mlxsw_sp_port *mlxsw_sp_port, |
| 366 | struct net_device *brport_dev, |
| 367 | struct net_device *br_dev); |
| 368 | |
Ido Schimmel | cb4cc0e | 2017-06-04 16:53:38 +0200 | [diff] [blame] | 369 | /* spectrum.c */ |
Ido Schimmel | 8e8dfe9 | 2016-04-06 17:10:10 +0200 | [diff] [blame] | 370 | int mlxsw_sp_port_ets_set(struct mlxsw_sp_port *mlxsw_sp_port, |
| 371 | enum mlxsw_reg_qeec_hr hr, u8 index, u8 next_index, |
| 372 | bool dwrr, u8 dwrr_weight); |
| 373 | int mlxsw_sp_port_prio_tc_set(struct mlxsw_sp_port *mlxsw_sp_port, |
| 374 | u8 switch_prio, u8 tclass); |
| 375 | int __mlxsw_sp_port_headroom_set(struct mlxsw_sp_port *mlxsw_sp_port, int mtu, |
Ido Schimmel | d81a6bd | 2016-04-06 17:10:16 +0200 | [diff] [blame] | 376 | u8 *prio_tc, bool pause_en, |
| 377 | struct ieee_pfc *my_pfc); |
Ido Schimmel | cc7cf51 | 2016-04-06 17:10:11 +0200 | [diff] [blame] | 378 | int mlxsw_sp_port_ets_maxrate_set(struct mlxsw_sp_port *mlxsw_sp_port, |
| 379 | enum mlxsw_reg_qeec_hr hr, u8 index, |
| 380 | u8 next_index, u32 maxrate); |
Ido Schimmel | fe9ccc7 | 2017-05-16 19:38:31 +0200 | [diff] [blame] | 381 | int mlxsw_sp_port_vid_stp_set(struct mlxsw_sp_port *mlxsw_sp_port, u16 vid, |
| 382 | u8 state); |
Ido Schimmel | a110748 | 2017-05-26 08:37:39 +0200 | [diff] [blame] | 383 | int mlxsw_sp_port_vp_mode_set(struct mlxsw_sp_port *mlxsw_sp_port, bool enable); |
Ido Schimmel | fe9ccc7 | 2017-05-16 19:38:31 +0200 | [diff] [blame] | 384 | int mlxsw_sp_port_vid_learning_set(struct mlxsw_sp_port *mlxsw_sp_port, u16 vid, |
| 385 | bool learn_enable); |
Ido Schimmel | b02eae9 | 2017-05-16 19:38:34 +0200 | [diff] [blame] | 386 | int mlxsw_sp_port_pvid_set(struct mlxsw_sp_port *mlxsw_sp_port, u16 vid); |
Ido Schimmel | c57529e | 2017-05-26 08:37:31 +0200 | [diff] [blame] | 387 | struct mlxsw_sp_port_vlan * |
| 388 | mlxsw_sp_port_vlan_get(struct mlxsw_sp_port *mlxsw_sp_port, u16 vid); |
| 389 | void mlxsw_sp_port_vlan_put(struct mlxsw_sp_port_vlan *mlxsw_sp_port_vlan); |
Ido Schimmel | cb4cc0e | 2017-06-04 16:53:38 +0200 | [diff] [blame] | 390 | int mlxsw_sp_port_vlan_set(struct mlxsw_sp_port *mlxsw_sp_port, u16 vid_begin, |
| 391 | u16 vid_end, bool is_member, bool untagged); |
| 392 | int mlxsw_sp_flow_counter_get(struct mlxsw_sp *mlxsw_sp, |
| 393 | unsigned int counter_index, u64 *packets, |
| 394 | u64 *bytes); |
| 395 | int mlxsw_sp_flow_counter_alloc(struct mlxsw_sp *mlxsw_sp, |
| 396 | unsigned int *p_counter_index); |
| 397 | void mlxsw_sp_flow_counter_free(struct mlxsw_sp *mlxsw_sp, |
| 398 | unsigned int counter_index); |
| 399 | bool mlxsw_sp_port_dev_check(const struct net_device *dev); |
| 400 | struct mlxsw_sp *mlxsw_sp_lower_get(struct net_device *dev); |
| 401 | struct mlxsw_sp_port *mlxsw_sp_port_dev_lower_find(struct net_device *dev); |
| 402 | struct mlxsw_sp_port *mlxsw_sp_port_lower_dev_hold(struct net_device *dev); |
| 403 | void mlxsw_sp_port_dev_put(struct mlxsw_sp_port *mlxsw_sp_port); |
Arkadi Sharshevsky | af061378 | 2017-06-08 08:44:20 +0200 | [diff] [blame] | 404 | struct mlxsw_sp_port *mlxsw_sp_port_dev_lower_find_rcu(struct net_device *dev); |
Jiri Pirko | 56ade8f | 2015-10-16 14:01:37 +0200 | [diff] [blame] | 405 | |
Ido Schimmel | cb4cc0e | 2017-06-04 16:53:38 +0200 | [diff] [blame] | 406 | /* spectrum_dcb.c */ |
Ido Schimmel | f00817d | 2016-04-06 17:10:09 +0200 | [diff] [blame] | 407 | #ifdef CONFIG_MLXSW_SPECTRUM_DCB |
Ido Schimmel | f00817d | 2016-04-06 17:10:09 +0200 | [diff] [blame] | 408 | int mlxsw_sp_port_dcb_init(struct mlxsw_sp_port *mlxsw_sp_port); |
| 409 | void mlxsw_sp_port_dcb_fini(struct mlxsw_sp_port *mlxsw_sp_port); |
Ido Schimmel | f00817d | 2016-04-06 17:10:09 +0200 | [diff] [blame] | 410 | #else |
Ido Schimmel | f00817d | 2016-04-06 17:10:09 +0200 | [diff] [blame] | 411 | static inline int mlxsw_sp_port_dcb_init(struct mlxsw_sp_port *mlxsw_sp_port) |
| 412 | { |
| 413 | return 0; |
| 414 | } |
Ido Schimmel | f00817d | 2016-04-06 17:10:09 +0200 | [diff] [blame] | 415 | static inline void mlxsw_sp_port_dcb_fini(struct mlxsw_sp_port *mlxsw_sp_port) |
| 416 | {} |
Ido Schimmel | f00817d | 2016-04-06 17:10:09 +0200 | [diff] [blame] | 417 | #endif |
| 418 | |
Ido Schimmel | cb4cc0e | 2017-06-04 16:53:38 +0200 | [diff] [blame] | 419 | /* spectrum_router.c */ |
Ido Schimmel | 464dce1 | 2016-07-02 11:00:15 +0200 | [diff] [blame] | 420 | int mlxsw_sp_router_init(struct mlxsw_sp *mlxsw_sp); |
| 421 | void mlxsw_sp_router_fini(struct mlxsw_sp *mlxsw_sp); |
Ido Schimmel | 4724ba56 | 2017-03-10 08:53:39 +0100 | [diff] [blame] | 422 | int mlxsw_sp_netdevice_router_port_event(struct net_device *dev); |
| 423 | int mlxsw_sp_inetaddr_event(struct notifier_block *unused, |
| 424 | unsigned long event, void *ptr); |
David Ahern | 89d5dd2 | 2017-10-18 09:56:55 -0700 | [diff] [blame] | 425 | int mlxsw_sp_inetaddr_valid_event(struct notifier_block *unused, |
| 426 | unsigned long event, void *ptr); |
Arkadi Sharshevsky | 5ea1237 | 2017-07-18 10:10:13 +0200 | [diff] [blame] | 427 | int mlxsw_sp_inet6addr_event(struct notifier_block *unused, |
| 428 | unsigned long event, void *ptr); |
David Ahern | 89d5dd2 | 2017-10-18 09:56:55 -0700 | [diff] [blame] | 429 | int mlxsw_sp_inet6addr_valid_event(struct notifier_block *unused, |
| 430 | unsigned long event, void *ptr); |
Ido Schimmel | b1e4552 | 2017-04-30 19:47:14 +0300 | [diff] [blame] | 431 | int mlxsw_sp_netdevice_vrf_event(struct net_device *l3_dev, unsigned long event, |
| 432 | struct netdev_notifier_changeupper_info *info); |
Petr Machata | 796ec77 | 2017-11-03 10:03:29 +0100 | [diff] [blame] | 433 | bool mlxsw_sp_netdev_is_ipip_ol(const struct mlxsw_sp *mlxsw_sp, |
| 434 | const struct net_device *dev); |
Petr Machata | 61481f2 | 2017-11-03 10:03:41 +0100 | [diff] [blame] | 435 | bool mlxsw_sp_netdev_is_ipip_ul(const struct mlxsw_sp *mlxsw_sp, |
| 436 | const struct net_device *dev); |
Petr Machata | 7e75af6 | 2017-11-03 10:03:36 +0100 | [diff] [blame] | 437 | int mlxsw_sp_netdevice_ipip_ol_event(struct mlxsw_sp *mlxsw_sp, |
| 438 | struct net_device *l3_dev, |
| 439 | unsigned long event, |
| 440 | struct netdev_notifier_info *info); |
Petr Machata | 61481f2 | 2017-11-03 10:03:41 +0100 | [diff] [blame] | 441 | int |
| 442 | mlxsw_sp_netdevice_ipip_ul_event(struct mlxsw_sp *mlxsw_sp, |
| 443 | struct net_device *l3_dev, |
| 444 | unsigned long event, |
| 445 | struct netdev_notifier_info *info); |
Ido Schimmel | a110748 | 2017-05-26 08:37:39 +0200 | [diff] [blame] | 446 | void |
| 447 | mlxsw_sp_port_vlan_router_leave(struct mlxsw_sp_port_vlan *mlxsw_sp_port_vlan); |
Ido Schimmel | e4f3c1c | 2017-05-26 08:37:40 +0200 | [diff] [blame] | 448 | void mlxsw_sp_rif_destroy(struct mlxsw_sp_rif *rif); |
Ido Schimmel | 464dce1 | 2016-07-02 11:00:15 +0200 | [diff] [blame] | 449 | |
Ido Schimmel | cb4cc0e | 2017-06-04 16:53:38 +0200 | [diff] [blame] | 450 | /* spectrum_kvdl.c */ |
Ido Schimmel | a875a2e | 2017-10-22 23:11:44 +0200 | [diff] [blame] | 451 | int mlxsw_sp_kvdl_init(struct mlxsw_sp *mlxsw_sp); |
| 452 | void mlxsw_sp_kvdl_fini(struct mlxsw_sp *mlxsw_sp); |
Arkadi Sharshevsky | 1312444 | 2017-03-25 08:28:22 +0100 | [diff] [blame] | 453 | int mlxsw_sp_kvdl_alloc(struct mlxsw_sp *mlxsw_sp, unsigned int entry_count, |
| 454 | u32 *p_entry_index); |
Jiri Pirko | b090ef0 | 2016-07-05 11:27:47 +0200 | [diff] [blame] | 455 | void mlxsw_sp_kvdl_free(struct mlxsw_sp *mlxsw_sp, int entry_index); |
Ido Schimmel | d672aec4 | 2017-10-22 23:11:45 +0200 | [diff] [blame] | 456 | int mlxsw_sp_kvdl_alloc_size_query(struct mlxsw_sp *mlxsw_sp, |
| 457 | unsigned int entry_count, |
| 458 | unsigned int *p_alloc_size); |
Jiri Pirko | b090ef0 | 2016-07-05 11:27:47 +0200 | [diff] [blame] | 459 | |
Jiri Pirko | 22a6776 | 2017-02-03 10:29:07 +0100 | [diff] [blame] | 460 | struct mlxsw_sp_acl_rule_info { |
| 461 | unsigned int priority; |
| 462 | struct mlxsw_afk_element_values values; |
| 463 | struct mlxsw_afa_block *act_block; |
Arkadi Sharshevsky | 4817072 | 2017-03-11 09:42:58 +0100 | [diff] [blame] | 464 | unsigned int counter_index; |
| 465 | bool counter_valid; |
Jiri Pirko | 22a6776 | 2017-02-03 10:29:07 +0100 | [diff] [blame] | 466 | }; |
| 467 | |
| 468 | enum mlxsw_sp_acl_profile { |
| 469 | MLXSW_SP_ACL_PROFILE_FLOWER, |
| 470 | }; |
| 471 | |
| 472 | struct mlxsw_sp_acl_profile_ops { |
| 473 | size_t ruleset_priv_size; |
| 474 | int (*ruleset_add)(struct mlxsw_sp *mlxsw_sp, |
| 475 | void *priv, void *ruleset_priv); |
| 476 | void (*ruleset_del)(struct mlxsw_sp *mlxsw_sp, void *ruleset_priv); |
| 477 | int (*ruleset_bind)(struct mlxsw_sp *mlxsw_sp, void *ruleset_priv, |
| 478 | struct net_device *dev, bool ingress); |
| 479 | void (*ruleset_unbind)(struct mlxsw_sp *mlxsw_sp, void *ruleset_priv); |
Jiri Pirko | 0ade3b6 | 2017-08-23 10:08:20 +0200 | [diff] [blame] | 480 | u16 (*ruleset_group_id)(void *ruleset_priv); |
Jiri Pirko | 22a6776 | 2017-02-03 10:29:07 +0100 | [diff] [blame] | 481 | size_t rule_priv_size; |
| 482 | int (*rule_add)(struct mlxsw_sp *mlxsw_sp, |
| 483 | void *ruleset_priv, void *rule_priv, |
| 484 | struct mlxsw_sp_acl_rule_info *rulei); |
| 485 | void (*rule_del)(struct mlxsw_sp *mlxsw_sp, void *rule_priv); |
Arkadi Sharshevsky | 7fd056c | 2017-03-11 09:42:54 +0100 | [diff] [blame] | 486 | int (*rule_activity_get)(struct mlxsw_sp *mlxsw_sp, void *rule_priv, |
| 487 | bool *activity); |
Jiri Pirko | 22a6776 | 2017-02-03 10:29:07 +0100 | [diff] [blame] | 488 | }; |
| 489 | |
| 490 | struct mlxsw_sp_acl_ops { |
| 491 | size_t priv_size; |
| 492 | int (*init)(struct mlxsw_sp *mlxsw_sp, void *priv); |
| 493 | void (*fini)(struct mlxsw_sp *mlxsw_sp, void *priv); |
| 494 | const struct mlxsw_sp_acl_profile_ops * |
| 495 | (*profile_ops)(struct mlxsw_sp *mlxsw_sp, |
| 496 | enum mlxsw_sp_acl_profile profile); |
| 497 | }; |
| 498 | |
| 499 | struct mlxsw_sp_acl_ruleset; |
| 500 | |
Ido Schimmel | cb4cc0e | 2017-06-04 16:53:38 +0200 | [diff] [blame] | 501 | /* spectrum_acl.c */ |
| 502 | struct mlxsw_afk *mlxsw_sp_acl_afk(struct mlxsw_sp_acl *acl); |
Jiri Pirko | 22a6776 | 2017-02-03 10:29:07 +0100 | [diff] [blame] | 503 | struct mlxsw_sp_acl_ruleset * |
Jiri Pirko | dbec8ee | 2017-08-23 10:08:21 +0200 | [diff] [blame] | 504 | mlxsw_sp_acl_ruleset_lookup(struct mlxsw_sp *mlxsw_sp, struct net_device *dev, |
| 505 | bool ingress, u32 chain_index, |
| 506 | enum mlxsw_sp_acl_profile profile); |
| 507 | struct mlxsw_sp_acl_ruleset * |
Jiri Pirko | 45b6274 | 2017-08-23 10:08:18 +0200 | [diff] [blame] | 508 | mlxsw_sp_acl_ruleset_get(struct mlxsw_sp *mlxsw_sp, struct net_device *dev, |
| 509 | bool ingress, u32 chain_index, |
Jiri Pirko | 22a6776 | 2017-02-03 10:29:07 +0100 | [diff] [blame] | 510 | enum mlxsw_sp_acl_profile profile); |
| 511 | void mlxsw_sp_acl_ruleset_put(struct mlxsw_sp *mlxsw_sp, |
| 512 | struct mlxsw_sp_acl_ruleset *ruleset); |
Jiri Pirko | 0ade3b6 | 2017-08-23 10:08:20 +0200 | [diff] [blame] | 513 | u16 mlxsw_sp_acl_ruleset_group_id(struct mlxsw_sp_acl_ruleset *ruleset); |
Jiri Pirko | 22a6776 | 2017-02-03 10:29:07 +0100 | [diff] [blame] | 514 | |
| 515 | struct mlxsw_sp_acl_rule_info * |
| 516 | mlxsw_sp_acl_rulei_create(struct mlxsw_sp_acl *acl); |
| 517 | void mlxsw_sp_acl_rulei_destroy(struct mlxsw_sp_acl_rule_info *rulei); |
| 518 | int mlxsw_sp_acl_rulei_commit(struct mlxsw_sp_acl_rule_info *rulei); |
| 519 | void mlxsw_sp_acl_rulei_priority(struct mlxsw_sp_acl_rule_info *rulei, |
| 520 | unsigned int priority); |
| 521 | void mlxsw_sp_acl_rulei_keymask_u32(struct mlxsw_sp_acl_rule_info *rulei, |
| 522 | enum mlxsw_afk_element element, |
| 523 | u32 key_value, u32 mask_value); |
| 524 | void mlxsw_sp_acl_rulei_keymask_buf(struct mlxsw_sp_acl_rule_info *rulei, |
| 525 | enum mlxsw_afk_element element, |
| 526 | const char *key_value, |
| 527 | const char *mask_value, unsigned int len); |
Jiri Pirko | 2a52a8c | 2017-09-25 10:58:20 +0200 | [diff] [blame] | 528 | int mlxsw_sp_acl_rulei_act_continue(struct mlxsw_sp_acl_rule_info *rulei); |
| 529 | int mlxsw_sp_acl_rulei_act_jump(struct mlxsw_sp_acl_rule_info *rulei, |
| 530 | u16 group_id); |
Jiri Pirko | 22a6776 | 2017-02-03 10:29:07 +0100 | [diff] [blame] | 531 | int mlxsw_sp_acl_rulei_act_drop(struct mlxsw_sp_acl_rule_info *rulei); |
Jiri Pirko | df7eea9 | 2017-06-06 14:12:06 +0200 | [diff] [blame] | 532 | int mlxsw_sp_acl_rulei_act_trap(struct mlxsw_sp_acl_rule_info *rulei); |
Jiri Pirko | 22a6776 | 2017-02-03 10:29:07 +0100 | [diff] [blame] | 533 | int mlxsw_sp_acl_rulei_act_fwd(struct mlxsw_sp *mlxsw_sp, |
| 534 | struct mlxsw_sp_acl_rule_info *rulei, |
| 535 | struct net_device *out_dev); |
Petr Machata | a150201 | 2017-03-09 09:25:19 +0100 | [diff] [blame] | 536 | int mlxsw_sp_acl_rulei_act_vlan(struct mlxsw_sp *mlxsw_sp, |
| 537 | struct mlxsw_sp_acl_rule_info *rulei, |
| 538 | u32 action, u16 vid, u16 proto, u8 prio); |
Arkadi Sharshevsky | 4817072 | 2017-03-11 09:42:58 +0100 | [diff] [blame] | 539 | int mlxsw_sp_acl_rulei_act_count(struct mlxsw_sp *mlxsw_sp, |
| 540 | struct mlxsw_sp_acl_rule_info *rulei); |
Jiri Pirko | ac44dd4 | 2017-04-18 16:55:32 +0200 | [diff] [blame] | 541 | int mlxsw_sp_acl_rulei_act_fid_set(struct mlxsw_sp *mlxsw_sp, |
| 542 | struct mlxsw_sp_acl_rule_info *rulei, |
| 543 | u16 fid); |
Jiri Pirko | 22a6776 | 2017-02-03 10:29:07 +0100 | [diff] [blame] | 544 | |
| 545 | struct mlxsw_sp_acl_rule; |
| 546 | |
| 547 | struct mlxsw_sp_acl_rule * |
| 548 | mlxsw_sp_acl_rule_create(struct mlxsw_sp *mlxsw_sp, |
| 549 | struct mlxsw_sp_acl_ruleset *ruleset, |
| 550 | unsigned long cookie); |
| 551 | void mlxsw_sp_acl_rule_destroy(struct mlxsw_sp *mlxsw_sp, |
| 552 | struct mlxsw_sp_acl_rule *rule); |
| 553 | int mlxsw_sp_acl_rule_add(struct mlxsw_sp *mlxsw_sp, |
| 554 | struct mlxsw_sp_acl_rule *rule); |
| 555 | void mlxsw_sp_acl_rule_del(struct mlxsw_sp *mlxsw_sp, |
| 556 | struct mlxsw_sp_acl_rule *rule); |
| 557 | struct mlxsw_sp_acl_rule * |
| 558 | mlxsw_sp_acl_rule_lookup(struct mlxsw_sp *mlxsw_sp, |
| 559 | struct mlxsw_sp_acl_ruleset *ruleset, |
| 560 | unsigned long cookie); |
| 561 | struct mlxsw_sp_acl_rule_info * |
| 562 | mlxsw_sp_acl_rule_rulei(struct mlxsw_sp_acl_rule *rule); |
Arkadi Sharshevsky | 4817072 | 2017-03-11 09:42:58 +0100 | [diff] [blame] | 563 | int mlxsw_sp_acl_rule_get_stats(struct mlxsw_sp *mlxsw_sp, |
| 564 | struct mlxsw_sp_acl_rule *rule, |
| 565 | u64 *packets, u64 *bytes, u64 *last_use); |
Jiri Pirko | 22a6776 | 2017-02-03 10:29:07 +0100 | [diff] [blame] | 566 | |
Ido Schimmel | a110748 | 2017-05-26 08:37:39 +0200 | [diff] [blame] | 567 | struct mlxsw_sp_fid *mlxsw_sp_acl_dummy_fid(struct mlxsw_sp *mlxsw_sp); |
| 568 | |
Jiri Pirko | 22a6776 | 2017-02-03 10:29:07 +0100 | [diff] [blame] | 569 | int mlxsw_sp_acl_init(struct mlxsw_sp *mlxsw_sp); |
| 570 | void mlxsw_sp_acl_fini(struct mlxsw_sp *mlxsw_sp); |
| 571 | |
Ido Schimmel | cb4cc0e | 2017-06-04 16:53:38 +0200 | [diff] [blame] | 572 | /* spectrum_acl_tcam.c */ |
Jiri Pirko | 22a6776 | 2017-02-03 10:29:07 +0100 | [diff] [blame] | 573 | extern const struct mlxsw_sp_acl_ops mlxsw_sp_acl_tcam_ops; |
| 574 | |
Ido Schimmel | cb4cc0e | 2017-06-04 16:53:38 +0200 | [diff] [blame] | 575 | /* spectrum_flower.c */ |
Jiri Pirko | 7aa0f5a | 2017-02-03 10:29:09 +0100 | [diff] [blame] | 576 | int mlxsw_sp_flower_replace(struct mlxsw_sp_port *mlxsw_sp_port, bool ingress, |
Jiri Pirko | 5fd9fc4 | 2017-08-07 10:15:29 +0200 | [diff] [blame] | 577 | struct tc_cls_flower_offload *f); |
Jiri Pirko | 7aa0f5a | 2017-02-03 10:29:09 +0100 | [diff] [blame] | 578 | void mlxsw_sp_flower_destroy(struct mlxsw_sp_port *mlxsw_sp_port, bool ingress, |
| 579 | struct tc_cls_flower_offload *f); |
Arkadi Sharshevsky | 7c1b8eb | 2017-03-11 09:42:59 +0100 | [diff] [blame] | 580 | int mlxsw_sp_flower_stats(struct mlxsw_sp_port *mlxsw_sp_port, bool ingress, |
| 581 | struct tc_cls_flower_offload *f); |
Jiri Pirko | 7aa0f5a | 2017-02-03 10:29:09 +0100 | [diff] [blame] | 582 | |
Nogah Frankel | 96f17e0 | 2017-11-06 07:23:45 +0100 | [diff] [blame] | 583 | /* spectrum_qdisc.c */ |
| 584 | int mlxsw_sp_setup_tc_red(struct mlxsw_sp_port *mlxsw_sp_port, |
| 585 | struct tc_red_qopt_offload *p); |
| 586 | |
Ido Schimmel | cb4cc0e | 2017-06-04 16:53:38 +0200 | [diff] [blame] | 587 | /* spectrum_fid.c */ |
Ido Schimmel | a110748 | 2017-05-26 08:37:39 +0200 | [diff] [blame] | 588 | int mlxsw_sp_fid_flood_set(struct mlxsw_sp_fid *fid, |
| 589 | enum mlxsw_sp_flood_type packet_type, u8 local_port, |
| 590 | bool member); |
| 591 | int mlxsw_sp_fid_port_vid_map(struct mlxsw_sp_fid *fid, |
| 592 | struct mlxsw_sp_port *mlxsw_sp_port, u16 vid); |
| 593 | void mlxsw_sp_fid_port_vid_unmap(struct mlxsw_sp_fid *fid, |
| 594 | struct mlxsw_sp_port *mlxsw_sp_port, u16 vid); |
| 595 | enum mlxsw_sp_rif_type mlxsw_sp_fid_rif_type(const struct mlxsw_sp_fid *fid); |
| 596 | u16 mlxsw_sp_fid_index(const struct mlxsw_sp_fid *fid); |
| 597 | enum mlxsw_sp_fid_type mlxsw_sp_fid_type(const struct mlxsw_sp_fid *fid); |
| 598 | void mlxsw_sp_fid_rif_set(struct mlxsw_sp_fid *fid, struct mlxsw_sp_rif *rif); |
Ido Schimmel | e4f3c1c | 2017-05-26 08:37:40 +0200 | [diff] [blame] | 599 | enum mlxsw_sp_rif_type |
| 600 | mlxsw_sp_fid_type_rif_type(const struct mlxsw_sp *mlxsw_sp, |
| 601 | enum mlxsw_sp_fid_type type); |
| 602 | u16 mlxsw_sp_fid_8021q_vid(const struct mlxsw_sp_fid *fid); |
Ido Schimmel | a110748 | 2017-05-26 08:37:39 +0200 | [diff] [blame] | 603 | struct mlxsw_sp_fid *mlxsw_sp_fid_8021q_get(struct mlxsw_sp *mlxsw_sp, u16 vid); |
| 604 | struct mlxsw_sp_fid *mlxsw_sp_fid_8021d_get(struct mlxsw_sp *mlxsw_sp, |
| 605 | int br_ifindex); |
| 606 | struct mlxsw_sp_fid *mlxsw_sp_fid_rfid_get(struct mlxsw_sp *mlxsw_sp, |
| 607 | u16 rif_index); |
| 608 | struct mlxsw_sp_fid *mlxsw_sp_fid_dummy_get(struct mlxsw_sp *mlxsw_sp); |
| 609 | void mlxsw_sp_fid_put(struct mlxsw_sp_fid *fid); |
| 610 | int mlxsw_sp_port_fids_init(struct mlxsw_sp_port *mlxsw_sp_port); |
| 611 | void mlxsw_sp_port_fids_fini(struct mlxsw_sp_port *mlxsw_sp_port); |
| 612 | int mlxsw_sp_fids_init(struct mlxsw_sp *mlxsw_sp); |
| 613 | void mlxsw_sp_fids_fini(struct mlxsw_sp *mlxsw_sp); |
| 614 | |
Jiri Pirko | 56ade8f | 2015-10-16 14:01:37 +0200 | [diff] [blame] | 615 | #endif |