1 /* SPDX-License-Identifier: BSD-3-Clause OR GPL-2.0 */ 2 /* Copyright (c) 2015-2018 Mellanox Technologies. All rights reserved */ 3 4 #ifndef _MLXSW_REG_H 5 #define _MLXSW_REG_H 6 7 #include <linux/kernel.h> 8 #include <linux/string.h> 9 #include <linux/bitops.h> 10 #include <linux/if_vlan.h> 11 12 #include "item.h" 13 #include "port.h" 14 15 struct mlxsw_reg_info { 16 u16 id; 17 u16 len; /* In u8 */ 18 const char *name; 19 }; 20 21 #define MLXSW_REG_DEFINE(_name, _id, _len) \ 22 static const struct mlxsw_reg_info mlxsw_reg_##_name = { \ 23 .id = _id, \ 24 .len = _len, \ 25 .name = #_name, \ 26 } 27 28 #define MLXSW_REG(type) (&mlxsw_reg_##type) 29 #define MLXSW_REG_LEN(type) MLXSW_REG(type)->len 30 #define MLXSW_REG_ZERO(type, payload) memset(payload, 0, MLXSW_REG(type)->len) 31 32 /* SGCR - Switch General Configuration Register 33 * -------------------------------------------- 34 * This register is used for configuration of the switch capabilities. 35 */ 36 #define MLXSW_REG_SGCR_ID 0x2000 37 #define MLXSW_REG_SGCR_LEN 0x10 38 39 MLXSW_REG_DEFINE(sgcr, MLXSW_REG_SGCR_ID, MLXSW_REG_SGCR_LEN); 40 41 /* reg_sgcr_llb 42 * Link Local Broadcast (Default=0) 43 * When set, all Link Local packets (224.0.0.X) will be treated as broadcast 44 * packets and ignore the IGMP snooping entries. 45 * Access: RW 46 */ 47 MLXSW_ITEM32(reg, sgcr, llb, 0x04, 0, 1); 48 49 static inline void mlxsw_reg_sgcr_pack(char *payload, bool llb) 50 { 51 MLXSW_REG_ZERO(sgcr, payload); 52 mlxsw_reg_sgcr_llb_set(payload, !!llb); 53 } 54 55 /* SPAD - Switch Physical Address Register 56 * --------------------------------------- 57 * The SPAD register configures the switch physical MAC address. 58 */ 59 #define MLXSW_REG_SPAD_ID 0x2002 60 #define MLXSW_REG_SPAD_LEN 0x10 61 62 MLXSW_REG_DEFINE(spad, MLXSW_REG_SPAD_ID, MLXSW_REG_SPAD_LEN); 63 64 /* reg_spad_base_mac 65 * Base MAC address for the switch partitions. 66 * Per switch partition MAC address is equal to: 67 * base_mac + swid 68 * Access: RW 69 */ 70 MLXSW_ITEM_BUF(reg, spad, base_mac, 0x02, 6); 71 72 /* SSPR - Switch System Port Record Register 73 * ----------------------------------------- 74 * Configures the system port to local port mapping. 75 */ 76 #define MLXSW_REG_SSPR_ID 0x2008 77 #define MLXSW_REG_SSPR_LEN 0x8 78 79 MLXSW_REG_DEFINE(sspr, MLXSW_REG_SSPR_ID, MLXSW_REG_SSPR_LEN); 80 81 /* reg_sspr_m 82 * Master - if set, then the record describes the master system port. 83 * This is needed in case a local port is mapped into several system ports 84 * (for multipathing). That number will be reported as the source system 85 * port when packets are forwarded to the CPU. Only one master port is allowed 86 * per local port. 87 * 88 * Note: Must be set for Spectrum. 89 * Access: RW 90 */ 91 MLXSW_ITEM32(reg, sspr, m, 0x00, 31, 1); 92 93 /* reg_sspr_local_port 94 * Local port number. 95 * 96 * Access: RW 97 */ 98 MLXSW_ITEM32_LP(reg, sspr, 0x00, 16, 0x00, 12); 99 100 /* reg_sspr_sub_port 101 * Virtual port within the physical port. 102 * Should be set to 0 when virtual ports are not enabled on the port. 103 * 104 * Access: RW 105 */ 106 MLXSW_ITEM32(reg, sspr, sub_port, 0x00, 8, 8); 107 108 /* reg_sspr_system_port 109 * Unique identifier within the stacking domain that represents all the ports 110 * that are available in the system (external ports). 111 * 112 * Currently, only single-ASIC configurations are supported, so we default to 113 * 1:1 mapping between system ports and local ports. 114 * Access: Index 115 */ 116 MLXSW_ITEM32(reg, sspr, system_port, 0x04, 0, 16); 117 118 static inline void mlxsw_reg_sspr_pack(char *payload, u16 local_port) 119 { 120 MLXSW_REG_ZERO(sspr, payload); 121 mlxsw_reg_sspr_m_set(payload, 1); 122 mlxsw_reg_sspr_local_port_set(payload, local_port); 123 mlxsw_reg_sspr_sub_port_set(payload, 0); 124 mlxsw_reg_sspr_system_port_set(payload, local_port); 125 } 126 127 /* SFDAT - Switch Filtering Database Aging Time 128 * -------------------------------------------- 129 * Controls the Switch aging time. Aging time is able to be set per Switch 130 * Partition. 131 */ 132 #define MLXSW_REG_SFDAT_ID 0x2009 133 #define MLXSW_REG_SFDAT_LEN 0x8 134 135 MLXSW_REG_DEFINE(sfdat, MLXSW_REG_SFDAT_ID, MLXSW_REG_SFDAT_LEN); 136 137 /* reg_sfdat_swid 138 * Switch partition ID. 139 * Access: Index 140 */ 141 MLXSW_ITEM32(reg, sfdat, swid, 0x00, 24, 8); 142 143 /* reg_sfdat_age_time 144 * Aging time in seconds 145 * Min - 10 seconds 146 * Max - 1,000,000 seconds 147 * Default is 300 seconds. 148 * Access: RW 149 */ 150 MLXSW_ITEM32(reg, sfdat, age_time, 0x04, 0, 20); 151 152 static inline void mlxsw_reg_sfdat_pack(char *payload, u32 age_time) 153 { 154 MLXSW_REG_ZERO(sfdat, payload); 155 mlxsw_reg_sfdat_swid_set(payload, 0); 156 mlxsw_reg_sfdat_age_time_set(payload, age_time); 157 } 158 159 /* SFD - Switch Filtering Database 160 * ------------------------------- 161 * The following register defines the access to the filtering database. 162 * The register supports querying, adding, removing and modifying the database. 163 * The access is optimized for bulk updates in which case more than one 164 * FDB record is present in the same command. 165 */ 166 #define MLXSW_REG_SFD_ID 0x200A 167 #define MLXSW_REG_SFD_BASE_LEN 0x10 /* base length, without records */ 168 #define MLXSW_REG_SFD_REC_LEN 0x10 /* record length */ 169 #define MLXSW_REG_SFD_REC_MAX_COUNT 64 170 #define MLXSW_REG_SFD_LEN (MLXSW_REG_SFD_BASE_LEN + \ 171 MLXSW_REG_SFD_REC_LEN * MLXSW_REG_SFD_REC_MAX_COUNT) 172 173 MLXSW_REG_DEFINE(sfd, MLXSW_REG_SFD_ID, MLXSW_REG_SFD_LEN); 174 175 /* reg_sfd_swid 176 * Switch partition ID for queries. Reserved on Write. 177 * Access: Index 178 */ 179 MLXSW_ITEM32(reg, sfd, swid, 0x00, 24, 8); 180 181 enum mlxsw_reg_sfd_op { 182 /* Dump entire FDB a (process according to record_locator) */ 183 MLXSW_REG_SFD_OP_QUERY_DUMP = 0, 184 /* Query records by {MAC, VID/FID} value */ 185 MLXSW_REG_SFD_OP_QUERY_QUERY = 1, 186 /* Query and clear activity. Query records by {MAC, VID/FID} value */ 187 MLXSW_REG_SFD_OP_QUERY_QUERY_AND_CLEAR_ACTIVITY = 2, 188 /* Test. Response indicates if each of the records could be 189 * added to the FDB. 190 */ 191 MLXSW_REG_SFD_OP_WRITE_TEST = 0, 192 /* Add/modify. Aged-out records cannot be added. This command removes 193 * the learning notification of the {MAC, VID/FID}. Response includes 194 * the entries that were added to the FDB. 195 */ 196 MLXSW_REG_SFD_OP_WRITE_EDIT = 1, 197 /* Remove record by {MAC, VID/FID}. This command also removes 198 * the learning notification and aged-out notifications 199 * of the {MAC, VID/FID}. The response provides current (pre-removal) 200 * entries as non-aged-out. 201 */ 202 MLXSW_REG_SFD_OP_WRITE_REMOVE = 2, 203 /* Remove learned notification by {MAC, VID/FID}. The response provides 204 * the removed learning notification. 205 */ 206 MLXSW_REG_SFD_OP_WRITE_REMOVE_NOTIFICATION = 2, 207 }; 208 209 /* reg_sfd_op 210 * Operation. 211 * Access: OP 212 */ 213 MLXSW_ITEM32(reg, sfd, op, 0x04, 30, 2); 214 215 /* reg_sfd_record_locator 216 * Used for querying the FDB. Use record_locator=0 to initiate the 217 * query. When a record is returned, a new record_locator is 218 * returned to be used in the subsequent query. 219 * Reserved for database update. 220 * Access: Index 221 */ 222 MLXSW_ITEM32(reg, sfd, record_locator, 0x04, 0, 30); 223 224 /* reg_sfd_num_rec 225 * Request: Number of records to read/add/modify/remove 226 * Response: Number of records read/added/replaced/removed 227 * See above description for more details. 228 * Ranges 0..64 229 * Access: RW 230 */ 231 MLXSW_ITEM32(reg, sfd, num_rec, 0x08, 0, 8); 232 233 static inline void mlxsw_reg_sfd_pack(char *payload, enum mlxsw_reg_sfd_op op, 234 u32 record_locator) 235 { 236 MLXSW_REG_ZERO(sfd, payload); 237 mlxsw_reg_sfd_op_set(payload, op); 238 mlxsw_reg_sfd_record_locator_set(payload, record_locator); 239 } 240 241 /* reg_sfd_rec_swid 242 * Switch partition ID. 243 * Access: Index 244 */ 245 MLXSW_ITEM32_INDEXED(reg, sfd, rec_swid, MLXSW_REG_SFD_BASE_LEN, 24, 8, 246 MLXSW_REG_SFD_REC_LEN, 0x00, false); 247 248 enum mlxsw_reg_sfd_rec_type { 249 MLXSW_REG_SFD_REC_TYPE_UNICAST = 0x0, 250 MLXSW_REG_SFD_REC_TYPE_UNICAST_LAG = 0x1, 251 MLXSW_REG_SFD_REC_TYPE_MULTICAST = 0x2, 252 MLXSW_REG_SFD_REC_TYPE_UNICAST_TUNNEL = 0xC, 253 }; 254 255 /* reg_sfd_rec_type 256 * FDB record type. 257 * Access: RW 258 */ 259 MLXSW_ITEM32_INDEXED(reg, sfd, rec_type, MLXSW_REG_SFD_BASE_LEN, 20, 4, 260 MLXSW_REG_SFD_REC_LEN, 0x00, false); 261 262 enum mlxsw_reg_sfd_rec_policy { 263 /* Replacement disabled, aging disabled. */ 264 MLXSW_REG_SFD_REC_POLICY_STATIC_ENTRY = 0, 265 /* (mlag remote): Replacement enabled, aging disabled, 266 * learning notification enabled on this port. 267 */ 268 MLXSW_REG_SFD_REC_POLICY_DYNAMIC_ENTRY_MLAG = 1, 269 /* (ingress device): Replacement enabled, aging enabled. */ 270 MLXSW_REG_SFD_REC_POLICY_DYNAMIC_ENTRY_INGRESS = 3, 271 }; 272 273 /* reg_sfd_rec_policy 274 * Policy. 275 * Access: RW 276 */ 277 MLXSW_ITEM32_INDEXED(reg, sfd, rec_policy, MLXSW_REG_SFD_BASE_LEN, 18, 2, 278 MLXSW_REG_SFD_REC_LEN, 0x00, false); 279 280 /* reg_sfd_rec_a 281 * Activity. Set for new static entries. Set for static entries if a frame SMAC 282 * lookup hits on the entry. 283 * To clear the a bit, use "query and clear activity" op. 284 * Access: RO 285 */ 286 MLXSW_ITEM32_INDEXED(reg, sfd, rec_a, MLXSW_REG_SFD_BASE_LEN, 16, 1, 287 MLXSW_REG_SFD_REC_LEN, 0x00, false); 288 289 /* reg_sfd_rec_mac 290 * MAC address. 291 * Access: Index 292 */ 293 MLXSW_ITEM_BUF_INDEXED(reg, sfd, rec_mac, MLXSW_REG_SFD_BASE_LEN, 6, 294 MLXSW_REG_SFD_REC_LEN, 0x02); 295 296 enum mlxsw_reg_sfd_rec_action { 297 /* forward */ 298 MLXSW_REG_SFD_REC_ACTION_NOP = 0, 299 /* forward and trap, trap_id is FDB_TRAP */ 300 MLXSW_REG_SFD_REC_ACTION_MIRROR_TO_CPU = 1, 301 /* trap and do not forward, trap_id is FDB_TRAP */ 302 MLXSW_REG_SFD_REC_ACTION_TRAP = 2, 303 /* forward to IP router */ 304 MLXSW_REG_SFD_REC_ACTION_FORWARD_IP_ROUTER = 3, 305 MLXSW_REG_SFD_REC_ACTION_DISCARD_ERROR = 15, 306 }; 307 308 /* reg_sfd_rec_action 309 * Action to apply on the packet. 310 * Note: Dynamic entries can only be configured with NOP action. 311 * Access: RW 312 */ 313 MLXSW_ITEM32_INDEXED(reg, sfd, rec_action, MLXSW_REG_SFD_BASE_LEN, 28, 4, 314 MLXSW_REG_SFD_REC_LEN, 0x0C, false); 315 316 /* reg_sfd_uc_sub_port 317 * VEPA channel on local port. 318 * Valid only if local port is a non-stacking port. Must be 0 if multichannel 319 * VEPA is not enabled. 320 * Access: RW 321 */ 322 MLXSW_ITEM32_INDEXED(reg, sfd, uc_sub_port, MLXSW_REG_SFD_BASE_LEN, 16, 8, 323 MLXSW_REG_SFD_REC_LEN, 0x08, false); 324 325 /* reg_sfd_uc_fid_vid 326 * Filtering ID or VLAN ID 327 * For SwitchX and SwitchX-2: 328 * - Dynamic entries (policy 2,3) use FID 329 * - Static entries (policy 0) use VID 330 * - When independent learning is configured, VID=FID 331 * For Spectrum: use FID for both Dynamic and Static entries. 332 * VID should not be used. 333 * Access: Index 334 */ 335 MLXSW_ITEM32_INDEXED(reg, sfd, uc_fid_vid, MLXSW_REG_SFD_BASE_LEN, 0, 16, 336 MLXSW_REG_SFD_REC_LEN, 0x08, false); 337 338 /* reg_sfd_uc_system_port 339 * Unique port identifier for the final destination of the packet. 340 * Access: RW 341 */ 342 MLXSW_ITEM32_INDEXED(reg, sfd, uc_system_port, MLXSW_REG_SFD_BASE_LEN, 0, 16, 343 MLXSW_REG_SFD_REC_LEN, 0x0C, false); 344 345 static inline void mlxsw_reg_sfd_rec_pack(char *payload, int rec_index, 346 enum mlxsw_reg_sfd_rec_type rec_type, 347 const char *mac, 348 enum mlxsw_reg_sfd_rec_action action) 349 { 350 u8 num_rec = mlxsw_reg_sfd_num_rec_get(payload); 351 352 if (rec_index >= num_rec) 353 mlxsw_reg_sfd_num_rec_set(payload, rec_index + 1); 354 mlxsw_reg_sfd_rec_swid_set(payload, rec_index, 0); 355 mlxsw_reg_sfd_rec_type_set(payload, rec_index, rec_type); 356 mlxsw_reg_sfd_rec_mac_memcpy_to(payload, rec_index, mac); 357 mlxsw_reg_sfd_rec_action_set(payload, rec_index, action); 358 } 359 360 static inline void mlxsw_reg_sfd_uc_pack(char *payload, int rec_index, 361 enum mlxsw_reg_sfd_rec_policy policy, 362 const char *mac, u16 fid_vid, 363 enum mlxsw_reg_sfd_rec_action action, 364 u16 local_port) 365 { 366 mlxsw_reg_sfd_rec_pack(payload, rec_index, 367 MLXSW_REG_SFD_REC_TYPE_UNICAST, mac, action); 368 mlxsw_reg_sfd_rec_policy_set(payload, rec_index, policy); 369 mlxsw_reg_sfd_uc_sub_port_set(payload, rec_index, 0); 370 mlxsw_reg_sfd_uc_fid_vid_set(payload, rec_index, fid_vid); 371 mlxsw_reg_sfd_uc_system_port_set(payload, rec_index, local_port); 372 } 373 374 /* reg_sfd_uc_lag_sub_port 375 * LAG sub port. 376 * Must be 0 if multichannel VEPA is not enabled. 377 * Access: RW 378 */ 379 MLXSW_ITEM32_INDEXED(reg, sfd, uc_lag_sub_port, MLXSW_REG_SFD_BASE_LEN, 16, 8, 380 MLXSW_REG_SFD_REC_LEN, 0x08, false); 381 382 /* reg_sfd_uc_lag_fid_vid 383 * Filtering ID or VLAN ID 384 * For SwitchX and SwitchX-2: 385 * - Dynamic entries (policy 2,3) use FID 386 * - Static entries (policy 0) use VID 387 * - When independent learning is configured, VID=FID 388 * For Spectrum: use FID for both Dynamic and Static entries. 389 * VID should not be used. 390 * Access: Index 391 */ 392 MLXSW_ITEM32_INDEXED(reg, sfd, uc_lag_fid_vid, MLXSW_REG_SFD_BASE_LEN, 0, 16, 393 MLXSW_REG_SFD_REC_LEN, 0x08, false); 394 395 /* reg_sfd_uc_lag_lag_vid 396 * Indicates VID in case of vFIDs. Reserved for FIDs. 397 * Access: RW 398 */ 399 MLXSW_ITEM32_INDEXED(reg, sfd, uc_lag_lag_vid, MLXSW_REG_SFD_BASE_LEN, 16, 12, 400 MLXSW_REG_SFD_REC_LEN, 0x0C, false); 401 402 /* reg_sfd_uc_lag_lag_id 403 * LAG Identifier - pointer into the LAG descriptor table. 404 * Access: RW 405 */ 406 MLXSW_ITEM32_INDEXED(reg, sfd, uc_lag_lag_id, MLXSW_REG_SFD_BASE_LEN, 0, 10, 407 MLXSW_REG_SFD_REC_LEN, 0x0C, false); 408 409 static inline void 410 mlxsw_reg_sfd_uc_lag_pack(char *payload, int rec_index, 411 enum mlxsw_reg_sfd_rec_policy policy, 412 const char *mac, u16 fid_vid, 413 enum mlxsw_reg_sfd_rec_action action, u16 lag_vid, 414 u16 lag_id) 415 { 416 mlxsw_reg_sfd_rec_pack(payload, rec_index, 417 MLXSW_REG_SFD_REC_TYPE_UNICAST_LAG, 418 mac, action); 419 mlxsw_reg_sfd_rec_policy_set(payload, rec_index, policy); 420 mlxsw_reg_sfd_uc_lag_sub_port_set(payload, rec_index, 0); 421 mlxsw_reg_sfd_uc_lag_fid_vid_set(payload, rec_index, fid_vid); 422 mlxsw_reg_sfd_uc_lag_lag_vid_set(payload, rec_index, lag_vid); 423 mlxsw_reg_sfd_uc_lag_lag_id_set(payload, rec_index, lag_id); 424 } 425 426 /* reg_sfd_mc_pgi 427 * 428 * Multicast port group index - index into the port group table. 429 * Value 0x1FFF indicates the pgi should point to the MID entry. 430 * For Spectrum this value must be set to 0x1FFF 431 * Access: RW 432 */ 433 MLXSW_ITEM32_INDEXED(reg, sfd, mc_pgi, MLXSW_REG_SFD_BASE_LEN, 16, 13, 434 MLXSW_REG_SFD_REC_LEN, 0x08, false); 435 436 /* reg_sfd_mc_fid_vid 437 * 438 * Filtering ID or VLAN ID 439 * Access: Index 440 */ 441 MLXSW_ITEM32_INDEXED(reg, sfd, mc_fid_vid, MLXSW_REG_SFD_BASE_LEN, 0, 16, 442 MLXSW_REG_SFD_REC_LEN, 0x08, false); 443 444 /* reg_sfd_mc_mid 445 * 446 * Multicast identifier - global identifier that represents the multicast 447 * group across all devices. 448 * Access: RW 449 */ 450 MLXSW_ITEM32_INDEXED(reg, sfd, mc_mid, MLXSW_REG_SFD_BASE_LEN, 0, 16, 451 MLXSW_REG_SFD_REC_LEN, 0x0C, false); 452 453 static inline void 454 mlxsw_reg_sfd_mc_pack(char *payload, int rec_index, 455 const char *mac, u16 fid_vid, 456 enum mlxsw_reg_sfd_rec_action action, u16 mid) 457 { 458 mlxsw_reg_sfd_rec_pack(payload, rec_index, 459 MLXSW_REG_SFD_REC_TYPE_MULTICAST, mac, action); 460 mlxsw_reg_sfd_mc_pgi_set(payload, rec_index, 0x1FFF); 461 mlxsw_reg_sfd_mc_fid_vid_set(payload, rec_index, fid_vid); 462 mlxsw_reg_sfd_mc_mid_set(payload, rec_index, mid); 463 } 464 465 /* reg_sfd_uc_tunnel_uip_msb 466 * When protocol is IPv4, the most significant byte of the underlay IPv4 467 * destination IP. 468 * When protocol is IPv6, reserved. 469 * Access: RW 470 */ 471 MLXSW_ITEM32_INDEXED(reg, sfd, uc_tunnel_uip_msb, MLXSW_REG_SFD_BASE_LEN, 24, 472 8, MLXSW_REG_SFD_REC_LEN, 0x08, false); 473 474 /* reg_sfd_uc_tunnel_fid 475 * Filtering ID. 476 * Access: Index 477 */ 478 MLXSW_ITEM32_INDEXED(reg, sfd, uc_tunnel_fid, MLXSW_REG_SFD_BASE_LEN, 0, 16, 479 MLXSW_REG_SFD_REC_LEN, 0x08, false); 480 481 enum mlxsw_reg_sfd_uc_tunnel_protocol { 482 MLXSW_REG_SFD_UC_TUNNEL_PROTOCOL_IPV4, 483 MLXSW_REG_SFD_UC_TUNNEL_PROTOCOL_IPV6, 484 }; 485 486 /* reg_sfd_uc_tunnel_protocol 487 * IP protocol. 488 * Access: RW 489 */ 490 MLXSW_ITEM32_INDEXED(reg, sfd, uc_tunnel_protocol, MLXSW_REG_SFD_BASE_LEN, 27, 491 1, MLXSW_REG_SFD_REC_LEN, 0x0C, false); 492 493 /* reg_sfd_uc_tunnel_uip_lsb 494 * When protocol is IPv4, the least significant bytes of the underlay 495 * IPv4 destination IP. 496 * When protocol is IPv6, pointer to the underlay IPv6 destination IP 497 * which is configured by RIPS. 498 * Access: RW 499 */ 500 MLXSW_ITEM32_INDEXED(reg, sfd, uc_tunnel_uip_lsb, MLXSW_REG_SFD_BASE_LEN, 0, 501 24, MLXSW_REG_SFD_REC_LEN, 0x0C, false); 502 503 static inline void 504 mlxsw_reg_sfd_uc_tunnel_pack(char *payload, int rec_index, 505 enum mlxsw_reg_sfd_rec_policy policy, 506 const char *mac, u16 fid, 507 enum mlxsw_reg_sfd_rec_action action, u32 uip, 508 enum mlxsw_reg_sfd_uc_tunnel_protocol proto) 509 { 510 mlxsw_reg_sfd_rec_pack(payload, rec_index, 511 MLXSW_REG_SFD_REC_TYPE_UNICAST_TUNNEL, mac, 512 action); 513 mlxsw_reg_sfd_rec_policy_set(payload, rec_index, policy); 514 mlxsw_reg_sfd_uc_tunnel_uip_msb_set(payload, rec_index, uip >> 24); 515 mlxsw_reg_sfd_uc_tunnel_uip_lsb_set(payload, rec_index, uip); 516 mlxsw_reg_sfd_uc_tunnel_fid_set(payload, rec_index, fid); 517 mlxsw_reg_sfd_uc_tunnel_protocol_set(payload, rec_index, proto); 518 } 519 520 enum mlxsw_reg_tunnel_port { 521 MLXSW_REG_TUNNEL_PORT_NVE, 522 MLXSW_REG_TUNNEL_PORT_VPLS, 523 MLXSW_REG_TUNNEL_PORT_FLEX_TUNNEL0, 524 MLXSW_REG_TUNNEL_PORT_FLEX_TUNNEL1, 525 }; 526 527 /* SFN - Switch FDB Notification Register 528 * ------------------------------------------- 529 * The switch provides notifications on newly learned FDB entries and 530 * aged out entries. The notifications can be polled by software. 531 */ 532 #define MLXSW_REG_SFN_ID 0x200B 533 #define MLXSW_REG_SFN_BASE_LEN 0x10 /* base length, without records */ 534 #define MLXSW_REG_SFN_REC_LEN 0x10 /* record length */ 535 #define MLXSW_REG_SFN_REC_MAX_COUNT 64 536 #define MLXSW_REG_SFN_LEN (MLXSW_REG_SFN_BASE_LEN + \ 537 MLXSW_REG_SFN_REC_LEN * MLXSW_REG_SFN_REC_MAX_COUNT) 538 539 MLXSW_REG_DEFINE(sfn, MLXSW_REG_SFN_ID, MLXSW_REG_SFN_LEN); 540 541 /* reg_sfn_swid 542 * Switch partition ID. 543 * Access: Index 544 */ 545 MLXSW_ITEM32(reg, sfn, swid, 0x00, 24, 8); 546 547 /* reg_sfn_end 548 * Forces the current session to end. 549 * Access: OP 550 */ 551 MLXSW_ITEM32(reg, sfn, end, 0x04, 20, 1); 552 553 /* reg_sfn_num_rec 554 * Request: Number of learned notifications and aged-out notification 555 * records requested. 556 * Response: Number of notification records returned (must be smaller 557 * than or equal to the value requested) 558 * Ranges 0..64 559 * Access: OP 560 */ 561 MLXSW_ITEM32(reg, sfn, num_rec, 0x04, 0, 8); 562 563 static inline void mlxsw_reg_sfn_pack(char *payload) 564 { 565 MLXSW_REG_ZERO(sfn, payload); 566 mlxsw_reg_sfn_swid_set(payload, 0); 567 mlxsw_reg_sfn_end_set(payload, 0); 568 mlxsw_reg_sfn_num_rec_set(payload, MLXSW_REG_SFN_REC_MAX_COUNT); 569 } 570 571 /* reg_sfn_rec_swid 572 * Switch partition ID. 573 * Access: RO 574 */ 575 MLXSW_ITEM32_INDEXED(reg, sfn, rec_swid, MLXSW_REG_SFN_BASE_LEN, 24, 8, 576 MLXSW_REG_SFN_REC_LEN, 0x00, false); 577 578 enum mlxsw_reg_sfn_rec_type { 579 /* MAC addresses learned on a regular port. */ 580 MLXSW_REG_SFN_REC_TYPE_LEARNED_MAC = 0x5, 581 /* MAC addresses learned on a LAG port. */ 582 MLXSW_REG_SFN_REC_TYPE_LEARNED_MAC_LAG = 0x6, 583 /* Aged-out MAC address on a regular port. */ 584 MLXSW_REG_SFN_REC_TYPE_AGED_OUT_MAC = 0x7, 585 /* Aged-out MAC address on a LAG port. */ 586 MLXSW_REG_SFN_REC_TYPE_AGED_OUT_MAC_LAG = 0x8, 587 /* Learned unicast tunnel record. */ 588 MLXSW_REG_SFN_REC_TYPE_LEARNED_UNICAST_TUNNEL = 0xD, 589 /* Aged-out unicast tunnel record. */ 590 MLXSW_REG_SFN_REC_TYPE_AGED_OUT_UNICAST_TUNNEL = 0xE, 591 }; 592 593 /* reg_sfn_rec_type 594 * Notification record type. 595 * Access: RO 596 */ 597 MLXSW_ITEM32_INDEXED(reg, sfn, rec_type, MLXSW_REG_SFN_BASE_LEN, 20, 4, 598 MLXSW_REG_SFN_REC_LEN, 0x00, false); 599 600 /* reg_sfn_rec_mac 601 * MAC address. 602 * Access: RO 603 */ 604 MLXSW_ITEM_BUF_INDEXED(reg, sfn, rec_mac, MLXSW_REG_SFN_BASE_LEN, 6, 605 MLXSW_REG_SFN_REC_LEN, 0x02); 606 607 /* reg_sfn_mac_sub_port 608 * VEPA channel on the local port. 609 * 0 if multichannel VEPA is not enabled. 610 * Access: RO 611 */ 612 MLXSW_ITEM32_INDEXED(reg, sfn, mac_sub_port, MLXSW_REG_SFN_BASE_LEN, 16, 8, 613 MLXSW_REG_SFN_REC_LEN, 0x08, false); 614 615 /* reg_sfn_mac_fid 616 * Filtering identifier. 617 * Access: RO 618 */ 619 MLXSW_ITEM32_INDEXED(reg, sfn, mac_fid, MLXSW_REG_SFN_BASE_LEN, 0, 16, 620 MLXSW_REG_SFN_REC_LEN, 0x08, false); 621 622 /* reg_sfn_mac_system_port 623 * Unique port identifier for the final destination of the packet. 624 * Access: RO 625 */ 626 MLXSW_ITEM32_INDEXED(reg, sfn, mac_system_port, MLXSW_REG_SFN_BASE_LEN, 0, 16, 627 MLXSW_REG_SFN_REC_LEN, 0x0C, false); 628 629 static inline void mlxsw_reg_sfn_mac_unpack(char *payload, int rec_index, 630 char *mac, u16 *p_vid, 631 u16 *p_local_port) 632 { 633 mlxsw_reg_sfn_rec_mac_memcpy_from(payload, rec_index, mac); 634 *p_vid = mlxsw_reg_sfn_mac_fid_get(payload, rec_index); 635 *p_local_port = mlxsw_reg_sfn_mac_system_port_get(payload, rec_index); 636 } 637 638 /* reg_sfn_mac_lag_lag_id 639 * LAG ID (pointer into the LAG descriptor table). 640 * Access: RO 641 */ 642 MLXSW_ITEM32_INDEXED(reg, sfn, mac_lag_lag_id, MLXSW_REG_SFN_BASE_LEN, 0, 10, 643 MLXSW_REG_SFN_REC_LEN, 0x0C, false); 644 645 static inline void mlxsw_reg_sfn_mac_lag_unpack(char *payload, int rec_index, 646 char *mac, u16 *p_vid, 647 u16 *p_lag_id) 648 { 649 mlxsw_reg_sfn_rec_mac_memcpy_from(payload, rec_index, mac); 650 *p_vid = mlxsw_reg_sfn_mac_fid_get(payload, rec_index); 651 *p_lag_id = mlxsw_reg_sfn_mac_lag_lag_id_get(payload, rec_index); 652 } 653 654 /* reg_sfn_uc_tunnel_uip_msb 655 * When protocol is IPv4, the most significant byte of the underlay IPv4 656 * address of the remote VTEP. 657 * When protocol is IPv6, reserved. 658 * Access: RO 659 */ 660 MLXSW_ITEM32_INDEXED(reg, sfn, uc_tunnel_uip_msb, MLXSW_REG_SFN_BASE_LEN, 24, 661 8, MLXSW_REG_SFN_REC_LEN, 0x08, false); 662 663 enum mlxsw_reg_sfn_uc_tunnel_protocol { 664 MLXSW_REG_SFN_UC_TUNNEL_PROTOCOL_IPV4, 665 MLXSW_REG_SFN_UC_TUNNEL_PROTOCOL_IPV6, 666 }; 667 668 /* reg_sfn_uc_tunnel_protocol 669 * IP protocol. 670 * Access: RO 671 */ 672 MLXSW_ITEM32_INDEXED(reg, sfn, uc_tunnel_protocol, MLXSW_REG_SFN_BASE_LEN, 27, 673 1, MLXSW_REG_SFN_REC_LEN, 0x0C, false); 674 675 /* reg_sfn_uc_tunnel_uip_lsb 676 * When protocol is IPv4, the least significant bytes of the underlay 677 * IPv4 address of the remote VTEP. 678 * When protocol is IPv6, ipv6_id to be queried from TNIPSD. 679 * Access: RO 680 */ 681 MLXSW_ITEM32_INDEXED(reg, sfn, uc_tunnel_uip_lsb, MLXSW_REG_SFN_BASE_LEN, 0, 682 24, MLXSW_REG_SFN_REC_LEN, 0x0C, false); 683 684 /* reg_sfn_uc_tunnel_port 685 * Tunnel port. 686 * Reserved on Spectrum. 687 * Access: RO 688 */ 689 MLXSW_ITEM32_INDEXED(reg, sfn, tunnel_port, MLXSW_REG_SFN_BASE_LEN, 0, 4, 690 MLXSW_REG_SFN_REC_LEN, 0x10, false); 691 692 static inline void 693 mlxsw_reg_sfn_uc_tunnel_unpack(char *payload, int rec_index, char *mac, 694 u16 *p_fid, u32 *p_uip, 695 enum mlxsw_reg_sfn_uc_tunnel_protocol *p_proto) 696 { 697 u32 uip_msb, uip_lsb; 698 699 mlxsw_reg_sfn_rec_mac_memcpy_from(payload, rec_index, mac); 700 *p_fid = mlxsw_reg_sfn_mac_fid_get(payload, rec_index); 701 uip_msb = mlxsw_reg_sfn_uc_tunnel_uip_msb_get(payload, rec_index); 702 uip_lsb = mlxsw_reg_sfn_uc_tunnel_uip_lsb_get(payload, rec_index); 703 *p_uip = uip_msb << 24 | uip_lsb; 704 *p_proto = mlxsw_reg_sfn_uc_tunnel_protocol_get(payload, rec_index); 705 } 706 707 /* SPMS - Switch Port MSTP/RSTP State Register 708 * ------------------------------------------- 709 * Configures the spanning tree state of a physical port. 710 */ 711 #define MLXSW_REG_SPMS_ID 0x200D 712 #define MLXSW_REG_SPMS_LEN 0x404 713 714 MLXSW_REG_DEFINE(spms, MLXSW_REG_SPMS_ID, MLXSW_REG_SPMS_LEN); 715 716 /* reg_spms_local_port 717 * Local port number. 718 * Access: Index 719 */ 720 MLXSW_ITEM32_LP(reg, spms, 0x00, 16, 0x00, 12); 721 722 enum mlxsw_reg_spms_state { 723 MLXSW_REG_SPMS_STATE_NO_CHANGE, 724 MLXSW_REG_SPMS_STATE_DISCARDING, 725 MLXSW_REG_SPMS_STATE_LEARNING, 726 MLXSW_REG_SPMS_STATE_FORWARDING, 727 }; 728 729 /* reg_spms_state 730 * Spanning tree state of each VLAN ID (VID) of the local port. 731 * 0 - Do not change spanning tree state (used only when writing). 732 * 1 - Discarding. No learning or forwarding to/from this port (default). 733 * 2 - Learning. Port is learning, but not forwarding. 734 * 3 - Forwarding. Port is learning and forwarding. 735 * Access: RW 736 */ 737 MLXSW_ITEM_BIT_ARRAY(reg, spms, state, 0x04, 0x400, 2); 738 739 static inline void mlxsw_reg_spms_pack(char *payload, u16 local_port) 740 { 741 MLXSW_REG_ZERO(spms, payload); 742 mlxsw_reg_spms_local_port_set(payload, local_port); 743 } 744 745 static inline void mlxsw_reg_spms_vid_pack(char *payload, u16 vid, 746 enum mlxsw_reg_spms_state state) 747 { 748 mlxsw_reg_spms_state_set(payload, vid, state); 749 } 750 751 /* SPVID - Switch Port VID 752 * ----------------------- 753 * The switch port VID configures the default VID for a port. 754 */ 755 #define MLXSW_REG_SPVID_ID 0x200E 756 #define MLXSW_REG_SPVID_LEN 0x08 757 758 MLXSW_REG_DEFINE(spvid, MLXSW_REG_SPVID_ID, MLXSW_REG_SPVID_LEN); 759 760 /* reg_spvid_tport 761 * Port is tunnel port. 762 * Reserved when SwitchX/-2 or Spectrum-1. 763 * Access: Index 764 */ 765 MLXSW_ITEM32(reg, spvid, tport, 0x00, 24, 1); 766 767 /* reg_spvid_local_port 768 * When tport = 0: Local port number. Not supported for CPU port. 769 * When tport = 1: Tunnel port. 770 * Access: Index 771 */ 772 MLXSW_ITEM32_LP(reg, spvid, 0x00, 16, 0x00, 12); 773 774 /* reg_spvid_sub_port 775 * Virtual port within the physical port. 776 * Should be set to 0 when virtual ports are not enabled on the port. 777 * Access: Index 778 */ 779 MLXSW_ITEM32(reg, spvid, sub_port, 0x00, 8, 8); 780 781 /* reg_spvid_egr_et_set 782 * When VLAN is pushed at ingress (for untagged packets or for 783 * QinQ push mode) then the EtherType is decided at the egress port. 784 * Reserved when Spectrum-1. 785 * Access: RW 786 */ 787 MLXSW_ITEM32(reg, spvid, egr_et_set, 0x04, 24, 1); 788 789 /* reg_spvid_et_vlan 790 * EtherType used for when VLAN is pushed at ingress (for untagged 791 * packets or for QinQ push mode). 792 * 0: ether_type0 - (default) 793 * 1: ether_type1 794 * 2: ether_type2 - Reserved when Spectrum-1, supported by Spectrum-2 795 * Ethertype IDs are configured by SVER. 796 * Reserved when egr_et_set = 1. 797 * Access: RW 798 */ 799 MLXSW_ITEM32(reg, spvid, et_vlan, 0x04, 16, 2); 800 801 /* reg_spvid_pvid 802 * Port default VID 803 * Access: RW 804 */ 805 MLXSW_ITEM32(reg, spvid, pvid, 0x04, 0, 12); 806 807 static inline void mlxsw_reg_spvid_pack(char *payload, u16 local_port, u16 pvid, 808 u8 et_vlan) 809 { 810 MLXSW_REG_ZERO(spvid, payload); 811 mlxsw_reg_spvid_local_port_set(payload, local_port); 812 mlxsw_reg_spvid_pvid_set(payload, pvid); 813 mlxsw_reg_spvid_et_vlan_set(payload, et_vlan); 814 } 815 816 /* SPVM - Switch Port VLAN Membership 817 * ---------------------------------- 818 * The Switch Port VLAN Membership register configures the VLAN membership 819 * of a port in a VLAN denoted by VID. VLAN membership is managed per 820 * virtual port. The register can be used to add and remove VID(s) from a port. 821 */ 822 #define MLXSW_REG_SPVM_ID 0x200F 823 #define MLXSW_REG_SPVM_BASE_LEN 0x04 /* base length, without records */ 824 #define MLXSW_REG_SPVM_REC_LEN 0x04 /* record length */ 825 #define MLXSW_REG_SPVM_REC_MAX_COUNT 255 826 #define MLXSW_REG_SPVM_LEN (MLXSW_REG_SPVM_BASE_LEN + \ 827 MLXSW_REG_SPVM_REC_LEN * MLXSW_REG_SPVM_REC_MAX_COUNT) 828 829 MLXSW_REG_DEFINE(spvm, MLXSW_REG_SPVM_ID, MLXSW_REG_SPVM_LEN); 830 831 /* reg_spvm_pt 832 * Priority tagged. If this bit is set, packets forwarded to the port with 833 * untagged VLAN membership (u bit is set) will be tagged with priority tag 834 * (VID=0) 835 * Access: RW 836 */ 837 MLXSW_ITEM32(reg, spvm, pt, 0x00, 31, 1); 838 839 /* reg_spvm_pte 840 * Priority Tagged Update Enable. On Write operations, if this bit is cleared, 841 * the pt bit will NOT be updated. To update the pt bit, pte must be set. 842 * Access: WO 843 */ 844 MLXSW_ITEM32(reg, spvm, pte, 0x00, 30, 1); 845 846 /* reg_spvm_local_port 847 * Local port number. 848 * Access: Index 849 */ 850 MLXSW_ITEM32_LP(reg, spvm, 0x00, 16, 0x00, 12); 851 852 /* reg_spvm_sub_port 853 * Virtual port within the physical port. 854 * Should be set to 0 when virtual ports are not enabled on the port. 855 * Access: Index 856 */ 857 MLXSW_ITEM32(reg, spvm, sub_port, 0x00, 8, 8); 858 859 /* reg_spvm_num_rec 860 * Number of records to update. Each record contains: i, e, u, vid. 861 * Access: OP 862 */ 863 MLXSW_ITEM32(reg, spvm, num_rec, 0x00, 0, 8); 864 865 /* reg_spvm_rec_i 866 * Ingress membership in VLAN ID. 867 * Access: Index 868 */ 869 MLXSW_ITEM32_INDEXED(reg, spvm, rec_i, 870 MLXSW_REG_SPVM_BASE_LEN, 14, 1, 871 MLXSW_REG_SPVM_REC_LEN, 0, false); 872 873 /* reg_spvm_rec_e 874 * Egress membership in VLAN ID. 875 * Access: Index 876 */ 877 MLXSW_ITEM32_INDEXED(reg, spvm, rec_e, 878 MLXSW_REG_SPVM_BASE_LEN, 13, 1, 879 MLXSW_REG_SPVM_REC_LEN, 0, false); 880 881 /* reg_spvm_rec_u 882 * Untagged - port is an untagged member - egress transmission uses untagged 883 * frames on VID<n> 884 * Access: Index 885 */ 886 MLXSW_ITEM32_INDEXED(reg, spvm, rec_u, 887 MLXSW_REG_SPVM_BASE_LEN, 12, 1, 888 MLXSW_REG_SPVM_REC_LEN, 0, false); 889 890 /* reg_spvm_rec_vid 891 * Egress membership in VLAN ID. 892 * Access: Index 893 */ 894 MLXSW_ITEM32_INDEXED(reg, spvm, rec_vid, 895 MLXSW_REG_SPVM_BASE_LEN, 0, 12, 896 MLXSW_REG_SPVM_REC_LEN, 0, false); 897 898 static inline void mlxsw_reg_spvm_pack(char *payload, u16 local_port, 899 u16 vid_begin, u16 vid_end, 900 bool is_member, bool untagged) 901 { 902 int size = vid_end - vid_begin + 1; 903 int i; 904 905 MLXSW_REG_ZERO(spvm, payload); 906 mlxsw_reg_spvm_local_port_set(payload, local_port); 907 mlxsw_reg_spvm_num_rec_set(payload, size); 908 909 for (i = 0; i < size; i++) { 910 mlxsw_reg_spvm_rec_i_set(payload, i, is_member); 911 mlxsw_reg_spvm_rec_e_set(payload, i, is_member); 912 mlxsw_reg_spvm_rec_u_set(payload, i, untagged); 913 mlxsw_reg_spvm_rec_vid_set(payload, i, vid_begin + i); 914 } 915 } 916 917 /* SPAFT - Switch Port Acceptable Frame Types 918 * ------------------------------------------ 919 * The Switch Port Acceptable Frame Types register configures the frame 920 * admittance of the port. 921 */ 922 #define MLXSW_REG_SPAFT_ID 0x2010 923 #define MLXSW_REG_SPAFT_LEN 0x08 924 925 MLXSW_REG_DEFINE(spaft, MLXSW_REG_SPAFT_ID, MLXSW_REG_SPAFT_LEN); 926 927 /* reg_spaft_local_port 928 * Local port number. 929 * Access: Index 930 * 931 * Note: CPU port is not supported (all tag types are allowed). 932 */ 933 MLXSW_ITEM32_LP(reg, spaft, 0x00, 16, 0x00, 12); 934 935 /* reg_spaft_sub_port 936 * Virtual port within the physical port. 937 * Should be set to 0 when virtual ports are not enabled on the port. 938 * Access: RW 939 */ 940 MLXSW_ITEM32(reg, spaft, sub_port, 0x00, 8, 8); 941 942 /* reg_spaft_allow_untagged 943 * When set, untagged frames on the ingress are allowed (default). 944 * Access: RW 945 */ 946 MLXSW_ITEM32(reg, spaft, allow_untagged, 0x04, 31, 1); 947 948 /* reg_spaft_allow_prio_tagged 949 * When set, priority tagged frames on the ingress are allowed (default). 950 * Access: RW 951 */ 952 MLXSW_ITEM32(reg, spaft, allow_prio_tagged, 0x04, 30, 1); 953 954 /* reg_spaft_allow_tagged 955 * When set, tagged frames on the ingress are allowed (default). 956 * Access: RW 957 */ 958 MLXSW_ITEM32(reg, spaft, allow_tagged, 0x04, 29, 1); 959 960 static inline void mlxsw_reg_spaft_pack(char *payload, u16 local_port, 961 bool allow_untagged) 962 { 963 MLXSW_REG_ZERO(spaft, payload); 964 mlxsw_reg_spaft_local_port_set(payload, local_port); 965 mlxsw_reg_spaft_allow_untagged_set(payload, allow_untagged); 966 mlxsw_reg_spaft_allow_prio_tagged_set(payload, allow_untagged); 967 mlxsw_reg_spaft_allow_tagged_set(payload, true); 968 } 969 970 /* SFGC - Switch Flooding Group Configuration 971 * ------------------------------------------ 972 * The following register controls the association of flooding tables and MIDs 973 * to packet types used for flooding. 974 */ 975 #define MLXSW_REG_SFGC_ID 0x2011 976 #define MLXSW_REG_SFGC_LEN 0x10 977 978 MLXSW_REG_DEFINE(sfgc, MLXSW_REG_SFGC_ID, MLXSW_REG_SFGC_LEN); 979 980 enum mlxsw_reg_sfgc_type { 981 MLXSW_REG_SFGC_TYPE_BROADCAST, 982 MLXSW_REG_SFGC_TYPE_UNKNOWN_UNICAST, 983 MLXSW_REG_SFGC_TYPE_UNREGISTERED_MULTICAST_IPV4, 984 MLXSW_REG_SFGC_TYPE_UNREGISTERED_MULTICAST_IPV6, 985 MLXSW_REG_SFGC_TYPE_RESERVED, 986 MLXSW_REG_SFGC_TYPE_UNREGISTERED_MULTICAST_NON_IP, 987 MLXSW_REG_SFGC_TYPE_IPV4_LINK_LOCAL, 988 MLXSW_REG_SFGC_TYPE_IPV6_ALL_HOST, 989 MLXSW_REG_SFGC_TYPE_MAX, 990 }; 991 992 /* reg_sfgc_type 993 * The traffic type to reach the flooding table. 994 * Access: Index 995 */ 996 MLXSW_ITEM32(reg, sfgc, type, 0x00, 0, 4); 997 998 enum mlxsw_reg_sfgc_bridge_type { 999 MLXSW_REG_SFGC_BRIDGE_TYPE_1Q_FID = 0, 1000 MLXSW_REG_SFGC_BRIDGE_TYPE_VFID = 1, 1001 }; 1002 1003 /* reg_sfgc_bridge_type 1004 * Access: Index 1005 * 1006 * Note: SwitchX-2 only supports 802.1Q mode. 1007 */ 1008 MLXSW_ITEM32(reg, sfgc, bridge_type, 0x04, 24, 3); 1009 1010 enum mlxsw_flood_table_type { 1011 MLXSW_REG_SFGC_TABLE_TYPE_VID = 1, 1012 MLXSW_REG_SFGC_TABLE_TYPE_SINGLE = 2, 1013 MLXSW_REG_SFGC_TABLE_TYPE_ANY = 0, 1014 MLXSW_REG_SFGC_TABLE_TYPE_FID_OFFSET = 3, 1015 MLXSW_REG_SFGC_TABLE_TYPE_FID = 4, 1016 }; 1017 1018 /* reg_sfgc_table_type 1019 * See mlxsw_flood_table_type 1020 * Access: RW 1021 * 1022 * Note: FID offset and FID types are not supported in SwitchX-2. 1023 */ 1024 MLXSW_ITEM32(reg, sfgc, table_type, 0x04, 16, 3); 1025 1026 /* reg_sfgc_flood_table 1027 * Flooding table index to associate with the specific type on the specific 1028 * switch partition. 1029 * Access: RW 1030 */ 1031 MLXSW_ITEM32(reg, sfgc, flood_table, 0x04, 0, 6); 1032 1033 /* reg_sfgc_mid 1034 * The multicast ID for the swid. Not supported for Spectrum 1035 * Access: RW 1036 */ 1037 MLXSW_ITEM32(reg, sfgc, mid, 0x08, 0, 16); 1038 1039 /* reg_sfgc_counter_set_type 1040 * Counter Set Type for flow counters. 1041 * Access: RW 1042 */ 1043 MLXSW_ITEM32(reg, sfgc, counter_set_type, 0x0C, 24, 8); 1044 1045 /* reg_sfgc_counter_index 1046 * Counter Index for flow counters. 1047 * Access: RW 1048 */ 1049 MLXSW_ITEM32(reg, sfgc, counter_index, 0x0C, 0, 24); 1050 1051 static inline void 1052 mlxsw_reg_sfgc_pack(char *payload, enum mlxsw_reg_sfgc_type type, 1053 enum mlxsw_reg_sfgc_bridge_type bridge_type, 1054 enum mlxsw_flood_table_type table_type, 1055 unsigned int flood_table) 1056 { 1057 MLXSW_REG_ZERO(sfgc, payload); 1058 mlxsw_reg_sfgc_type_set(payload, type); 1059 mlxsw_reg_sfgc_bridge_type_set(payload, bridge_type); 1060 mlxsw_reg_sfgc_table_type_set(payload, table_type); 1061 mlxsw_reg_sfgc_flood_table_set(payload, flood_table); 1062 mlxsw_reg_sfgc_mid_set(payload, MLXSW_PORT_MID); 1063 } 1064 1065 /* SFDF - Switch Filtering DB Flush 1066 * -------------------------------- 1067 * The switch filtering DB flush register is used to flush the FDB. 1068 * Note that FDB notifications are flushed as well. 1069 */ 1070 #define MLXSW_REG_SFDF_ID 0x2013 1071 #define MLXSW_REG_SFDF_LEN 0x14 1072 1073 MLXSW_REG_DEFINE(sfdf, MLXSW_REG_SFDF_ID, MLXSW_REG_SFDF_LEN); 1074 1075 /* reg_sfdf_swid 1076 * Switch partition ID. 1077 * Access: Index 1078 */ 1079 MLXSW_ITEM32(reg, sfdf, swid, 0x00, 24, 8); 1080 1081 enum mlxsw_reg_sfdf_flush_type { 1082 MLXSW_REG_SFDF_FLUSH_PER_SWID, 1083 MLXSW_REG_SFDF_FLUSH_PER_FID, 1084 MLXSW_REG_SFDF_FLUSH_PER_PORT, 1085 MLXSW_REG_SFDF_FLUSH_PER_PORT_AND_FID, 1086 MLXSW_REG_SFDF_FLUSH_PER_LAG, 1087 MLXSW_REG_SFDF_FLUSH_PER_LAG_AND_FID, 1088 MLXSW_REG_SFDF_FLUSH_PER_NVE, 1089 MLXSW_REG_SFDF_FLUSH_PER_NVE_AND_FID, 1090 }; 1091 1092 /* reg_sfdf_flush_type 1093 * Flush type. 1094 * 0 - All SWID dynamic entries are flushed. 1095 * 1 - All FID dynamic entries are flushed. 1096 * 2 - All dynamic entries pointing to port are flushed. 1097 * 3 - All FID dynamic entries pointing to port are flushed. 1098 * 4 - All dynamic entries pointing to LAG are flushed. 1099 * 5 - All FID dynamic entries pointing to LAG are flushed. 1100 * 6 - All entries of type "Unicast Tunnel" or "Multicast Tunnel" are 1101 * flushed. 1102 * 7 - All entries of type "Unicast Tunnel" or "Multicast Tunnel" are 1103 * flushed, per FID. 1104 * Access: RW 1105 */ 1106 MLXSW_ITEM32(reg, sfdf, flush_type, 0x04, 28, 4); 1107 1108 /* reg_sfdf_flush_static 1109 * Static. 1110 * 0 - Flush only dynamic entries. 1111 * 1 - Flush both dynamic and static entries. 1112 * Access: RW 1113 */ 1114 MLXSW_ITEM32(reg, sfdf, flush_static, 0x04, 24, 1); 1115 1116 static inline void mlxsw_reg_sfdf_pack(char *payload, 1117 enum mlxsw_reg_sfdf_flush_type type) 1118 { 1119 MLXSW_REG_ZERO(sfdf, payload); 1120 mlxsw_reg_sfdf_flush_type_set(payload, type); 1121 mlxsw_reg_sfdf_flush_static_set(payload, true); 1122 } 1123 1124 /* reg_sfdf_fid 1125 * FID to flush. 1126 * Access: RW 1127 */ 1128 MLXSW_ITEM32(reg, sfdf, fid, 0x0C, 0, 16); 1129 1130 /* reg_sfdf_system_port 1131 * Port to flush. 1132 * Access: RW 1133 */ 1134 MLXSW_ITEM32(reg, sfdf, system_port, 0x0C, 0, 16); 1135 1136 /* reg_sfdf_port_fid_system_port 1137 * Port to flush, pointed to by FID. 1138 * Access: RW 1139 */ 1140 MLXSW_ITEM32(reg, sfdf, port_fid_system_port, 0x08, 0, 16); 1141 1142 /* reg_sfdf_lag_id 1143 * LAG ID to flush. 1144 * Access: RW 1145 */ 1146 MLXSW_ITEM32(reg, sfdf, lag_id, 0x0C, 0, 10); 1147 1148 /* reg_sfdf_lag_fid_lag_id 1149 * LAG ID to flush, pointed to by FID. 1150 * Access: RW 1151 */ 1152 MLXSW_ITEM32(reg, sfdf, lag_fid_lag_id, 0x08, 0, 10); 1153 1154 /* SLDR - Switch LAG Descriptor Register 1155 * ----------------------------------------- 1156 * The switch LAG descriptor register is populated by LAG descriptors. 1157 * Each LAG descriptor is indexed by lag_id. The LAG ID runs from 0 to 1158 * max_lag-1. 1159 */ 1160 #define MLXSW_REG_SLDR_ID 0x2014 1161 #define MLXSW_REG_SLDR_LEN 0x0C /* counting in only one port in list */ 1162 1163 MLXSW_REG_DEFINE(sldr, MLXSW_REG_SLDR_ID, MLXSW_REG_SLDR_LEN); 1164 1165 enum mlxsw_reg_sldr_op { 1166 /* Indicates a creation of a new LAG-ID, lag_id must be valid */ 1167 MLXSW_REG_SLDR_OP_LAG_CREATE, 1168 MLXSW_REG_SLDR_OP_LAG_DESTROY, 1169 /* Ports that appear in the list have the Distributor enabled */ 1170 MLXSW_REG_SLDR_OP_LAG_ADD_PORT_LIST, 1171 /* Removes ports from the disributor list */ 1172 MLXSW_REG_SLDR_OP_LAG_REMOVE_PORT_LIST, 1173 }; 1174 1175 /* reg_sldr_op 1176 * Operation. 1177 * Access: RW 1178 */ 1179 MLXSW_ITEM32(reg, sldr, op, 0x00, 29, 3); 1180 1181 /* reg_sldr_lag_id 1182 * LAG identifier. The lag_id is the index into the LAG descriptor table. 1183 * Access: Index 1184 */ 1185 MLXSW_ITEM32(reg, sldr, lag_id, 0x00, 0, 10); 1186 1187 static inline void mlxsw_reg_sldr_lag_create_pack(char *payload, u8 lag_id) 1188 { 1189 MLXSW_REG_ZERO(sldr, payload); 1190 mlxsw_reg_sldr_op_set(payload, MLXSW_REG_SLDR_OP_LAG_CREATE); 1191 mlxsw_reg_sldr_lag_id_set(payload, lag_id); 1192 } 1193 1194 static inline void mlxsw_reg_sldr_lag_destroy_pack(char *payload, u8 lag_id) 1195 { 1196 MLXSW_REG_ZERO(sldr, payload); 1197 mlxsw_reg_sldr_op_set(payload, MLXSW_REG_SLDR_OP_LAG_DESTROY); 1198 mlxsw_reg_sldr_lag_id_set(payload, lag_id); 1199 } 1200 1201 /* reg_sldr_num_ports 1202 * The number of member ports of the LAG. 1203 * Reserved for Create / Destroy operations 1204 * For Add / Remove operations - indicates the number of ports in the list. 1205 * Access: RW 1206 */ 1207 MLXSW_ITEM32(reg, sldr, num_ports, 0x04, 24, 8); 1208 1209 /* reg_sldr_system_port 1210 * System port. 1211 * Access: RW 1212 */ 1213 MLXSW_ITEM32_INDEXED(reg, sldr, system_port, 0x08, 0, 16, 4, 0, false); 1214 1215 static inline void mlxsw_reg_sldr_lag_add_port_pack(char *payload, u8 lag_id, 1216 u16 local_port) 1217 { 1218 MLXSW_REG_ZERO(sldr, payload); 1219 mlxsw_reg_sldr_op_set(payload, MLXSW_REG_SLDR_OP_LAG_ADD_PORT_LIST); 1220 mlxsw_reg_sldr_lag_id_set(payload, lag_id); 1221 mlxsw_reg_sldr_num_ports_set(payload, 1); 1222 mlxsw_reg_sldr_system_port_set(payload, 0, local_port); 1223 } 1224 1225 static inline void mlxsw_reg_sldr_lag_remove_port_pack(char *payload, u8 lag_id, 1226 u16 local_port) 1227 { 1228 MLXSW_REG_ZERO(sldr, payload); 1229 mlxsw_reg_sldr_op_set(payload, MLXSW_REG_SLDR_OP_LAG_REMOVE_PORT_LIST); 1230 mlxsw_reg_sldr_lag_id_set(payload, lag_id); 1231 mlxsw_reg_sldr_num_ports_set(payload, 1); 1232 mlxsw_reg_sldr_system_port_set(payload, 0, local_port); 1233 } 1234 1235 /* SLCR - Switch LAG Configuration 2 Register 1236 * ------------------------------------------- 1237 * The Switch LAG Configuration register is used for configuring the 1238 * LAG properties of the switch. 1239 */ 1240 #define MLXSW_REG_SLCR_ID 0x2015 1241 #define MLXSW_REG_SLCR_LEN 0x10 1242 1243 MLXSW_REG_DEFINE(slcr, MLXSW_REG_SLCR_ID, MLXSW_REG_SLCR_LEN); 1244 1245 enum mlxsw_reg_slcr_pp { 1246 /* Global Configuration (for all ports) */ 1247 MLXSW_REG_SLCR_PP_GLOBAL, 1248 /* Per port configuration, based on local_port field */ 1249 MLXSW_REG_SLCR_PP_PER_PORT, 1250 }; 1251 1252 /* reg_slcr_pp 1253 * Per Port Configuration 1254 * Note: Reading at Global mode results in reading port 1 configuration. 1255 * Access: Index 1256 */ 1257 MLXSW_ITEM32(reg, slcr, pp, 0x00, 24, 1); 1258 1259 /* reg_slcr_local_port 1260 * Local port number 1261 * Supported from CPU port 1262 * Not supported from router port 1263 * Reserved when pp = Global Configuration 1264 * Access: Index 1265 */ 1266 MLXSW_ITEM32_LP(reg, slcr, 0x00, 16, 0x00, 12); 1267 1268 enum mlxsw_reg_slcr_type { 1269 MLXSW_REG_SLCR_TYPE_CRC, /* default */ 1270 MLXSW_REG_SLCR_TYPE_XOR, 1271 MLXSW_REG_SLCR_TYPE_RANDOM, 1272 }; 1273 1274 /* reg_slcr_type 1275 * Hash type 1276 * Access: RW 1277 */ 1278 MLXSW_ITEM32(reg, slcr, type, 0x00, 0, 4); 1279 1280 /* Ingress port */ 1281 #define MLXSW_REG_SLCR_LAG_HASH_IN_PORT BIT(0) 1282 /* SMAC - for IPv4 and IPv6 packets */ 1283 #define MLXSW_REG_SLCR_LAG_HASH_SMAC_IP BIT(1) 1284 /* SMAC - for non-IP packets */ 1285 #define MLXSW_REG_SLCR_LAG_HASH_SMAC_NONIP BIT(2) 1286 #define MLXSW_REG_SLCR_LAG_HASH_SMAC \ 1287 (MLXSW_REG_SLCR_LAG_HASH_SMAC_IP | \ 1288 MLXSW_REG_SLCR_LAG_HASH_SMAC_NONIP) 1289 /* DMAC - for IPv4 and IPv6 packets */ 1290 #define MLXSW_REG_SLCR_LAG_HASH_DMAC_IP BIT(3) 1291 /* DMAC - for non-IP packets */ 1292 #define MLXSW_REG_SLCR_LAG_HASH_DMAC_NONIP BIT(4) 1293 #define MLXSW_REG_SLCR_LAG_HASH_DMAC \ 1294 (MLXSW_REG_SLCR_LAG_HASH_DMAC_IP | \ 1295 MLXSW_REG_SLCR_LAG_HASH_DMAC_NONIP) 1296 /* Ethertype - for IPv4 and IPv6 packets */ 1297 #define MLXSW_REG_SLCR_LAG_HASH_ETHERTYPE_IP BIT(5) 1298 /* Ethertype - for non-IP packets */ 1299 #define MLXSW_REG_SLCR_LAG_HASH_ETHERTYPE_NONIP BIT(6) 1300 #define MLXSW_REG_SLCR_LAG_HASH_ETHERTYPE \ 1301 (MLXSW_REG_SLCR_LAG_HASH_ETHERTYPE_IP | \ 1302 MLXSW_REG_SLCR_LAG_HASH_ETHERTYPE_NONIP) 1303 /* VLAN ID - for IPv4 and IPv6 packets */ 1304 #define MLXSW_REG_SLCR_LAG_HASH_VLANID_IP BIT(7) 1305 /* VLAN ID - for non-IP packets */ 1306 #define MLXSW_REG_SLCR_LAG_HASH_VLANID_NONIP BIT(8) 1307 #define MLXSW_REG_SLCR_LAG_HASH_VLANID \ 1308 (MLXSW_REG_SLCR_LAG_HASH_VLANID_IP | \ 1309 MLXSW_REG_SLCR_LAG_HASH_VLANID_NONIP) 1310 /* Source IP address (can be IPv4 or IPv6) */ 1311 #define MLXSW_REG_SLCR_LAG_HASH_SIP BIT(9) 1312 /* Destination IP address (can be IPv4 or IPv6) */ 1313 #define MLXSW_REG_SLCR_LAG_HASH_DIP BIT(10) 1314 /* TCP/UDP source port */ 1315 #define MLXSW_REG_SLCR_LAG_HASH_SPORT BIT(11) 1316 /* TCP/UDP destination port*/ 1317 #define MLXSW_REG_SLCR_LAG_HASH_DPORT BIT(12) 1318 /* IPv4 Protocol/IPv6 Next Header */ 1319 #define MLXSW_REG_SLCR_LAG_HASH_IPPROTO BIT(13) 1320 /* IPv6 Flow label */ 1321 #define MLXSW_REG_SLCR_LAG_HASH_FLOWLABEL BIT(14) 1322 /* SID - FCoE source ID */ 1323 #define MLXSW_REG_SLCR_LAG_HASH_FCOE_SID BIT(15) 1324 /* DID - FCoE destination ID */ 1325 #define MLXSW_REG_SLCR_LAG_HASH_FCOE_DID BIT(16) 1326 /* OXID - FCoE originator exchange ID */ 1327 #define MLXSW_REG_SLCR_LAG_HASH_FCOE_OXID BIT(17) 1328 /* Destination QP number - for RoCE packets */ 1329 #define MLXSW_REG_SLCR_LAG_HASH_ROCE_DQP BIT(19) 1330 1331 /* reg_slcr_lag_hash 1332 * LAG hashing configuration. This is a bitmask, in which each set 1333 * bit includes the corresponding item in the LAG hash calculation. 1334 * The default lag_hash contains SMAC, DMAC, VLANID and 1335 * Ethertype (for all packet types). 1336 * Access: RW 1337 */ 1338 MLXSW_ITEM32(reg, slcr, lag_hash, 0x04, 0, 20); 1339 1340 /* reg_slcr_seed 1341 * LAG seed value. The seed is the same for all ports. 1342 * Access: RW 1343 */ 1344 MLXSW_ITEM32(reg, slcr, seed, 0x08, 0, 32); 1345 1346 static inline void mlxsw_reg_slcr_pack(char *payload, u16 lag_hash, u32 seed) 1347 { 1348 MLXSW_REG_ZERO(slcr, payload); 1349 mlxsw_reg_slcr_pp_set(payload, MLXSW_REG_SLCR_PP_GLOBAL); 1350 mlxsw_reg_slcr_type_set(payload, MLXSW_REG_SLCR_TYPE_CRC); 1351 mlxsw_reg_slcr_lag_hash_set(payload, lag_hash); 1352 mlxsw_reg_slcr_seed_set(payload, seed); 1353 } 1354 1355 /* SLCOR - Switch LAG Collector Register 1356 * ------------------------------------- 1357 * The Switch LAG Collector register controls the Local Port membership 1358 * in a LAG and enablement of the collector. 1359 */ 1360 #define MLXSW_REG_SLCOR_ID 0x2016 1361 #define MLXSW_REG_SLCOR_LEN 0x10 1362 1363 MLXSW_REG_DEFINE(slcor, MLXSW_REG_SLCOR_ID, MLXSW_REG_SLCOR_LEN); 1364 1365 enum mlxsw_reg_slcor_col { 1366 /* Port is added with collector disabled */ 1367 MLXSW_REG_SLCOR_COL_LAG_ADD_PORT, 1368 MLXSW_REG_SLCOR_COL_LAG_COLLECTOR_ENABLED, 1369 MLXSW_REG_SLCOR_COL_LAG_COLLECTOR_DISABLED, 1370 MLXSW_REG_SLCOR_COL_LAG_REMOVE_PORT, 1371 }; 1372 1373 /* reg_slcor_col 1374 * Collector configuration 1375 * Access: RW 1376 */ 1377 MLXSW_ITEM32(reg, slcor, col, 0x00, 30, 2); 1378 1379 /* reg_slcor_local_port 1380 * Local port number 1381 * Not supported for CPU port 1382 * Access: Index 1383 */ 1384 MLXSW_ITEM32_LP(reg, slcor, 0x00, 16, 0x00, 12); 1385 1386 /* reg_slcor_lag_id 1387 * LAG Identifier. Index into the LAG descriptor table. 1388 * Access: Index 1389 */ 1390 MLXSW_ITEM32(reg, slcor, lag_id, 0x00, 0, 10); 1391 1392 /* reg_slcor_port_index 1393 * Port index in the LAG list. Only valid on Add Port to LAG col. 1394 * Valid range is from 0 to cap_max_lag_members-1 1395 * Access: RW 1396 */ 1397 MLXSW_ITEM32(reg, slcor, port_index, 0x04, 0, 10); 1398 1399 static inline void mlxsw_reg_slcor_pack(char *payload, 1400 u16 local_port, u16 lag_id, 1401 enum mlxsw_reg_slcor_col col) 1402 { 1403 MLXSW_REG_ZERO(slcor, payload); 1404 mlxsw_reg_slcor_col_set(payload, col); 1405 mlxsw_reg_slcor_local_port_set(payload, local_port); 1406 mlxsw_reg_slcor_lag_id_set(payload, lag_id); 1407 } 1408 1409 static inline void mlxsw_reg_slcor_port_add_pack(char *payload, 1410 u16 local_port, u16 lag_id, 1411 u8 port_index) 1412 { 1413 mlxsw_reg_slcor_pack(payload, local_port, lag_id, 1414 MLXSW_REG_SLCOR_COL_LAG_ADD_PORT); 1415 mlxsw_reg_slcor_port_index_set(payload, port_index); 1416 } 1417 1418 static inline void mlxsw_reg_slcor_port_remove_pack(char *payload, 1419 u16 local_port, u16 lag_id) 1420 { 1421 mlxsw_reg_slcor_pack(payload, local_port, lag_id, 1422 MLXSW_REG_SLCOR_COL_LAG_REMOVE_PORT); 1423 } 1424 1425 static inline void mlxsw_reg_slcor_col_enable_pack(char *payload, 1426 u16 local_port, u16 lag_id) 1427 { 1428 mlxsw_reg_slcor_pack(payload, local_port, lag_id, 1429 MLXSW_REG_SLCOR_COL_LAG_COLLECTOR_ENABLED); 1430 } 1431 1432 static inline void mlxsw_reg_slcor_col_disable_pack(char *payload, 1433 u16 local_port, u16 lag_id) 1434 { 1435 mlxsw_reg_slcor_pack(payload, local_port, lag_id, 1436 MLXSW_REG_SLCOR_COL_LAG_COLLECTOR_ENABLED); 1437 } 1438 1439 /* SPMLR - Switch Port MAC Learning Register 1440 * ----------------------------------------- 1441 * Controls the Switch MAC learning policy per port. 1442 */ 1443 #define MLXSW_REG_SPMLR_ID 0x2018 1444 #define MLXSW_REG_SPMLR_LEN 0x8 1445 1446 MLXSW_REG_DEFINE(spmlr, MLXSW_REG_SPMLR_ID, MLXSW_REG_SPMLR_LEN); 1447 1448 /* reg_spmlr_local_port 1449 * Local port number. 1450 * Access: Index 1451 */ 1452 MLXSW_ITEM32_LP(reg, spmlr, 0x00, 16, 0x00, 12); 1453 1454 /* reg_spmlr_sub_port 1455 * Virtual port within the physical port. 1456 * Should be set to 0 when virtual ports are not enabled on the port. 1457 * Access: Index 1458 */ 1459 MLXSW_ITEM32(reg, spmlr, sub_port, 0x00, 8, 8); 1460 1461 enum mlxsw_reg_spmlr_learn_mode { 1462 MLXSW_REG_SPMLR_LEARN_MODE_DISABLE = 0, 1463 MLXSW_REG_SPMLR_LEARN_MODE_ENABLE = 2, 1464 MLXSW_REG_SPMLR_LEARN_MODE_SEC = 3, 1465 }; 1466 1467 /* reg_spmlr_learn_mode 1468 * Learning mode on the port. 1469 * 0 - Learning disabled. 1470 * 2 - Learning enabled. 1471 * 3 - Security mode. 1472 * 1473 * In security mode the switch does not learn MACs on the port, but uses the 1474 * SMAC to see if it exists on another ingress port. If so, the packet is 1475 * classified as a bad packet and is discarded unless the software registers 1476 * to receive port security error packets usign HPKT. 1477 */ 1478 MLXSW_ITEM32(reg, spmlr, learn_mode, 0x04, 30, 2); 1479 1480 static inline void mlxsw_reg_spmlr_pack(char *payload, u16 local_port, 1481 enum mlxsw_reg_spmlr_learn_mode mode) 1482 { 1483 MLXSW_REG_ZERO(spmlr, payload); 1484 mlxsw_reg_spmlr_local_port_set(payload, local_port); 1485 mlxsw_reg_spmlr_sub_port_set(payload, 0); 1486 mlxsw_reg_spmlr_learn_mode_set(payload, mode); 1487 } 1488 1489 /* SVFA - Switch VID to FID Allocation Register 1490 * -------------------------------------------- 1491 * Controls the VID to FID mapping and {Port, VID} to FID mapping for 1492 * virtualized ports. 1493 */ 1494 #define MLXSW_REG_SVFA_ID 0x201C 1495 #define MLXSW_REG_SVFA_LEN 0x10 1496 1497 MLXSW_REG_DEFINE(svfa, MLXSW_REG_SVFA_ID, MLXSW_REG_SVFA_LEN); 1498 1499 /* reg_svfa_swid 1500 * Switch partition ID. 1501 * Access: Index 1502 */ 1503 MLXSW_ITEM32(reg, svfa, swid, 0x00, 24, 8); 1504 1505 /* reg_svfa_local_port 1506 * Local port number. 1507 * Access: Index 1508 * 1509 * Note: Reserved for 802.1Q FIDs. 1510 */ 1511 MLXSW_ITEM32_LP(reg, svfa, 0x00, 16, 0x00, 12); 1512 1513 enum mlxsw_reg_svfa_mt { 1514 MLXSW_REG_SVFA_MT_VID_TO_FID, 1515 MLXSW_REG_SVFA_MT_PORT_VID_TO_FID, 1516 }; 1517 1518 /* reg_svfa_mapping_table 1519 * Mapping table: 1520 * 0 - VID to FID 1521 * 1 - {Port, VID} to FID 1522 * Access: Index 1523 * 1524 * Note: Reserved for SwitchX-2. 1525 */ 1526 MLXSW_ITEM32(reg, svfa, mapping_table, 0x00, 8, 3); 1527 1528 /* reg_svfa_v 1529 * Valid. 1530 * Valid if set. 1531 * Access: RW 1532 * 1533 * Note: Reserved for SwitchX-2. 1534 */ 1535 MLXSW_ITEM32(reg, svfa, v, 0x00, 0, 1); 1536 1537 /* reg_svfa_fid 1538 * Filtering ID. 1539 * Access: RW 1540 */ 1541 MLXSW_ITEM32(reg, svfa, fid, 0x04, 16, 16); 1542 1543 /* reg_svfa_vid 1544 * VLAN ID. 1545 * Access: Index 1546 */ 1547 MLXSW_ITEM32(reg, svfa, vid, 0x04, 0, 12); 1548 1549 /* reg_svfa_counter_set_type 1550 * Counter set type for flow counters. 1551 * Access: RW 1552 * 1553 * Note: Reserved for SwitchX-2. 1554 */ 1555 MLXSW_ITEM32(reg, svfa, counter_set_type, 0x08, 24, 8); 1556 1557 /* reg_svfa_counter_index 1558 * Counter index for flow counters. 1559 * Access: RW 1560 * 1561 * Note: Reserved for SwitchX-2. 1562 */ 1563 MLXSW_ITEM32(reg, svfa, counter_index, 0x08, 0, 24); 1564 1565 static inline void mlxsw_reg_svfa_pack(char *payload, u16 local_port, 1566 enum mlxsw_reg_svfa_mt mt, bool valid, 1567 u16 fid, u16 vid) 1568 { 1569 MLXSW_REG_ZERO(svfa, payload); 1570 local_port = mt == MLXSW_REG_SVFA_MT_VID_TO_FID ? 0 : local_port; 1571 mlxsw_reg_svfa_swid_set(payload, 0); 1572 mlxsw_reg_svfa_local_port_set(payload, local_port); 1573 mlxsw_reg_svfa_mapping_table_set(payload, mt); 1574 mlxsw_reg_svfa_v_set(payload, valid); 1575 mlxsw_reg_svfa_fid_set(payload, fid); 1576 mlxsw_reg_svfa_vid_set(payload, vid); 1577 } 1578 1579 /* SPVTR - Switch Port VLAN Stacking Register 1580 * ------------------------------------------ 1581 * The Switch Port VLAN Stacking register configures the VLAN mode of the port 1582 * to enable VLAN stacking. 1583 */ 1584 #define MLXSW_REG_SPVTR_ID 0x201D 1585 #define MLXSW_REG_SPVTR_LEN 0x10 1586 1587 MLXSW_REG_DEFINE(spvtr, MLXSW_REG_SPVTR_ID, MLXSW_REG_SPVTR_LEN); 1588 1589 /* reg_spvtr_tport 1590 * Port is tunnel port. 1591 * Access: Index 1592 * 1593 * Note: Reserved when SwitchX/-2 or Spectrum-1. 1594 */ 1595 MLXSW_ITEM32(reg, spvtr, tport, 0x00, 24, 1); 1596 1597 /* reg_spvtr_local_port 1598 * When tport = 0: local port number (Not supported from/to CPU). 1599 * When tport = 1: tunnel port. 1600 * Access: Index 1601 */ 1602 MLXSW_ITEM32_LP(reg, spvtr, 0x00, 16, 0x00, 12); 1603 1604 /* reg_spvtr_ippe 1605 * Ingress Port Prio Mode Update Enable. 1606 * When set, the Port Prio Mode is updated with the provided ipprio_mode field. 1607 * Reserved on Get operations. 1608 * Access: OP 1609 */ 1610 MLXSW_ITEM32(reg, spvtr, ippe, 0x04, 31, 1); 1611 1612 /* reg_spvtr_ipve 1613 * Ingress Port VID Mode Update Enable. 1614 * When set, the Ingress Port VID Mode is updated with the provided ipvid_mode 1615 * field. 1616 * Reserved on Get operations. 1617 * Access: OP 1618 */ 1619 MLXSW_ITEM32(reg, spvtr, ipve, 0x04, 30, 1); 1620 1621 /* reg_spvtr_epve 1622 * Egress Port VID Mode Update Enable. 1623 * When set, the Egress Port VID Mode is updated with the provided epvid_mode 1624 * field. 1625 * Access: OP 1626 */ 1627 MLXSW_ITEM32(reg, spvtr, epve, 0x04, 29, 1); 1628 1629 /* reg_spvtr_ipprio_mode 1630 * Ingress Port Priority Mode. 1631 * This controls the PCP and DEI of the new outer VLAN 1632 * Note: for SwitchX/-2 the DEI is not affected. 1633 * 0: use port default PCP and DEI (configured by QPDPC). 1634 * 1: use C-VLAN PCP and DEI. 1635 * Has no effect when ipvid_mode = 0. 1636 * Reserved when tport = 1. 1637 * Access: RW 1638 */ 1639 MLXSW_ITEM32(reg, spvtr, ipprio_mode, 0x04, 20, 4); 1640 1641 enum mlxsw_reg_spvtr_ipvid_mode { 1642 /* IEEE Compliant PVID (default) */ 1643 MLXSW_REG_SPVTR_IPVID_MODE_IEEE_COMPLIANT_PVID, 1644 /* Push VLAN (for VLAN stacking, except prio tagged packets) */ 1645 MLXSW_REG_SPVTR_IPVID_MODE_PUSH_VLAN_FOR_UNTAGGED_PACKET, 1646 /* Always push VLAN (also for prio tagged packets) */ 1647 MLXSW_REG_SPVTR_IPVID_MODE_ALWAYS_PUSH_VLAN, 1648 }; 1649 1650 /* reg_spvtr_ipvid_mode 1651 * Ingress Port VLAN-ID Mode. 1652 * For Spectrum family, this affects the values of SPVM.i 1653 * Access: RW 1654 */ 1655 MLXSW_ITEM32(reg, spvtr, ipvid_mode, 0x04, 16, 4); 1656 1657 enum mlxsw_reg_spvtr_epvid_mode { 1658 /* IEEE Compliant VLAN membership */ 1659 MLXSW_REG_SPVTR_EPVID_MODE_IEEE_COMPLIANT_VLAN_MEMBERSHIP, 1660 /* Pop VLAN (for VLAN stacking) */ 1661 MLXSW_REG_SPVTR_EPVID_MODE_POP_VLAN, 1662 }; 1663 1664 /* reg_spvtr_epvid_mode 1665 * Egress Port VLAN-ID Mode. 1666 * For Spectrum family, this affects the values of SPVM.e,u,pt. 1667 * Access: WO 1668 */ 1669 MLXSW_ITEM32(reg, spvtr, epvid_mode, 0x04, 0, 4); 1670 1671 static inline void mlxsw_reg_spvtr_pack(char *payload, bool tport, 1672 u16 local_port, 1673 enum mlxsw_reg_spvtr_ipvid_mode ipvid_mode) 1674 { 1675 MLXSW_REG_ZERO(spvtr, payload); 1676 mlxsw_reg_spvtr_tport_set(payload, tport); 1677 mlxsw_reg_spvtr_local_port_set(payload, local_port); 1678 mlxsw_reg_spvtr_ipvid_mode_set(payload, ipvid_mode); 1679 mlxsw_reg_spvtr_ipve_set(payload, true); 1680 } 1681 1682 /* SVPE - Switch Virtual-Port Enabling Register 1683 * -------------------------------------------- 1684 * Enables port virtualization. 1685 */ 1686 #define MLXSW_REG_SVPE_ID 0x201E 1687 #define MLXSW_REG_SVPE_LEN 0x4 1688 1689 MLXSW_REG_DEFINE(svpe, MLXSW_REG_SVPE_ID, MLXSW_REG_SVPE_LEN); 1690 1691 /* reg_svpe_local_port 1692 * Local port number 1693 * Access: Index 1694 * 1695 * Note: CPU port is not supported (uses VLAN mode only). 1696 */ 1697 MLXSW_ITEM32_LP(reg, svpe, 0x00, 16, 0x00, 12); 1698 1699 /* reg_svpe_vp_en 1700 * Virtual port enable. 1701 * 0 - Disable, VLAN mode (VID to FID). 1702 * 1 - Enable, Virtual port mode ({Port, VID} to FID). 1703 * Access: RW 1704 */ 1705 MLXSW_ITEM32(reg, svpe, vp_en, 0x00, 8, 1); 1706 1707 static inline void mlxsw_reg_svpe_pack(char *payload, u16 local_port, 1708 bool enable) 1709 { 1710 MLXSW_REG_ZERO(svpe, payload); 1711 mlxsw_reg_svpe_local_port_set(payload, local_port); 1712 mlxsw_reg_svpe_vp_en_set(payload, enable); 1713 } 1714 1715 /* SFMR - Switch FID Management Register 1716 * ------------------------------------- 1717 * Creates and configures FIDs. 1718 */ 1719 #define MLXSW_REG_SFMR_ID 0x201F 1720 #define MLXSW_REG_SFMR_LEN 0x18 1721 1722 MLXSW_REG_DEFINE(sfmr, MLXSW_REG_SFMR_ID, MLXSW_REG_SFMR_LEN); 1723 1724 enum mlxsw_reg_sfmr_op { 1725 MLXSW_REG_SFMR_OP_CREATE_FID, 1726 MLXSW_REG_SFMR_OP_DESTROY_FID, 1727 }; 1728 1729 /* reg_sfmr_op 1730 * Operation. 1731 * 0 - Create or edit FID. 1732 * 1 - Destroy FID. 1733 * Access: WO 1734 */ 1735 MLXSW_ITEM32(reg, sfmr, op, 0x00, 24, 4); 1736 1737 /* reg_sfmr_fid 1738 * Filtering ID. 1739 * Access: Index 1740 */ 1741 MLXSW_ITEM32(reg, sfmr, fid, 0x00, 0, 16); 1742 1743 /* reg_sfmr_fid_offset 1744 * FID offset. 1745 * Used to point into the flooding table selected by SFGC register if 1746 * the table is of type FID-Offset. Otherwise, this field is reserved. 1747 * Access: RW 1748 */ 1749 MLXSW_ITEM32(reg, sfmr, fid_offset, 0x08, 0, 16); 1750 1751 /* reg_sfmr_vtfp 1752 * Valid Tunnel Flood Pointer. 1753 * If not set, then nve_tunnel_flood_ptr is reserved and considered NULL. 1754 * Access: RW 1755 * 1756 * Note: Reserved for 802.1Q FIDs. 1757 */ 1758 MLXSW_ITEM32(reg, sfmr, vtfp, 0x0C, 31, 1); 1759 1760 /* reg_sfmr_nve_tunnel_flood_ptr 1761 * Underlay Flooding and BC Pointer. 1762 * Used as a pointer to the first entry of the group based link lists of 1763 * flooding or BC entries (for NVE tunnels). 1764 * Access: RW 1765 */ 1766 MLXSW_ITEM32(reg, sfmr, nve_tunnel_flood_ptr, 0x0C, 0, 24); 1767 1768 /* reg_sfmr_vv 1769 * VNI Valid. 1770 * If not set, then vni is reserved. 1771 * Access: RW 1772 * 1773 * Note: Reserved for 802.1Q FIDs. 1774 */ 1775 MLXSW_ITEM32(reg, sfmr, vv, 0x10, 31, 1); 1776 1777 /* reg_sfmr_vni 1778 * Virtual Network Identifier. 1779 * Access: RW 1780 * 1781 * Note: A given VNI can only be assigned to one FID. 1782 */ 1783 MLXSW_ITEM32(reg, sfmr, vni, 0x10, 0, 24); 1784 1785 static inline void mlxsw_reg_sfmr_pack(char *payload, 1786 enum mlxsw_reg_sfmr_op op, u16 fid, 1787 u16 fid_offset) 1788 { 1789 MLXSW_REG_ZERO(sfmr, payload); 1790 mlxsw_reg_sfmr_op_set(payload, op); 1791 mlxsw_reg_sfmr_fid_set(payload, fid); 1792 mlxsw_reg_sfmr_fid_offset_set(payload, fid_offset); 1793 mlxsw_reg_sfmr_vtfp_set(payload, false); 1794 mlxsw_reg_sfmr_vv_set(payload, false); 1795 } 1796 1797 /* SPVMLR - Switch Port VLAN MAC Learning Register 1798 * ----------------------------------------------- 1799 * Controls the switch MAC learning policy per {Port, VID}. 1800 */ 1801 #define MLXSW_REG_SPVMLR_ID 0x2020 1802 #define MLXSW_REG_SPVMLR_BASE_LEN 0x04 /* base length, without records */ 1803 #define MLXSW_REG_SPVMLR_REC_LEN 0x04 /* record length */ 1804 #define MLXSW_REG_SPVMLR_REC_MAX_COUNT 255 1805 #define MLXSW_REG_SPVMLR_LEN (MLXSW_REG_SPVMLR_BASE_LEN + \ 1806 MLXSW_REG_SPVMLR_REC_LEN * \ 1807 MLXSW_REG_SPVMLR_REC_MAX_COUNT) 1808 1809 MLXSW_REG_DEFINE(spvmlr, MLXSW_REG_SPVMLR_ID, MLXSW_REG_SPVMLR_LEN); 1810 1811 /* reg_spvmlr_local_port 1812 * Local ingress port. 1813 * Access: Index 1814 * 1815 * Note: CPU port is not supported. 1816 */ 1817 MLXSW_ITEM32_LP(reg, spvmlr, 0x00, 16, 0x00, 12); 1818 1819 /* reg_spvmlr_num_rec 1820 * Number of records to update. 1821 * Access: OP 1822 */ 1823 MLXSW_ITEM32(reg, spvmlr, num_rec, 0x00, 0, 8); 1824 1825 /* reg_spvmlr_rec_learn_enable 1826 * 0 - Disable learning for {Port, VID}. 1827 * 1 - Enable learning for {Port, VID}. 1828 * Access: RW 1829 */ 1830 MLXSW_ITEM32_INDEXED(reg, spvmlr, rec_learn_enable, MLXSW_REG_SPVMLR_BASE_LEN, 1831 31, 1, MLXSW_REG_SPVMLR_REC_LEN, 0x00, false); 1832 1833 /* reg_spvmlr_rec_vid 1834 * VLAN ID to be added/removed from port or for querying. 1835 * Access: Index 1836 */ 1837 MLXSW_ITEM32_INDEXED(reg, spvmlr, rec_vid, MLXSW_REG_SPVMLR_BASE_LEN, 0, 12, 1838 MLXSW_REG_SPVMLR_REC_LEN, 0x00, false); 1839 1840 static inline void mlxsw_reg_spvmlr_pack(char *payload, u16 local_port, 1841 u16 vid_begin, u16 vid_end, 1842 bool learn_enable) 1843 { 1844 int num_rec = vid_end - vid_begin + 1; 1845 int i; 1846 1847 WARN_ON(num_rec < 1 || num_rec > MLXSW_REG_SPVMLR_REC_MAX_COUNT); 1848 1849 MLXSW_REG_ZERO(spvmlr, payload); 1850 mlxsw_reg_spvmlr_local_port_set(payload, local_port); 1851 mlxsw_reg_spvmlr_num_rec_set(payload, num_rec); 1852 1853 for (i = 0; i < num_rec; i++) { 1854 mlxsw_reg_spvmlr_rec_learn_enable_set(payload, i, learn_enable); 1855 mlxsw_reg_spvmlr_rec_vid_set(payload, i, vid_begin + i); 1856 } 1857 } 1858 1859 /* SPVC - Switch Port VLAN Classification Register 1860 * ----------------------------------------------- 1861 * Configures the port to identify packets as untagged / single tagged / 1862 * double packets based on the packet EtherTypes. 1863 * Ethertype IDs are configured by SVER. 1864 */ 1865 #define MLXSW_REG_SPVC_ID 0x2026 1866 #define MLXSW_REG_SPVC_LEN 0x0C 1867 1868 MLXSW_REG_DEFINE(spvc, MLXSW_REG_SPVC_ID, MLXSW_REG_SPVC_LEN); 1869 1870 /* reg_spvc_local_port 1871 * Local port. 1872 * Access: Index 1873 * 1874 * Note: applies both to Rx port and Tx port, so if a packet traverses 1875 * through Rx port i and a Tx port j then port i and port j must have the 1876 * same configuration. 1877 */ 1878 MLXSW_ITEM32_LP(reg, spvc, 0x00, 16, 0x00, 12); 1879 1880 /* reg_spvc_inner_et2 1881 * Vlan Tag1 EtherType2 enable. 1882 * Packet is initially classified as double VLAN Tag if in addition to 1883 * being classified with a tag0 VLAN Tag its tag1 EtherType value is 1884 * equal to ether_type2. 1885 * 0: disable (default) 1886 * 1: enable 1887 * Access: RW 1888 */ 1889 MLXSW_ITEM32(reg, spvc, inner_et2, 0x08, 17, 1); 1890 1891 /* reg_spvc_et2 1892 * Vlan Tag0 EtherType2 enable. 1893 * Packet is initially classified as VLAN Tag if its tag0 EtherType is 1894 * equal to ether_type2. 1895 * 0: disable (default) 1896 * 1: enable 1897 * Access: RW 1898 */ 1899 MLXSW_ITEM32(reg, spvc, et2, 0x08, 16, 1); 1900 1901 /* reg_spvc_inner_et1 1902 * Vlan Tag1 EtherType1 enable. 1903 * Packet is initially classified as double VLAN Tag if in addition to 1904 * being classified with a tag0 VLAN Tag its tag1 EtherType value is 1905 * equal to ether_type1. 1906 * 0: disable 1907 * 1: enable (default) 1908 * Access: RW 1909 */ 1910 MLXSW_ITEM32(reg, spvc, inner_et1, 0x08, 9, 1); 1911 1912 /* reg_spvc_et1 1913 * Vlan Tag0 EtherType1 enable. 1914 * Packet is initially classified as VLAN Tag if its tag0 EtherType is 1915 * equal to ether_type1. 1916 * 0: disable 1917 * 1: enable (default) 1918 * Access: RW 1919 */ 1920 MLXSW_ITEM32(reg, spvc, et1, 0x08, 8, 1); 1921 1922 /* reg_inner_et0 1923 * Vlan Tag1 EtherType0 enable. 1924 * Packet is initially classified as double VLAN Tag if in addition to 1925 * being classified with a tag0 VLAN Tag its tag1 EtherType value is 1926 * equal to ether_type0. 1927 * 0: disable 1928 * 1: enable (default) 1929 * Access: RW 1930 */ 1931 MLXSW_ITEM32(reg, spvc, inner_et0, 0x08, 1, 1); 1932 1933 /* reg_et0 1934 * Vlan Tag0 EtherType0 enable. 1935 * Packet is initially classified as VLAN Tag if its tag0 EtherType is 1936 * equal to ether_type0. 1937 * 0: disable 1938 * 1: enable (default) 1939 * Access: RW 1940 */ 1941 MLXSW_ITEM32(reg, spvc, et0, 0x08, 0, 1); 1942 1943 static inline void mlxsw_reg_spvc_pack(char *payload, u16 local_port, bool et1, 1944 bool et0) 1945 { 1946 MLXSW_REG_ZERO(spvc, payload); 1947 mlxsw_reg_spvc_local_port_set(payload, local_port); 1948 /* Enable inner_et1 and inner_et0 to enable identification of double 1949 * tagged packets. 1950 */ 1951 mlxsw_reg_spvc_inner_et1_set(payload, 1); 1952 mlxsw_reg_spvc_inner_et0_set(payload, 1); 1953 mlxsw_reg_spvc_et1_set(payload, et1); 1954 mlxsw_reg_spvc_et0_set(payload, et0); 1955 } 1956 1957 /* SPEVET - Switch Port Egress VLAN EtherType 1958 * ------------------------------------------ 1959 * The switch port egress VLAN EtherType configures which EtherType to push at 1960 * egress for packets incoming through a local port for which 'SPVID.egr_et_set' 1961 * is set. 1962 */ 1963 #define MLXSW_REG_SPEVET_ID 0x202A 1964 #define MLXSW_REG_SPEVET_LEN 0x08 1965 1966 MLXSW_REG_DEFINE(spevet, MLXSW_REG_SPEVET_ID, MLXSW_REG_SPEVET_LEN); 1967 1968 /* reg_spevet_local_port 1969 * Egress Local port number. 1970 * Not supported to CPU port. 1971 * Access: Index 1972 */ 1973 MLXSW_ITEM32_LP(reg, spevet, 0x00, 16, 0x00, 12); 1974 1975 /* reg_spevet_et_vlan 1976 * Egress EtherType VLAN to push when SPVID.egr_et_set field set for the packet: 1977 * 0: ether_type0 - (default) 1978 * 1: ether_type1 1979 * 2: ether_type2 1980 * Access: RW 1981 */ 1982 MLXSW_ITEM32(reg, spevet, et_vlan, 0x04, 16, 2); 1983 1984 static inline void mlxsw_reg_spevet_pack(char *payload, u16 local_port, 1985 u8 et_vlan) 1986 { 1987 MLXSW_REG_ZERO(spevet, payload); 1988 mlxsw_reg_spevet_local_port_set(payload, local_port); 1989 mlxsw_reg_spevet_et_vlan_set(payload, et_vlan); 1990 } 1991 1992 /* SFTR-V2 - Switch Flooding Table Version 2 Register 1993 * -------------------------------------------------- 1994 * The switch flooding table is used for flooding packet replication. The table 1995 * defines a bit mask of ports for packet replication. 1996 */ 1997 #define MLXSW_REG_SFTR2_ID 0x202F 1998 #define MLXSW_REG_SFTR2_LEN 0x120 1999 2000 MLXSW_REG_DEFINE(sftr2, MLXSW_REG_SFTR2_ID, MLXSW_REG_SFTR2_LEN); 2001 2002 /* reg_sftr2_swid 2003 * Switch partition ID with which to associate the port. 2004 * Access: Index 2005 */ 2006 MLXSW_ITEM32(reg, sftr2, swid, 0x00, 24, 8); 2007 2008 /* reg_sftr2_flood_table 2009 * Flooding table index to associate with the specific type on the specific 2010 * switch partition. 2011 * Access: Index 2012 */ 2013 MLXSW_ITEM32(reg, sftr2, flood_table, 0x00, 16, 6); 2014 2015 /* reg_sftr2_index 2016 * Index. Used as an index into the Flooding Table in case the table is 2017 * configured to use VID / FID or FID Offset. 2018 * Access: Index 2019 */ 2020 MLXSW_ITEM32(reg, sftr2, index, 0x00, 0, 16); 2021 2022 /* reg_sftr2_table_type 2023 * See mlxsw_flood_table_type 2024 * Access: RW 2025 */ 2026 MLXSW_ITEM32(reg, sftr2, table_type, 0x04, 16, 3); 2027 2028 /* reg_sftr2_range 2029 * Range of entries to update 2030 * Access: Index 2031 */ 2032 MLXSW_ITEM32(reg, sftr2, range, 0x04, 0, 16); 2033 2034 /* reg_sftr2_port 2035 * Local port membership (1 bit per port). 2036 * Access: RW 2037 */ 2038 MLXSW_ITEM_BIT_ARRAY(reg, sftr2, port, 0x20, 0x80, 1); 2039 2040 /* reg_sftr2_port_mask 2041 * Local port mask (1 bit per port). 2042 * Access: WO 2043 */ 2044 MLXSW_ITEM_BIT_ARRAY(reg, sftr2, port_mask, 0xA0, 0x80, 1); 2045 2046 static inline void mlxsw_reg_sftr2_pack(char *payload, 2047 unsigned int flood_table, 2048 unsigned int index, 2049 enum mlxsw_flood_table_type table_type, 2050 unsigned int range, u16 port, bool set) 2051 { 2052 MLXSW_REG_ZERO(sftr2, payload); 2053 mlxsw_reg_sftr2_swid_set(payload, 0); 2054 mlxsw_reg_sftr2_flood_table_set(payload, flood_table); 2055 mlxsw_reg_sftr2_index_set(payload, index); 2056 mlxsw_reg_sftr2_table_type_set(payload, table_type); 2057 mlxsw_reg_sftr2_range_set(payload, range); 2058 mlxsw_reg_sftr2_port_set(payload, port, set); 2059 mlxsw_reg_sftr2_port_mask_set(payload, port, 1); 2060 } 2061 2062 /* SMID-V2 - Switch Multicast ID Version 2 Register 2063 * ------------------------------------------------ 2064 * The MID record maps from a MID (Multicast ID), which is a unique identifier 2065 * of the multicast group within the stacking domain, into a list of local 2066 * ports into which the packet is replicated. 2067 */ 2068 #define MLXSW_REG_SMID2_ID 0x2034 2069 #define MLXSW_REG_SMID2_LEN 0x120 2070 2071 MLXSW_REG_DEFINE(smid2, MLXSW_REG_SMID2_ID, MLXSW_REG_SMID2_LEN); 2072 2073 /* reg_smid2_swid 2074 * Switch partition ID. 2075 * Access: Index 2076 */ 2077 MLXSW_ITEM32(reg, smid2, swid, 0x00, 24, 8); 2078 2079 /* reg_smid2_mid 2080 * Multicast identifier - global identifier that represents the multicast group 2081 * across all devices. 2082 * Access: Index 2083 */ 2084 MLXSW_ITEM32(reg, smid2, mid, 0x00, 0, 16); 2085 2086 /* reg_smid2_port 2087 * Local port memebership (1 bit per port). 2088 * Access: RW 2089 */ 2090 MLXSW_ITEM_BIT_ARRAY(reg, smid2, port, 0x20, 0x80, 1); 2091 2092 /* reg_smid2_port_mask 2093 * Local port mask (1 bit per port). 2094 * Access: WO 2095 */ 2096 MLXSW_ITEM_BIT_ARRAY(reg, smid2, port_mask, 0xA0, 0x80, 1); 2097 2098 static inline void mlxsw_reg_smid2_pack(char *payload, u16 mid, u16 port, 2099 bool set) 2100 { 2101 MLXSW_REG_ZERO(smid2, payload); 2102 mlxsw_reg_smid2_swid_set(payload, 0); 2103 mlxsw_reg_smid2_mid_set(payload, mid); 2104 mlxsw_reg_smid2_port_set(payload, port, set); 2105 mlxsw_reg_smid2_port_mask_set(payload, port, 1); 2106 } 2107 2108 /* CWTP - Congetion WRED ECN TClass Profile 2109 * ---------------------------------------- 2110 * Configures the profiles for queues of egress port and traffic class 2111 */ 2112 #define MLXSW_REG_CWTP_ID 0x2802 2113 #define MLXSW_REG_CWTP_BASE_LEN 0x28 2114 #define MLXSW_REG_CWTP_PROFILE_DATA_REC_LEN 0x08 2115 #define MLXSW_REG_CWTP_LEN 0x40 2116 2117 MLXSW_REG_DEFINE(cwtp, MLXSW_REG_CWTP_ID, MLXSW_REG_CWTP_LEN); 2118 2119 /* reg_cwtp_local_port 2120 * Local port number 2121 * Not supported for CPU port 2122 * Access: Index 2123 */ 2124 MLXSW_ITEM32_LP(reg, cwtp, 0x00, 16, 0x00, 12); 2125 2126 /* reg_cwtp_traffic_class 2127 * Traffic Class to configure 2128 * Access: Index 2129 */ 2130 MLXSW_ITEM32(reg, cwtp, traffic_class, 32, 0, 8); 2131 2132 /* reg_cwtp_profile_min 2133 * Minimum Average Queue Size of the profile in cells. 2134 * Access: RW 2135 */ 2136 MLXSW_ITEM32_INDEXED(reg, cwtp, profile_min, MLXSW_REG_CWTP_BASE_LEN, 2137 0, 20, MLXSW_REG_CWTP_PROFILE_DATA_REC_LEN, 0, false); 2138 2139 /* reg_cwtp_profile_percent 2140 * Percentage of WRED and ECN marking for maximum Average Queue size 2141 * Range is 0 to 100, units of integer percentage 2142 * Access: RW 2143 */ 2144 MLXSW_ITEM32_INDEXED(reg, cwtp, profile_percent, MLXSW_REG_CWTP_BASE_LEN, 2145 24, 7, MLXSW_REG_CWTP_PROFILE_DATA_REC_LEN, 4, false); 2146 2147 /* reg_cwtp_profile_max 2148 * Maximum Average Queue size of the profile in cells 2149 * Access: RW 2150 */ 2151 MLXSW_ITEM32_INDEXED(reg, cwtp, profile_max, MLXSW_REG_CWTP_BASE_LEN, 2152 0, 20, MLXSW_REG_CWTP_PROFILE_DATA_REC_LEN, 4, false); 2153 2154 #define MLXSW_REG_CWTP_MIN_VALUE 64 2155 #define MLXSW_REG_CWTP_MAX_PROFILE 2 2156 #define MLXSW_REG_CWTP_DEFAULT_PROFILE 1 2157 2158 static inline void mlxsw_reg_cwtp_pack(char *payload, u16 local_port, 2159 u8 traffic_class) 2160 { 2161 int i; 2162 2163 MLXSW_REG_ZERO(cwtp, payload); 2164 mlxsw_reg_cwtp_local_port_set(payload, local_port); 2165 mlxsw_reg_cwtp_traffic_class_set(payload, traffic_class); 2166 2167 for (i = 0; i <= MLXSW_REG_CWTP_MAX_PROFILE; i++) { 2168 mlxsw_reg_cwtp_profile_min_set(payload, i, 2169 MLXSW_REG_CWTP_MIN_VALUE); 2170 mlxsw_reg_cwtp_profile_max_set(payload, i, 2171 MLXSW_REG_CWTP_MIN_VALUE); 2172 } 2173 } 2174 2175 #define MLXSW_REG_CWTP_PROFILE_TO_INDEX(profile) (profile - 1) 2176 2177 static inline void 2178 mlxsw_reg_cwtp_profile_pack(char *payload, u8 profile, u32 min, u32 max, 2179 u32 probability) 2180 { 2181 u8 index = MLXSW_REG_CWTP_PROFILE_TO_INDEX(profile); 2182 2183 mlxsw_reg_cwtp_profile_min_set(payload, index, min); 2184 mlxsw_reg_cwtp_profile_max_set(payload, index, max); 2185 mlxsw_reg_cwtp_profile_percent_set(payload, index, probability); 2186 } 2187 2188 /* CWTPM - Congestion WRED ECN TClass and Pool Mapping 2189 * --------------------------------------------------- 2190 * The CWTPM register maps each egress port and traffic class to profile num. 2191 */ 2192 #define MLXSW_REG_CWTPM_ID 0x2803 2193 #define MLXSW_REG_CWTPM_LEN 0x44 2194 2195 MLXSW_REG_DEFINE(cwtpm, MLXSW_REG_CWTPM_ID, MLXSW_REG_CWTPM_LEN); 2196 2197 /* reg_cwtpm_local_port 2198 * Local port number 2199 * Not supported for CPU port 2200 * Access: Index 2201 */ 2202 MLXSW_ITEM32_LP(reg, cwtpm, 0x00, 16, 0x00, 12); 2203 2204 /* reg_cwtpm_traffic_class 2205 * Traffic Class to configure 2206 * Access: Index 2207 */ 2208 MLXSW_ITEM32(reg, cwtpm, traffic_class, 32, 0, 8); 2209 2210 /* reg_cwtpm_ew 2211 * Control enablement of WRED for traffic class: 2212 * 0 - Disable 2213 * 1 - Enable 2214 * Access: RW 2215 */ 2216 MLXSW_ITEM32(reg, cwtpm, ew, 36, 1, 1); 2217 2218 /* reg_cwtpm_ee 2219 * Control enablement of ECN for traffic class: 2220 * 0 - Disable 2221 * 1 - Enable 2222 * Access: RW 2223 */ 2224 MLXSW_ITEM32(reg, cwtpm, ee, 36, 0, 1); 2225 2226 /* reg_cwtpm_tcp_g 2227 * TCP Green Profile. 2228 * Index of the profile within {port, traffic class} to use. 2229 * 0 for disabling both WRED and ECN for this type of traffic. 2230 * Access: RW 2231 */ 2232 MLXSW_ITEM32(reg, cwtpm, tcp_g, 52, 0, 2); 2233 2234 /* reg_cwtpm_tcp_y 2235 * TCP Yellow Profile. 2236 * Index of the profile within {port, traffic class} to use. 2237 * 0 for disabling both WRED and ECN for this type of traffic. 2238 * Access: RW 2239 */ 2240 MLXSW_ITEM32(reg, cwtpm, tcp_y, 56, 16, 2); 2241 2242 /* reg_cwtpm_tcp_r 2243 * TCP Red Profile. 2244 * Index of the profile within {port, traffic class} to use. 2245 * 0 for disabling both WRED and ECN for this type of traffic. 2246 * Access: RW 2247 */ 2248 MLXSW_ITEM32(reg, cwtpm, tcp_r, 56, 0, 2); 2249 2250 /* reg_cwtpm_ntcp_g 2251 * Non-TCP Green Profile. 2252 * Index of the profile within {port, traffic class} to use. 2253 * 0 for disabling both WRED and ECN for this type of traffic. 2254 * Access: RW 2255 */ 2256 MLXSW_ITEM32(reg, cwtpm, ntcp_g, 60, 0, 2); 2257 2258 /* reg_cwtpm_ntcp_y 2259 * Non-TCP Yellow Profile. 2260 * Index of the profile within {port, traffic class} to use. 2261 * 0 for disabling both WRED and ECN for this type of traffic. 2262 * Access: RW 2263 */ 2264 MLXSW_ITEM32(reg, cwtpm, ntcp_y, 64, 16, 2); 2265 2266 /* reg_cwtpm_ntcp_r 2267 * Non-TCP Red Profile. 2268 * Index of the profile within {port, traffic class} to use. 2269 * 0 for disabling both WRED and ECN for this type of traffic. 2270 * Access: RW 2271 */ 2272 MLXSW_ITEM32(reg, cwtpm, ntcp_r, 64, 0, 2); 2273 2274 #define MLXSW_REG_CWTPM_RESET_PROFILE 0 2275 2276 static inline void mlxsw_reg_cwtpm_pack(char *payload, u16 local_port, 2277 u8 traffic_class, u8 profile, 2278 bool wred, bool ecn) 2279 { 2280 MLXSW_REG_ZERO(cwtpm, payload); 2281 mlxsw_reg_cwtpm_local_port_set(payload, local_port); 2282 mlxsw_reg_cwtpm_traffic_class_set(payload, traffic_class); 2283 mlxsw_reg_cwtpm_ew_set(payload, wred); 2284 mlxsw_reg_cwtpm_ee_set(payload, ecn); 2285 mlxsw_reg_cwtpm_tcp_g_set(payload, profile); 2286 mlxsw_reg_cwtpm_tcp_y_set(payload, profile); 2287 mlxsw_reg_cwtpm_tcp_r_set(payload, profile); 2288 mlxsw_reg_cwtpm_ntcp_g_set(payload, profile); 2289 mlxsw_reg_cwtpm_ntcp_y_set(payload, profile); 2290 mlxsw_reg_cwtpm_ntcp_r_set(payload, profile); 2291 } 2292 2293 /* PGCR - Policy-Engine General Configuration Register 2294 * --------------------------------------------------- 2295 * This register configures general Policy-Engine settings. 2296 */ 2297 #define MLXSW_REG_PGCR_ID 0x3001 2298 #define MLXSW_REG_PGCR_LEN 0x20 2299 2300 MLXSW_REG_DEFINE(pgcr, MLXSW_REG_PGCR_ID, MLXSW_REG_PGCR_LEN); 2301 2302 /* reg_pgcr_default_action_pointer_base 2303 * Default action pointer base. Each region has a default action pointer 2304 * which is equal to default_action_pointer_base + region_id. 2305 * Access: RW 2306 */ 2307 MLXSW_ITEM32(reg, pgcr, default_action_pointer_base, 0x1C, 0, 24); 2308 2309 static inline void mlxsw_reg_pgcr_pack(char *payload, u32 pointer_base) 2310 { 2311 MLXSW_REG_ZERO(pgcr, payload); 2312 mlxsw_reg_pgcr_default_action_pointer_base_set(payload, pointer_base); 2313 } 2314 2315 /* PPBT - Policy-Engine Port Binding Table 2316 * --------------------------------------- 2317 * This register is used for configuration of the Port Binding Table. 2318 */ 2319 #define MLXSW_REG_PPBT_ID 0x3002 2320 #define MLXSW_REG_PPBT_LEN 0x14 2321 2322 MLXSW_REG_DEFINE(ppbt, MLXSW_REG_PPBT_ID, MLXSW_REG_PPBT_LEN); 2323 2324 enum mlxsw_reg_pxbt_e { 2325 MLXSW_REG_PXBT_E_IACL, 2326 MLXSW_REG_PXBT_E_EACL, 2327 }; 2328 2329 /* reg_ppbt_e 2330 * Access: Index 2331 */ 2332 MLXSW_ITEM32(reg, ppbt, e, 0x00, 31, 1); 2333 2334 enum mlxsw_reg_pxbt_op { 2335 MLXSW_REG_PXBT_OP_BIND, 2336 MLXSW_REG_PXBT_OP_UNBIND, 2337 }; 2338 2339 /* reg_ppbt_op 2340 * Access: RW 2341 */ 2342 MLXSW_ITEM32(reg, ppbt, op, 0x00, 28, 3); 2343 2344 /* reg_ppbt_local_port 2345 * Local port. Not including CPU port. 2346 * Access: Index 2347 */ 2348 MLXSW_ITEM32_LP(reg, ppbt, 0x00, 16, 0x00, 12); 2349 2350 /* reg_ppbt_g 2351 * group - When set, the binding is of an ACL group. When cleared, 2352 * the binding is of an ACL. 2353 * Must be set to 1 for Spectrum. 2354 * Access: RW 2355 */ 2356 MLXSW_ITEM32(reg, ppbt, g, 0x10, 31, 1); 2357 2358 /* reg_ppbt_acl_info 2359 * ACL/ACL group identifier. If the g bit is set, this field should hold 2360 * the acl_group_id, else it should hold the acl_id. 2361 * Access: RW 2362 */ 2363 MLXSW_ITEM32(reg, ppbt, acl_info, 0x10, 0, 16); 2364 2365 static inline void mlxsw_reg_ppbt_pack(char *payload, enum mlxsw_reg_pxbt_e e, 2366 enum mlxsw_reg_pxbt_op op, 2367 u16 local_port, u16 acl_info) 2368 { 2369 MLXSW_REG_ZERO(ppbt, payload); 2370 mlxsw_reg_ppbt_e_set(payload, e); 2371 mlxsw_reg_ppbt_op_set(payload, op); 2372 mlxsw_reg_ppbt_local_port_set(payload, local_port); 2373 mlxsw_reg_ppbt_g_set(payload, true); 2374 mlxsw_reg_ppbt_acl_info_set(payload, acl_info); 2375 } 2376 2377 /* PACL - Policy-Engine ACL Register 2378 * --------------------------------- 2379 * This register is used for configuration of the ACL. 2380 */ 2381 #define MLXSW_REG_PACL_ID 0x3004 2382 #define MLXSW_REG_PACL_LEN 0x70 2383 2384 MLXSW_REG_DEFINE(pacl, MLXSW_REG_PACL_ID, MLXSW_REG_PACL_LEN); 2385 2386 /* reg_pacl_v 2387 * Valid. Setting the v bit makes the ACL valid. It should not be cleared 2388 * while the ACL is bounded to either a port, VLAN or ACL rule. 2389 * Access: RW 2390 */ 2391 MLXSW_ITEM32(reg, pacl, v, 0x00, 24, 1); 2392 2393 /* reg_pacl_acl_id 2394 * An identifier representing the ACL (managed by software) 2395 * Range 0 .. cap_max_acl_regions - 1 2396 * Access: Index 2397 */ 2398 MLXSW_ITEM32(reg, pacl, acl_id, 0x08, 0, 16); 2399 2400 #define MLXSW_REG_PXXX_TCAM_REGION_INFO_LEN 16 2401 2402 /* reg_pacl_tcam_region_info 2403 * Opaque object that represents a TCAM region. 2404 * Obtained through PTAR register. 2405 * Access: RW 2406 */ 2407 MLXSW_ITEM_BUF(reg, pacl, tcam_region_info, 0x30, 2408 MLXSW_REG_PXXX_TCAM_REGION_INFO_LEN); 2409 2410 static inline void mlxsw_reg_pacl_pack(char *payload, u16 acl_id, 2411 bool valid, const char *tcam_region_info) 2412 { 2413 MLXSW_REG_ZERO(pacl, payload); 2414 mlxsw_reg_pacl_acl_id_set(payload, acl_id); 2415 mlxsw_reg_pacl_v_set(payload, valid); 2416 mlxsw_reg_pacl_tcam_region_info_memcpy_to(payload, tcam_region_info); 2417 } 2418 2419 /* PAGT - Policy-Engine ACL Group Table 2420 * ------------------------------------ 2421 * This register is used for configuration of the ACL Group Table. 2422 */ 2423 #define MLXSW_REG_PAGT_ID 0x3005 2424 #define MLXSW_REG_PAGT_BASE_LEN 0x30 2425 #define MLXSW_REG_PAGT_ACL_LEN 4 2426 #define MLXSW_REG_PAGT_ACL_MAX_NUM 16 2427 #define MLXSW_REG_PAGT_LEN (MLXSW_REG_PAGT_BASE_LEN + \ 2428 MLXSW_REG_PAGT_ACL_MAX_NUM * MLXSW_REG_PAGT_ACL_LEN) 2429 2430 MLXSW_REG_DEFINE(pagt, MLXSW_REG_PAGT_ID, MLXSW_REG_PAGT_LEN); 2431 2432 /* reg_pagt_size 2433 * Number of ACLs in the group. 2434 * Size 0 invalidates a group. 2435 * Range 0 .. cap_max_acl_group_size (hard coded to 16 for now) 2436 * Total number of ACLs in all groups must be lower or equal 2437 * to cap_max_acl_tot_groups 2438 * Note: a group which is binded must not be invalidated 2439 * Access: Index 2440 */ 2441 MLXSW_ITEM32(reg, pagt, size, 0x00, 0, 8); 2442 2443 /* reg_pagt_acl_group_id 2444 * An identifier (numbered from 0..cap_max_acl_groups-1) representing 2445 * the ACL Group identifier (managed by software). 2446 * Access: Index 2447 */ 2448 MLXSW_ITEM32(reg, pagt, acl_group_id, 0x08, 0, 16); 2449 2450 /* reg_pagt_multi 2451 * Multi-ACL 2452 * 0 - This ACL is the last ACL in the multi-ACL 2453 * 1 - This ACL is part of a multi-ACL 2454 * Access: RW 2455 */ 2456 MLXSW_ITEM32_INDEXED(reg, pagt, multi, 0x30, 31, 1, 0x04, 0x00, false); 2457 2458 /* reg_pagt_acl_id 2459 * ACL identifier 2460 * Access: RW 2461 */ 2462 MLXSW_ITEM32_INDEXED(reg, pagt, acl_id, 0x30, 0, 16, 0x04, 0x00, false); 2463 2464 static inline void mlxsw_reg_pagt_pack(char *payload, u16 acl_group_id) 2465 { 2466 MLXSW_REG_ZERO(pagt, payload); 2467 mlxsw_reg_pagt_acl_group_id_set(payload, acl_group_id); 2468 } 2469 2470 static inline void mlxsw_reg_pagt_acl_id_pack(char *payload, int index, 2471 u16 acl_id, bool multi) 2472 { 2473 u8 size = mlxsw_reg_pagt_size_get(payload); 2474 2475 if (index >= size) 2476 mlxsw_reg_pagt_size_set(payload, index + 1); 2477 mlxsw_reg_pagt_multi_set(payload, index, multi); 2478 mlxsw_reg_pagt_acl_id_set(payload, index, acl_id); 2479 } 2480 2481 /* PTAR - Policy-Engine TCAM Allocation Register 2482 * --------------------------------------------- 2483 * This register is used for allocation of regions in the TCAM. 2484 * Note: Query method is not supported on this register. 2485 */ 2486 #define MLXSW_REG_PTAR_ID 0x3006 2487 #define MLXSW_REG_PTAR_BASE_LEN 0x20 2488 #define MLXSW_REG_PTAR_KEY_ID_LEN 1 2489 #define MLXSW_REG_PTAR_KEY_ID_MAX_NUM 16 2490 #define MLXSW_REG_PTAR_LEN (MLXSW_REG_PTAR_BASE_LEN + \ 2491 MLXSW_REG_PTAR_KEY_ID_MAX_NUM * MLXSW_REG_PTAR_KEY_ID_LEN) 2492 2493 MLXSW_REG_DEFINE(ptar, MLXSW_REG_PTAR_ID, MLXSW_REG_PTAR_LEN); 2494 2495 enum mlxsw_reg_ptar_op { 2496 /* allocate a TCAM region */ 2497 MLXSW_REG_PTAR_OP_ALLOC, 2498 /* resize a TCAM region */ 2499 MLXSW_REG_PTAR_OP_RESIZE, 2500 /* deallocate TCAM region */ 2501 MLXSW_REG_PTAR_OP_FREE, 2502 /* test allocation */ 2503 MLXSW_REG_PTAR_OP_TEST, 2504 }; 2505 2506 /* reg_ptar_op 2507 * Access: OP 2508 */ 2509 MLXSW_ITEM32(reg, ptar, op, 0x00, 28, 4); 2510 2511 /* reg_ptar_action_set_type 2512 * Type of action set to be used on this region. 2513 * For Spectrum and Spectrum-2, this is always type 2 - "flexible" 2514 * Access: WO 2515 */ 2516 MLXSW_ITEM32(reg, ptar, action_set_type, 0x00, 16, 8); 2517 2518 enum mlxsw_reg_ptar_key_type { 2519 MLXSW_REG_PTAR_KEY_TYPE_FLEX = 0x50, /* Spetrum */ 2520 MLXSW_REG_PTAR_KEY_TYPE_FLEX2 = 0x51, /* Spectrum-2 */ 2521 }; 2522 2523 /* reg_ptar_key_type 2524 * TCAM key type for the region. 2525 * Access: WO 2526 */ 2527 MLXSW_ITEM32(reg, ptar, key_type, 0x00, 0, 8); 2528 2529 /* reg_ptar_region_size 2530 * TCAM region size. When allocating/resizing this is the requested size, 2531 * the response is the actual size. Note that actual size may be 2532 * larger than requested. 2533 * Allowed range 1 .. cap_max_rules-1 2534 * Reserved during op deallocate. 2535 * Access: WO 2536 */ 2537 MLXSW_ITEM32(reg, ptar, region_size, 0x04, 0, 16); 2538 2539 /* reg_ptar_region_id 2540 * Region identifier 2541 * Range 0 .. cap_max_regions-1 2542 * Access: Index 2543 */ 2544 MLXSW_ITEM32(reg, ptar, region_id, 0x08, 0, 16); 2545 2546 /* reg_ptar_tcam_region_info 2547 * Opaque object that represents the TCAM region. 2548 * Returned when allocating a region. 2549 * Provided by software for ACL generation and region deallocation and resize. 2550 * Access: RW 2551 */ 2552 MLXSW_ITEM_BUF(reg, ptar, tcam_region_info, 0x10, 2553 MLXSW_REG_PXXX_TCAM_REGION_INFO_LEN); 2554 2555 /* reg_ptar_flexible_key_id 2556 * Identifier of the Flexible Key. 2557 * Only valid if key_type == "FLEX_KEY" 2558 * The key size will be rounded up to one of the following values: 2559 * 9B, 18B, 36B, 54B. 2560 * This field is reserved for in resize operation. 2561 * Access: WO 2562 */ 2563 MLXSW_ITEM8_INDEXED(reg, ptar, flexible_key_id, 0x20, 0, 8, 2564 MLXSW_REG_PTAR_KEY_ID_LEN, 0x00, false); 2565 2566 static inline void mlxsw_reg_ptar_pack(char *payload, enum mlxsw_reg_ptar_op op, 2567 enum mlxsw_reg_ptar_key_type key_type, 2568 u16 region_size, u16 region_id, 2569 const char *tcam_region_info) 2570 { 2571 MLXSW_REG_ZERO(ptar, payload); 2572 mlxsw_reg_ptar_op_set(payload, op); 2573 mlxsw_reg_ptar_action_set_type_set(payload, 2); /* "flexible" */ 2574 mlxsw_reg_ptar_key_type_set(payload, key_type); 2575 mlxsw_reg_ptar_region_size_set(payload, region_size); 2576 mlxsw_reg_ptar_region_id_set(payload, region_id); 2577 mlxsw_reg_ptar_tcam_region_info_memcpy_to(payload, tcam_region_info); 2578 } 2579 2580 static inline void mlxsw_reg_ptar_key_id_pack(char *payload, int index, 2581 u16 key_id) 2582 { 2583 mlxsw_reg_ptar_flexible_key_id_set(payload, index, key_id); 2584 } 2585 2586 static inline void mlxsw_reg_ptar_unpack(char *payload, char *tcam_region_info) 2587 { 2588 mlxsw_reg_ptar_tcam_region_info_memcpy_from(payload, tcam_region_info); 2589 } 2590 2591 /* PPBS - Policy-Engine Policy Based Switching Register 2592 * ---------------------------------------------------- 2593 * This register retrieves and sets Policy Based Switching Table entries. 2594 */ 2595 #define MLXSW_REG_PPBS_ID 0x300C 2596 #define MLXSW_REG_PPBS_LEN 0x14 2597 2598 MLXSW_REG_DEFINE(ppbs, MLXSW_REG_PPBS_ID, MLXSW_REG_PPBS_LEN); 2599 2600 /* reg_ppbs_pbs_ptr 2601 * Index into the PBS table. 2602 * For Spectrum, the index points to the KVD Linear. 2603 * Access: Index 2604 */ 2605 MLXSW_ITEM32(reg, ppbs, pbs_ptr, 0x08, 0, 24); 2606 2607 /* reg_ppbs_system_port 2608 * Unique port identifier for the final destination of the packet. 2609 * Access: RW 2610 */ 2611 MLXSW_ITEM32(reg, ppbs, system_port, 0x10, 0, 16); 2612 2613 static inline void mlxsw_reg_ppbs_pack(char *payload, u32 pbs_ptr, 2614 u16 system_port) 2615 { 2616 MLXSW_REG_ZERO(ppbs, payload); 2617 mlxsw_reg_ppbs_pbs_ptr_set(payload, pbs_ptr); 2618 mlxsw_reg_ppbs_system_port_set(payload, system_port); 2619 } 2620 2621 /* PRCR - Policy-Engine Rules Copy Register 2622 * ---------------------------------------- 2623 * This register is used for accessing rules within a TCAM region. 2624 */ 2625 #define MLXSW_REG_PRCR_ID 0x300D 2626 #define MLXSW_REG_PRCR_LEN 0x40 2627 2628 MLXSW_REG_DEFINE(prcr, MLXSW_REG_PRCR_ID, MLXSW_REG_PRCR_LEN); 2629 2630 enum mlxsw_reg_prcr_op { 2631 /* Move rules. Moves the rules from "tcam_region_info" starting 2632 * at offset "offset" to "dest_tcam_region_info" 2633 * at offset "dest_offset." 2634 */ 2635 MLXSW_REG_PRCR_OP_MOVE, 2636 /* Copy rules. Copies the rules from "tcam_region_info" starting 2637 * at offset "offset" to "dest_tcam_region_info" 2638 * at offset "dest_offset." 2639 */ 2640 MLXSW_REG_PRCR_OP_COPY, 2641 }; 2642 2643 /* reg_prcr_op 2644 * Access: OP 2645 */ 2646 MLXSW_ITEM32(reg, prcr, op, 0x00, 28, 4); 2647 2648 /* reg_prcr_offset 2649 * Offset within the source region to copy/move from. 2650 * Access: Index 2651 */ 2652 MLXSW_ITEM32(reg, prcr, offset, 0x00, 0, 16); 2653 2654 /* reg_prcr_size 2655 * The number of rules to copy/move. 2656 * Access: WO 2657 */ 2658 MLXSW_ITEM32(reg, prcr, size, 0x04, 0, 16); 2659 2660 /* reg_prcr_tcam_region_info 2661 * Opaque object that represents the source TCAM region. 2662 * Access: Index 2663 */ 2664 MLXSW_ITEM_BUF(reg, prcr, tcam_region_info, 0x10, 2665 MLXSW_REG_PXXX_TCAM_REGION_INFO_LEN); 2666 2667 /* reg_prcr_dest_offset 2668 * Offset within the source region to copy/move to. 2669 * Access: Index 2670 */ 2671 MLXSW_ITEM32(reg, prcr, dest_offset, 0x20, 0, 16); 2672 2673 /* reg_prcr_dest_tcam_region_info 2674 * Opaque object that represents the destination TCAM region. 2675 * Access: Index 2676 */ 2677 MLXSW_ITEM_BUF(reg, prcr, dest_tcam_region_info, 0x30, 2678 MLXSW_REG_PXXX_TCAM_REGION_INFO_LEN); 2679 2680 static inline void mlxsw_reg_prcr_pack(char *payload, enum mlxsw_reg_prcr_op op, 2681 const char *src_tcam_region_info, 2682 u16 src_offset, 2683 const char *dest_tcam_region_info, 2684 u16 dest_offset, u16 size) 2685 { 2686 MLXSW_REG_ZERO(prcr, payload); 2687 mlxsw_reg_prcr_op_set(payload, op); 2688 mlxsw_reg_prcr_offset_set(payload, src_offset); 2689 mlxsw_reg_prcr_size_set(payload, size); 2690 mlxsw_reg_prcr_tcam_region_info_memcpy_to(payload, 2691 src_tcam_region_info); 2692 mlxsw_reg_prcr_dest_offset_set(payload, dest_offset); 2693 mlxsw_reg_prcr_dest_tcam_region_info_memcpy_to(payload, 2694 dest_tcam_region_info); 2695 } 2696 2697 /* PEFA - Policy-Engine Extended Flexible Action Register 2698 * ------------------------------------------------------ 2699 * This register is used for accessing an extended flexible action entry 2700 * in the central KVD Linear Database. 2701 */ 2702 #define MLXSW_REG_PEFA_ID 0x300F 2703 #define MLXSW_REG_PEFA_LEN 0xB0 2704 2705 MLXSW_REG_DEFINE(pefa, MLXSW_REG_PEFA_ID, MLXSW_REG_PEFA_LEN); 2706 2707 /* reg_pefa_index 2708 * Index in the KVD Linear Centralized Database. 2709 * Access: Index 2710 */ 2711 MLXSW_ITEM32(reg, pefa, index, 0x00, 0, 24); 2712 2713 /* reg_pefa_a 2714 * Index in the KVD Linear Centralized Database. 2715 * Activity 2716 * For a new entry: set if ca=0, clear if ca=1 2717 * Set if a packet lookup has hit on the specific entry 2718 * Access: RO 2719 */ 2720 MLXSW_ITEM32(reg, pefa, a, 0x04, 29, 1); 2721 2722 /* reg_pefa_ca 2723 * Clear activity 2724 * When write: activity is according to this field 2725 * When read: after reading the activity is cleared according to ca 2726 * Access: OP 2727 */ 2728 MLXSW_ITEM32(reg, pefa, ca, 0x04, 24, 1); 2729 2730 #define MLXSW_REG_FLEX_ACTION_SET_LEN 0xA8 2731 2732 /* reg_pefa_flex_action_set 2733 * Action-set to perform when rule is matched. 2734 * Must be zero padded if action set is shorter. 2735 * Access: RW 2736 */ 2737 MLXSW_ITEM_BUF(reg, pefa, flex_action_set, 0x08, MLXSW_REG_FLEX_ACTION_SET_LEN); 2738 2739 static inline void mlxsw_reg_pefa_pack(char *payload, u32 index, bool ca, 2740 const char *flex_action_set) 2741 { 2742 MLXSW_REG_ZERO(pefa, payload); 2743 mlxsw_reg_pefa_index_set(payload, index); 2744 mlxsw_reg_pefa_ca_set(payload, ca); 2745 if (flex_action_set) 2746 mlxsw_reg_pefa_flex_action_set_memcpy_to(payload, 2747 flex_action_set); 2748 } 2749 2750 static inline void mlxsw_reg_pefa_unpack(char *payload, bool *p_a) 2751 { 2752 *p_a = mlxsw_reg_pefa_a_get(payload); 2753 } 2754 2755 /* PEMRBT - Policy-Engine Multicast Router Binding Table Register 2756 * -------------------------------------------------------------- 2757 * This register is used for binding Multicast router to an ACL group 2758 * that serves the MC router. 2759 * This register is not supported by SwitchX/-2 and Spectrum. 2760 */ 2761 #define MLXSW_REG_PEMRBT_ID 0x3014 2762 #define MLXSW_REG_PEMRBT_LEN 0x14 2763 2764 MLXSW_REG_DEFINE(pemrbt, MLXSW_REG_PEMRBT_ID, MLXSW_REG_PEMRBT_LEN); 2765 2766 enum mlxsw_reg_pemrbt_protocol { 2767 MLXSW_REG_PEMRBT_PROTO_IPV4, 2768 MLXSW_REG_PEMRBT_PROTO_IPV6, 2769 }; 2770 2771 /* reg_pemrbt_protocol 2772 * Access: Index 2773 */ 2774 MLXSW_ITEM32(reg, pemrbt, protocol, 0x00, 0, 1); 2775 2776 /* reg_pemrbt_group_id 2777 * ACL group identifier. 2778 * Range 0..cap_max_acl_groups-1 2779 * Access: RW 2780 */ 2781 MLXSW_ITEM32(reg, pemrbt, group_id, 0x10, 0, 16); 2782 2783 static inline void 2784 mlxsw_reg_pemrbt_pack(char *payload, enum mlxsw_reg_pemrbt_protocol protocol, 2785 u16 group_id) 2786 { 2787 MLXSW_REG_ZERO(pemrbt, payload); 2788 mlxsw_reg_pemrbt_protocol_set(payload, protocol); 2789 mlxsw_reg_pemrbt_group_id_set(payload, group_id); 2790 } 2791 2792 /* PTCE-V2 - Policy-Engine TCAM Entry Register Version 2 2793 * ----------------------------------------------------- 2794 * This register is used for accessing rules within a TCAM region. 2795 * It is a new version of PTCE in order to support wider key, 2796 * mask and action within a TCAM region. This register is not supported 2797 * by SwitchX and SwitchX-2. 2798 */ 2799 #define MLXSW_REG_PTCE2_ID 0x3017 2800 #define MLXSW_REG_PTCE2_LEN 0x1D8 2801 2802 MLXSW_REG_DEFINE(ptce2, MLXSW_REG_PTCE2_ID, MLXSW_REG_PTCE2_LEN); 2803 2804 /* reg_ptce2_v 2805 * Valid. 2806 * Access: RW 2807 */ 2808 MLXSW_ITEM32(reg, ptce2, v, 0x00, 31, 1); 2809 2810 /* reg_ptce2_a 2811 * Activity. Set if a packet lookup has hit on the specific entry. 2812 * To clear the "a" bit, use "clear activity" op or "clear on read" op. 2813 * Access: RO 2814 */ 2815 MLXSW_ITEM32(reg, ptce2, a, 0x00, 30, 1); 2816 2817 enum mlxsw_reg_ptce2_op { 2818 /* Read operation. */ 2819 MLXSW_REG_PTCE2_OP_QUERY_READ = 0, 2820 /* clear on read operation. Used to read entry 2821 * and clear Activity bit. 2822 */ 2823 MLXSW_REG_PTCE2_OP_QUERY_CLEAR_ON_READ = 1, 2824 /* Write operation. Used to write a new entry to the table. 2825 * All R/W fields are relevant for new entry. Activity bit is set 2826 * for new entries - Note write with v = 0 will delete the entry. 2827 */ 2828 MLXSW_REG_PTCE2_OP_WRITE_WRITE = 0, 2829 /* Update action. Only action set will be updated. */ 2830 MLXSW_REG_PTCE2_OP_WRITE_UPDATE = 1, 2831 /* Clear activity. A bit is cleared for the entry. */ 2832 MLXSW_REG_PTCE2_OP_WRITE_CLEAR_ACTIVITY = 2, 2833 }; 2834 2835 /* reg_ptce2_op 2836 * Access: OP 2837 */ 2838 MLXSW_ITEM32(reg, ptce2, op, 0x00, 20, 3); 2839 2840 /* reg_ptce2_offset 2841 * Access: Index 2842 */ 2843 MLXSW_ITEM32(reg, ptce2, offset, 0x00, 0, 16); 2844 2845 /* reg_ptce2_priority 2846 * Priority of the rule, higher values win. The range is 1..cap_kvd_size-1. 2847 * Note: priority does not have to be unique per rule. 2848 * Within a region, higher priority should have lower offset (no limitation 2849 * between regions in a multi-region). 2850 * Access: RW 2851 */ 2852 MLXSW_ITEM32(reg, ptce2, priority, 0x04, 0, 24); 2853 2854 /* reg_ptce2_tcam_region_info 2855 * Opaque object that represents the TCAM region. 2856 * Access: Index 2857 */ 2858 MLXSW_ITEM_BUF(reg, ptce2, tcam_region_info, 0x10, 2859 MLXSW_REG_PXXX_TCAM_REGION_INFO_LEN); 2860 2861 #define MLXSW_REG_PTCEX_FLEX_KEY_BLOCKS_LEN 96 2862 2863 /* reg_ptce2_flex_key_blocks 2864 * ACL Key. 2865 * Access: RW 2866 */ 2867 MLXSW_ITEM_BUF(reg, ptce2, flex_key_blocks, 0x20, 2868 MLXSW_REG_PTCEX_FLEX_KEY_BLOCKS_LEN); 2869 2870 /* reg_ptce2_mask 2871 * mask- in the same size as key. A bit that is set directs the TCAM 2872 * to compare the corresponding bit in key. A bit that is clear directs 2873 * the TCAM to ignore the corresponding bit in key. 2874 * Access: RW 2875 */ 2876 MLXSW_ITEM_BUF(reg, ptce2, mask, 0x80, 2877 MLXSW_REG_PTCEX_FLEX_KEY_BLOCKS_LEN); 2878 2879 /* reg_ptce2_flex_action_set 2880 * ACL action set. 2881 * Access: RW 2882 */ 2883 MLXSW_ITEM_BUF(reg, ptce2, flex_action_set, 0xE0, 2884 MLXSW_REG_FLEX_ACTION_SET_LEN); 2885 2886 static inline void mlxsw_reg_ptce2_pack(char *payload, bool valid, 2887 enum mlxsw_reg_ptce2_op op, 2888 const char *tcam_region_info, 2889 u16 offset, u32 priority) 2890 { 2891 MLXSW_REG_ZERO(ptce2, payload); 2892 mlxsw_reg_ptce2_v_set(payload, valid); 2893 mlxsw_reg_ptce2_op_set(payload, op); 2894 mlxsw_reg_ptce2_offset_set(payload, offset); 2895 mlxsw_reg_ptce2_priority_set(payload, priority); 2896 mlxsw_reg_ptce2_tcam_region_info_memcpy_to(payload, tcam_region_info); 2897 } 2898 2899 /* PERPT - Policy-Engine ERP Table Register 2900 * ---------------------------------------- 2901 * This register adds and removes eRPs from the eRP table. 2902 */ 2903 #define MLXSW_REG_PERPT_ID 0x3021 2904 #define MLXSW_REG_PERPT_LEN 0x80 2905 2906 MLXSW_REG_DEFINE(perpt, MLXSW_REG_PERPT_ID, MLXSW_REG_PERPT_LEN); 2907 2908 /* reg_perpt_erpt_bank 2909 * eRP table bank. 2910 * Range 0 .. cap_max_erp_table_banks - 1 2911 * Access: Index 2912 */ 2913 MLXSW_ITEM32(reg, perpt, erpt_bank, 0x00, 16, 4); 2914 2915 /* reg_perpt_erpt_index 2916 * Index to eRP table within the eRP bank. 2917 * Range is 0 .. cap_max_erp_table_bank_size - 1 2918 * Access: Index 2919 */ 2920 MLXSW_ITEM32(reg, perpt, erpt_index, 0x00, 0, 8); 2921 2922 enum mlxsw_reg_perpt_key_size { 2923 MLXSW_REG_PERPT_KEY_SIZE_2KB, 2924 MLXSW_REG_PERPT_KEY_SIZE_4KB, 2925 MLXSW_REG_PERPT_KEY_SIZE_8KB, 2926 MLXSW_REG_PERPT_KEY_SIZE_12KB, 2927 }; 2928 2929 /* reg_perpt_key_size 2930 * Access: OP 2931 */ 2932 MLXSW_ITEM32(reg, perpt, key_size, 0x04, 0, 4); 2933 2934 /* reg_perpt_bf_bypass 2935 * 0 - The eRP is used only if bloom filter state is set for the given 2936 * rule. 2937 * 1 - The eRP is used regardless of bloom filter state. 2938 * The bypass is an OR condition of region_id or eRP. See PERCR.bf_bypass 2939 * Access: RW 2940 */ 2941 MLXSW_ITEM32(reg, perpt, bf_bypass, 0x08, 8, 1); 2942 2943 /* reg_perpt_erp_id 2944 * eRP ID for use by the rules. 2945 * Access: RW 2946 */ 2947 MLXSW_ITEM32(reg, perpt, erp_id, 0x08, 0, 4); 2948 2949 /* reg_perpt_erpt_base_bank 2950 * Base eRP table bank, points to head of erp_vector 2951 * Range is 0 .. cap_max_erp_table_banks - 1 2952 * Access: OP 2953 */ 2954 MLXSW_ITEM32(reg, perpt, erpt_base_bank, 0x0C, 16, 4); 2955 2956 /* reg_perpt_erpt_base_index 2957 * Base index to eRP table within the eRP bank 2958 * Range is 0 .. cap_max_erp_table_bank_size - 1 2959 * Access: OP 2960 */ 2961 MLXSW_ITEM32(reg, perpt, erpt_base_index, 0x0C, 0, 8); 2962 2963 /* reg_perpt_erp_index_in_vector 2964 * eRP index in the vector. 2965 * Access: OP 2966 */ 2967 MLXSW_ITEM32(reg, perpt, erp_index_in_vector, 0x10, 0, 4); 2968 2969 /* reg_perpt_erp_vector 2970 * eRP vector. 2971 * Access: OP 2972 */ 2973 MLXSW_ITEM_BIT_ARRAY(reg, perpt, erp_vector, 0x14, 4, 1); 2974 2975 /* reg_perpt_mask 2976 * Mask 2977 * 0 - A-TCAM will ignore the bit in key 2978 * 1 - A-TCAM will compare the bit in key 2979 * Access: RW 2980 */ 2981 MLXSW_ITEM_BUF(reg, perpt, mask, 0x20, MLXSW_REG_PTCEX_FLEX_KEY_BLOCKS_LEN); 2982 2983 static inline void mlxsw_reg_perpt_erp_vector_pack(char *payload, 2984 unsigned long *erp_vector, 2985 unsigned long size) 2986 { 2987 unsigned long bit; 2988 2989 for_each_set_bit(bit, erp_vector, size) 2990 mlxsw_reg_perpt_erp_vector_set(payload, bit, true); 2991 } 2992 2993 static inline void 2994 mlxsw_reg_perpt_pack(char *payload, u8 erpt_bank, u8 erpt_index, 2995 enum mlxsw_reg_perpt_key_size key_size, u8 erp_id, 2996 u8 erpt_base_bank, u8 erpt_base_index, u8 erp_index, 2997 char *mask) 2998 { 2999 MLXSW_REG_ZERO(perpt, payload); 3000 mlxsw_reg_perpt_erpt_bank_set(payload, erpt_bank); 3001 mlxsw_reg_perpt_erpt_index_set(payload, erpt_index); 3002 mlxsw_reg_perpt_key_size_set(payload, key_size); 3003 mlxsw_reg_perpt_bf_bypass_set(payload, false); 3004 mlxsw_reg_perpt_erp_id_set(payload, erp_id); 3005 mlxsw_reg_perpt_erpt_base_bank_set(payload, erpt_base_bank); 3006 mlxsw_reg_perpt_erpt_base_index_set(payload, erpt_base_index); 3007 mlxsw_reg_perpt_erp_index_in_vector_set(payload, erp_index); 3008 mlxsw_reg_perpt_mask_memcpy_to(payload, mask); 3009 } 3010 3011 /* PERAR - Policy-Engine Region Association Register 3012 * ------------------------------------------------- 3013 * This register associates a hw region for region_id's. Changing on the fly 3014 * is supported by the device. 3015 */ 3016 #define MLXSW_REG_PERAR_ID 0x3026 3017 #define MLXSW_REG_PERAR_LEN 0x08 3018 3019 MLXSW_REG_DEFINE(perar, MLXSW_REG_PERAR_ID, MLXSW_REG_PERAR_LEN); 3020 3021 /* reg_perar_region_id 3022 * Region identifier 3023 * Range 0 .. cap_max_regions-1 3024 * Access: Index 3025 */ 3026 MLXSW_ITEM32(reg, perar, region_id, 0x00, 0, 16); 3027 3028 static inline unsigned int 3029 mlxsw_reg_perar_hw_regions_needed(unsigned int block_num) 3030 { 3031 return DIV_ROUND_UP(block_num, 4); 3032 } 3033 3034 /* reg_perar_hw_region 3035 * HW Region 3036 * Range 0 .. cap_max_regions-1 3037 * Default: hw_region = region_id 3038 * For a 8 key block region, 2 consecutive regions are used 3039 * For a 12 key block region, 3 consecutive regions are used 3040 * Access: RW 3041 */ 3042 MLXSW_ITEM32(reg, perar, hw_region, 0x04, 0, 16); 3043 3044 static inline void mlxsw_reg_perar_pack(char *payload, u16 region_id, 3045 u16 hw_region) 3046 { 3047 MLXSW_REG_ZERO(perar, payload); 3048 mlxsw_reg_perar_region_id_set(payload, region_id); 3049 mlxsw_reg_perar_hw_region_set(payload, hw_region); 3050 } 3051 3052 /* PTCE-V3 - Policy-Engine TCAM Entry Register Version 3 3053 * ----------------------------------------------------- 3054 * This register is a new version of PTCE-V2 in order to support the 3055 * A-TCAM. This register is not supported by SwitchX/-2 and Spectrum. 3056 */ 3057 #define MLXSW_REG_PTCE3_ID 0x3027 3058 #define MLXSW_REG_PTCE3_LEN 0xF0 3059 3060 MLXSW_REG_DEFINE(ptce3, MLXSW_REG_PTCE3_ID, MLXSW_REG_PTCE3_LEN); 3061 3062 /* reg_ptce3_v 3063 * Valid. 3064 * Access: RW 3065 */ 3066 MLXSW_ITEM32(reg, ptce3, v, 0x00, 31, 1); 3067 3068 enum mlxsw_reg_ptce3_op { 3069 /* Write operation. Used to write a new entry to the table. 3070 * All R/W fields are relevant for new entry. Activity bit is set 3071 * for new entries. Write with v = 0 will delete the entry. Must 3072 * not be used if an entry exists. 3073 */ 3074 MLXSW_REG_PTCE3_OP_WRITE_WRITE = 0, 3075 /* Update operation */ 3076 MLXSW_REG_PTCE3_OP_WRITE_UPDATE = 1, 3077 /* Read operation */ 3078 MLXSW_REG_PTCE3_OP_QUERY_READ = 0, 3079 }; 3080 3081 /* reg_ptce3_op 3082 * Access: OP 3083 */ 3084 MLXSW_ITEM32(reg, ptce3, op, 0x00, 20, 3); 3085 3086 /* reg_ptce3_priority 3087 * Priority of the rule. Higher values win. 3088 * For Spectrum-2 range is 1..cap_kvd_size - 1 3089 * Note: Priority does not have to be unique per rule. 3090 * Access: RW 3091 */ 3092 MLXSW_ITEM32(reg, ptce3, priority, 0x04, 0, 24); 3093 3094 /* reg_ptce3_tcam_region_info 3095 * Opaque object that represents the TCAM region. 3096 * Access: Index 3097 */ 3098 MLXSW_ITEM_BUF(reg, ptce3, tcam_region_info, 0x10, 3099 MLXSW_REG_PXXX_TCAM_REGION_INFO_LEN); 3100 3101 /* reg_ptce3_flex2_key_blocks 3102 * ACL key. The key must be masked according to eRP (if exists) or 3103 * according to master mask. 3104 * Access: Index 3105 */ 3106 MLXSW_ITEM_BUF(reg, ptce3, flex2_key_blocks, 0x20, 3107 MLXSW_REG_PTCEX_FLEX_KEY_BLOCKS_LEN); 3108 3109 /* reg_ptce3_erp_id 3110 * eRP ID. 3111 * Access: Index 3112 */ 3113 MLXSW_ITEM32(reg, ptce3, erp_id, 0x80, 0, 4); 3114 3115 /* reg_ptce3_delta_start 3116 * Start point of delta_value and delta_mask, in bits. Must not exceed 3117 * num_key_blocks * 36 - 8. Reserved when delta_mask = 0. 3118 * Access: Index 3119 */ 3120 MLXSW_ITEM32(reg, ptce3, delta_start, 0x84, 0, 10); 3121 3122 /* reg_ptce3_delta_mask 3123 * Delta mask. 3124 * 0 - Ignore relevant bit in delta_value 3125 * 1 - Compare relevant bit in delta_value 3126 * Delta mask must not be set for reserved fields in the key blocks. 3127 * Note: No delta when no eRPs. Thus, for regions with 3128 * PERERP.erpt_pointer_valid = 0 the delta mask must be 0. 3129 * Access: Index 3130 */ 3131 MLXSW_ITEM32(reg, ptce3, delta_mask, 0x88, 16, 8); 3132 3133 /* reg_ptce3_delta_value 3134 * Delta value. 3135 * Bits which are masked by delta_mask must be 0. 3136 * Access: Index 3137 */ 3138 MLXSW_ITEM32(reg, ptce3, delta_value, 0x88, 0, 8); 3139 3140 /* reg_ptce3_prune_vector 3141 * Pruning vector relative to the PERPT.erp_id. 3142 * Used for reducing lookups. 3143 * 0 - NEED: Do a lookup using the eRP. 3144 * 1 - PRUNE: Do not perform a lookup using the eRP. 3145 * Maybe be modified by PEAPBL and PEAPBM. 3146 * Note: In Spectrum-2, a region of 8 key blocks must be set to either 3147 * all 1's or all 0's. 3148 * Access: RW 3149 */ 3150 MLXSW_ITEM_BIT_ARRAY(reg, ptce3, prune_vector, 0x90, 4, 1); 3151 3152 /* reg_ptce3_prune_ctcam 3153 * Pruning on C-TCAM. Used for reducing lookups. 3154 * 0 - NEED: Do a lookup in the C-TCAM. 3155 * 1 - PRUNE: Do not perform a lookup in the C-TCAM. 3156 * Access: RW 3157 */ 3158 MLXSW_ITEM32(reg, ptce3, prune_ctcam, 0x94, 31, 1); 3159 3160 /* reg_ptce3_large_exists 3161 * Large entry key ID exists. 3162 * Within the region: 3163 * 0 - SINGLE: The large_entry_key_id is not currently in use. 3164 * For rule insert: The MSB of the key (blocks 6..11) will be added. 3165 * For rule delete: The MSB of the key will be removed. 3166 * 1 - NON_SINGLE: The large_entry_key_id is currently in use. 3167 * For rule insert: The MSB of the key (blocks 6..11) will not be added. 3168 * For rule delete: The MSB of the key will not be removed. 3169 * Access: WO 3170 */ 3171 MLXSW_ITEM32(reg, ptce3, large_exists, 0x98, 31, 1); 3172 3173 /* reg_ptce3_large_entry_key_id 3174 * Large entry key ID. 3175 * A key for 12 key blocks rules. Reserved when region has less than 12 key 3176 * blocks. Must be different for different keys which have the same common 3177 * 6 key blocks (MSB, blocks 6..11) key within a region. 3178 * Range is 0..cap_max_pe_large_key_id - 1 3179 * Access: RW 3180 */ 3181 MLXSW_ITEM32(reg, ptce3, large_entry_key_id, 0x98, 0, 24); 3182 3183 /* reg_ptce3_action_pointer 3184 * Pointer to action. 3185 * Range is 0..cap_max_kvd_action_sets - 1 3186 * Access: RW 3187 */ 3188 MLXSW_ITEM32(reg, ptce3, action_pointer, 0xA0, 0, 24); 3189 3190 static inline void mlxsw_reg_ptce3_pack(char *payload, bool valid, 3191 enum mlxsw_reg_ptce3_op op, 3192 u32 priority, 3193 const char *tcam_region_info, 3194 const char *key, u8 erp_id, 3195 u16 delta_start, u8 delta_mask, 3196 u8 delta_value, bool large_exists, 3197 u32 lkey_id, u32 action_pointer) 3198 { 3199 MLXSW_REG_ZERO(ptce3, payload); 3200 mlxsw_reg_ptce3_v_set(payload, valid); 3201 mlxsw_reg_ptce3_op_set(payload, op); 3202 mlxsw_reg_ptce3_priority_set(payload, priority); 3203 mlxsw_reg_ptce3_tcam_region_info_memcpy_to(payload, tcam_region_info); 3204 mlxsw_reg_ptce3_flex2_key_blocks_memcpy_to(payload, key); 3205 mlxsw_reg_ptce3_erp_id_set(payload, erp_id); 3206 mlxsw_reg_ptce3_delta_start_set(payload, delta_start); 3207 mlxsw_reg_ptce3_delta_mask_set(payload, delta_mask); 3208 mlxsw_reg_ptce3_delta_value_set(payload, delta_value); 3209 mlxsw_reg_ptce3_large_exists_set(payload, large_exists); 3210 mlxsw_reg_ptce3_large_entry_key_id_set(payload, lkey_id); 3211 mlxsw_reg_ptce3_action_pointer_set(payload, action_pointer); 3212 } 3213 3214 /* PERCR - Policy-Engine Region Configuration Register 3215 * --------------------------------------------------- 3216 * This register configures the region parameters. The region_id must be 3217 * allocated. 3218 */ 3219 #define MLXSW_REG_PERCR_ID 0x302A 3220 #define MLXSW_REG_PERCR_LEN 0x80 3221 3222 MLXSW_REG_DEFINE(percr, MLXSW_REG_PERCR_ID, MLXSW_REG_PERCR_LEN); 3223 3224 /* reg_percr_region_id 3225 * Region identifier. 3226 * Range 0..cap_max_regions-1 3227 * Access: Index 3228 */ 3229 MLXSW_ITEM32(reg, percr, region_id, 0x00, 0, 16); 3230 3231 /* reg_percr_atcam_ignore_prune 3232 * Ignore prune_vector by other A-TCAM rules. Used e.g., for a new rule. 3233 * Access: RW 3234 */ 3235 MLXSW_ITEM32(reg, percr, atcam_ignore_prune, 0x04, 25, 1); 3236 3237 /* reg_percr_ctcam_ignore_prune 3238 * Ignore prune_ctcam by other A-TCAM rules. Used e.g., for a new rule. 3239 * Access: RW 3240 */ 3241 MLXSW_ITEM32(reg, percr, ctcam_ignore_prune, 0x04, 24, 1); 3242 3243 /* reg_percr_bf_bypass 3244 * Bloom filter bypass. 3245 * 0 - Bloom filter is used (default) 3246 * 1 - Bloom filter is bypassed. The bypass is an OR condition of 3247 * region_id or eRP. See PERPT.bf_bypass 3248 * Access: RW 3249 */ 3250 MLXSW_ITEM32(reg, percr, bf_bypass, 0x04, 16, 1); 3251 3252 /* reg_percr_master_mask 3253 * Master mask. Logical OR mask of all masks of all rules of a region 3254 * (both A-TCAM and C-TCAM). When there are no eRPs 3255 * (erpt_pointer_valid = 0), then this provides the mask. 3256 * Access: RW 3257 */ 3258 MLXSW_ITEM_BUF(reg, percr, master_mask, 0x20, 96); 3259 3260 static inline void mlxsw_reg_percr_pack(char *payload, u16 region_id) 3261 { 3262 MLXSW_REG_ZERO(percr, payload); 3263 mlxsw_reg_percr_region_id_set(payload, region_id); 3264 mlxsw_reg_percr_atcam_ignore_prune_set(payload, false); 3265 mlxsw_reg_percr_ctcam_ignore_prune_set(payload, false); 3266 mlxsw_reg_percr_bf_bypass_set(payload, false); 3267 } 3268 3269 /* PERERP - Policy-Engine Region eRP Register 3270 * ------------------------------------------ 3271 * This register configures the region eRP. The region_id must be 3272 * allocated. 3273 */ 3274 #define MLXSW_REG_PERERP_ID 0x302B 3275 #define MLXSW_REG_PERERP_LEN 0x1C 3276 3277 MLXSW_REG_DEFINE(pererp, MLXSW_REG_PERERP_ID, MLXSW_REG_PERERP_LEN); 3278 3279 /* reg_pererp_region_id 3280 * Region identifier. 3281 * Range 0..cap_max_regions-1 3282 * Access: Index 3283 */ 3284 MLXSW_ITEM32(reg, pererp, region_id, 0x00, 0, 16); 3285 3286 /* reg_pererp_ctcam_le 3287 * C-TCAM lookup enable. Reserved when erpt_pointer_valid = 0. 3288 * Access: RW 3289 */ 3290 MLXSW_ITEM32(reg, pererp, ctcam_le, 0x04, 28, 1); 3291 3292 /* reg_pererp_erpt_pointer_valid 3293 * erpt_pointer is valid. 3294 * Access: RW 3295 */ 3296 MLXSW_ITEM32(reg, pererp, erpt_pointer_valid, 0x10, 31, 1); 3297 3298 /* reg_pererp_erpt_bank_pointer 3299 * Pointer to eRP table bank. May be modified at any time. 3300 * Range 0..cap_max_erp_table_banks-1 3301 * Reserved when erpt_pointer_valid = 0 3302 */ 3303 MLXSW_ITEM32(reg, pererp, erpt_bank_pointer, 0x10, 16, 4); 3304 3305 /* reg_pererp_erpt_pointer 3306 * Pointer to eRP table within the eRP bank. Can be changed for an 3307 * existing region. 3308 * Range 0..cap_max_erp_table_size-1 3309 * Reserved when erpt_pointer_valid = 0 3310 * Access: RW 3311 */ 3312 MLXSW_ITEM32(reg, pererp, erpt_pointer, 0x10, 0, 8); 3313 3314 /* reg_pererp_erpt_vector 3315 * Vector of allowed eRP indexes starting from erpt_pointer within the 3316 * erpt_bank_pointer. Next entries will be in next bank. 3317 * Note that eRP index is used and not eRP ID. 3318 * Reserved when erpt_pointer_valid = 0 3319 * Access: RW 3320 */ 3321 MLXSW_ITEM_BIT_ARRAY(reg, pererp, erpt_vector, 0x14, 4, 1); 3322 3323 /* reg_pererp_master_rp_id 3324 * Master RP ID. When there are no eRPs, then this provides the eRP ID 3325 * for the lookup. Can be changed for an existing region. 3326 * Reserved when erpt_pointer_valid = 1 3327 * Access: RW 3328 */ 3329 MLXSW_ITEM32(reg, pererp, master_rp_id, 0x18, 0, 4); 3330 3331 static inline void mlxsw_reg_pererp_erp_vector_pack(char *payload, 3332 unsigned long *erp_vector, 3333 unsigned long size) 3334 { 3335 unsigned long bit; 3336 3337 for_each_set_bit(bit, erp_vector, size) 3338 mlxsw_reg_pererp_erpt_vector_set(payload, bit, true); 3339 } 3340 3341 static inline void mlxsw_reg_pererp_pack(char *payload, u16 region_id, 3342 bool ctcam_le, bool erpt_pointer_valid, 3343 u8 erpt_bank_pointer, u8 erpt_pointer, 3344 u8 master_rp_id) 3345 { 3346 MLXSW_REG_ZERO(pererp, payload); 3347 mlxsw_reg_pererp_region_id_set(payload, region_id); 3348 mlxsw_reg_pererp_ctcam_le_set(payload, ctcam_le); 3349 mlxsw_reg_pererp_erpt_pointer_valid_set(payload, erpt_pointer_valid); 3350 mlxsw_reg_pererp_erpt_bank_pointer_set(payload, erpt_bank_pointer); 3351 mlxsw_reg_pererp_erpt_pointer_set(payload, erpt_pointer); 3352 mlxsw_reg_pererp_master_rp_id_set(payload, master_rp_id); 3353 } 3354 3355 /* PEABFE - Policy-Engine Algorithmic Bloom Filter Entries Register 3356 * ---------------------------------------------------------------- 3357 * This register configures the Bloom filter entries. 3358 */ 3359 #define MLXSW_REG_PEABFE_ID 0x3022 3360 #define MLXSW_REG_PEABFE_BASE_LEN 0x10 3361 #define MLXSW_REG_PEABFE_BF_REC_LEN 0x4 3362 #define MLXSW_REG_PEABFE_BF_REC_MAX_COUNT 256 3363 #define MLXSW_REG_PEABFE_LEN (MLXSW_REG_PEABFE_BASE_LEN + \ 3364 MLXSW_REG_PEABFE_BF_REC_LEN * \ 3365 MLXSW_REG_PEABFE_BF_REC_MAX_COUNT) 3366 3367 MLXSW_REG_DEFINE(peabfe, MLXSW_REG_PEABFE_ID, MLXSW_REG_PEABFE_LEN); 3368 3369 /* reg_peabfe_size 3370 * Number of BF entries to be updated. 3371 * Range 1..256 3372 * Access: Op 3373 */ 3374 MLXSW_ITEM32(reg, peabfe, size, 0x00, 0, 9); 3375 3376 /* reg_peabfe_bf_entry_state 3377 * Bloom filter state 3378 * 0 - Clear 3379 * 1 - Set 3380 * Access: RW 3381 */ 3382 MLXSW_ITEM32_INDEXED(reg, peabfe, bf_entry_state, 3383 MLXSW_REG_PEABFE_BASE_LEN, 31, 1, 3384 MLXSW_REG_PEABFE_BF_REC_LEN, 0x00, false); 3385 3386 /* reg_peabfe_bf_entry_bank 3387 * Bloom filter bank ID 3388 * Range 0..cap_max_erp_table_banks-1 3389 * Access: Index 3390 */ 3391 MLXSW_ITEM32_INDEXED(reg, peabfe, bf_entry_bank, 3392 MLXSW_REG_PEABFE_BASE_LEN, 24, 4, 3393 MLXSW_REG_PEABFE_BF_REC_LEN, 0x00, false); 3394 3395 /* reg_peabfe_bf_entry_index 3396 * Bloom filter entry index 3397 * Range 0..2^cap_max_bf_log-1 3398 * Access: Index 3399 */ 3400 MLXSW_ITEM32_INDEXED(reg, peabfe, bf_entry_index, 3401 MLXSW_REG_PEABFE_BASE_LEN, 0, 24, 3402 MLXSW_REG_PEABFE_BF_REC_LEN, 0x00, false); 3403 3404 static inline void mlxsw_reg_peabfe_pack(char *payload) 3405 { 3406 MLXSW_REG_ZERO(peabfe, payload); 3407 } 3408 3409 static inline void mlxsw_reg_peabfe_rec_pack(char *payload, int rec_index, 3410 u8 state, u8 bank, u32 bf_index) 3411 { 3412 u8 num_rec = mlxsw_reg_peabfe_size_get(payload); 3413 3414 if (rec_index >= num_rec) 3415 mlxsw_reg_peabfe_size_set(payload, rec_index + 1); 3416 mlxsw_reg_peabfe_bf_entry_state_set(payload, rec_index, state); 3417 mlxsw_reg_peabfe_bf_entry_bank_set(payload, rec_index, bank); 3418 mlxsw_reg_peabfe_bf_entry_index_set(payload, rec_index, bf_index); 3419 } 3420 3421 /* IEDR - Infrastructure Entry Delete Register 3422 * ---------------------------------------------------- 3423 * This register is used for deleting entries from the entry tables. 3424 * It is legitimate to attempt to delete a nonexisting entry (the device will 3425 * respond as a good flow). 3426 */ 3427 #define MLXSW_REG_IEDR_ID 0x3804 3428 #define MLXSW_REG_IEDR_BASE_LEN 0x10 /* base length, without records */ 3429 #define MLXSW_REG_IEDR_REC_LEN 0x8 /* record length */ 3430 #define MLXSW_REG_IEDR_REC_MAX_COUNT 64 3431 #define MLXSW_REG_IEDR_LEN (MLXSW_REG_IEDR_BASE_LEN + \ 3432 MLXSW_REG_IEDR_REC_LEN * \ 3433 MLXSW_REG_IEDR_REC_MAX_COUNT) 3434 3435 MLXSW_REG_DEFINE(iedr, MLXSW_REG_IEDR_ID, MLXSW_REG_IEDR_LEN); 3436 3437 /* reg_iedr_num_rec 3438 * Number of records. 3439 * Access: OP 3440 */ 3441 MLXSW_ITEM32(reg, iedr, num_rec, 0x00, 0, 8); 3442 3443 /* reg_iedr_rec_type 3444 * Resource type. 3445 * Access: OP 3446 */ 3447 MLXSW_ITEM32_INDEXED(reg, iedr, rec_type, MLXSW_REG_IEDR_BASE_LEN, 24, 8, 3448 MLXSW_REG_IEDR_REC_LEN, 0x00, false); 3449 3450 /* reg_iedr_rec_size 3451 * Size of entries do be deleted. The unit is 1 entry, regardless of entry type. 3452 * Access: OP 3453 */ 3454 MLXSW_ITEM32_INDEXED(reg, iedr, rec_size, MLXSW_REG_IEDR_BASE_LEN, 0, 13, 3455 MLXSW_REG_IEDR_REC_LEN, 0x00, false); 3456 3457 /* reg_iedr_rec_index_start 3458 * Resource index start. 3459 * Access: OP 3460 */ 3461 MLXSW_ITEM32_INDEXED(reg, iedr, rec_index_start, MLXSW_REG_IEDR_BASE_LEN, 0, 24, 3462 MLXSW_REG_IEDR_REC_LEN, 0x04, false); 3463 3464 static inline void mlxsw_reg_iedr_pack(char *payload) 3465 { 3466 MLXSW_REG_ZERO(iedr, payload); 3467 } 3468 3469 static inline void mlxsw_reg_iedr_rec_pack(char *payload, int rec_index, 3470 u8 rec_type, u16 rec_size, 3471 u32 rec_index_start) 3472 { 3473 u8 num_rec = mlxsw_reg_iedr_num_rec_get(payload); 3474 3475 if (rec_index >= num_rec) 3476 mlxsw_reg_iedr_num_rec_set(payload, rec_index + 1); 3477 mlxsw_reg_iedr_rec_type_set(payload, rec_index, rec_type); 3478 mlxsw_reg_iedr_rec_size_set(payload, rec_index, rec_size); 3479 mlxsw_reg_iedr_rec_index_start_set(payload, rec_index, rec_index_start); 3480 } 3481 3482 /* QPTS - QoS Priority Trust State Register 3483 * ---------------------------------------- 3484 * This register controls the port policy to calculate the switch priority and 3485 * packet color based on incoming packet fields. 3486 */ 3487 #define MLXSW_REG_QPTS_ID 0x4002 3488 #define MLXSW_REG_QPTS_LEN 0x8 3489 3490 MLXSW_REG_DEFINE(qpts, MLXSW_REG_QPTS_ID, MLXSW_REG_QPTS_LEN); 3491 3492 /* reg_qpts_local_port 3493 * Local port number. 3494 * Access: Index 3495 * 3496 * Note: CPU port is supported. 3497 */ 3498 MLXSW_ITEM32_LP(reg, qpts, 0x00, 16, 0x00, 12); 3499 3500 enum mlxsw_reg_qpts_trust_state { 3501 MLXSW_REG_QPTS_TRUST_STATE_PCP = 1, 3502 MLXSW_REG_QPTS_TRUST_STATE_DSCP = 2, /* For MPLS, trust EXP. */ 3503 }; 3504 3505 /* reg_qpts_trust_state 3506 * Trust state for a given port. 3507 * Access: RW 3508 */ 3509 MLXSW_ITEM32(reg, qpts, trust_state, 0x04, 0, 3); 3510 3511 static inline void mlxsw_reg_qpts_pack(char *payload, u16 local_port, 3512 enum mlxsw_reg_qpts_trust_state ts) 3513 { 3514 MLXSW_REG_ZERO(qpts, payload); 3515 3516 mlxsw_reg_qpts_local_port_set(payload, local_port); 3517 mlxsw_reg_qpts_trust_state_set(payload, ts); 3518 } 3519 3520 /* QPCR - QoS Policer Configuration Register 3521 * ----------------------------------------- 3522 * The QPCR register is used to create policers - that limit 3523 * the rate of bytes or packets via some trap group. 3524 */ 3525 #define MLXSW_REG_QPCR_ID 0x4004 3526 #define MLXSW_REG_QPCR_LEN 0x28 3527 3528 MLXSW_REG_DEFINE(qpcr, MLXSW_REG_QPCR_ID, MLXSW_REG_QPCR_LEN); 3529 3530 enum mlxsw_reg_qpcr_g { 3531 MLXSW_REG_QPCR_G_GLOBAL = 2, 3532 MLXSW_REG_QPCR_G_STORM_CONTROL = 3, 3533 }; 3534 3535 /* reg_qpcr_g 3536 * The policer type. 3537 * Access: Index 3538 */ 3539 MLXSW_ITEM32(reg, qpcr, g, 0x00, 14, 2); 3540 3541 /* reg_qpcr_pid 3542 * Policer ID. 3543 * Access: Index 3544 */ 3545 MLXSW_ITEM32(reg, qpcr, pid, 0x00, 0, 14); 3546 3547 /* reg_qpcr_clear_counter 3548 * Clear counters. 3549 * Access: OP 3550 */ 3551 MLXSW_ITEM32(reg, qpcr, clear_counter, 0x04, 31, 1); 3552 3553 /* reg_qpcr_color_aware 3554 * Is the policer aware of colors. 3555 * Must be 0 (unaware) for cpu port. 3556 * Access: RW for unbounded policer. RO for bounded policer. 3557 */ 3558 MLXSW_ITEM32(reg, qpcr, color_aware, 0x04, 15, 1); 3559 3560 /* reg_qpcr_bytes 3561 * Is policer limit is for bytes per sec or packets per sec. 3562 * 0 - packets 3563 * 1 - bytes 3564 * Access: RW for unbounded policer. RO for bounded policer. 3565 */ 3566 MLXSW_ITEM32(reg, qpcr, bytes, 0x04, 14, 1); 3567 3568 enum mlxsw_reg_qpcr_ir_units { 3569 MLXSW_REG_QPCR_IR_UNITS_M, 3570 MLXSW_REG_QPCR_IR_UNITS_K, 3571 }; 3572 3573 /* reg_qpcr_ir_units 3574 * Policer's units for cir and eir fields (for bytes limits only) 3575 * 1 - 10^3 3576 * 0 - 10^6 3577 * Access: OP 3578 */ 3579 MLXSW_ITEM32(reg, qpcr, ir_units, 0x04, 12, 1); 3580 3581 enum mlxsw_reg_qpcr_rate_type { 3582 MLXSW_REG_QPCR_RATE_TYPE_SINGLE = 1, 3583 MLXSW_REG_QPCR_RATE_TYPE_DOUBLE = 2, 3584 }; 3585 3586 /* reg_qpcr_rate_type 3587 * Policer can have one limit (single rate) or 2 limits with specific operation 3588 * for packets that exceed the lower rate but not the upper one. 3589 * (For cpu port must be single rate) 3590 * Access: RW for unbounded policer. RO for bounded policer. 3591 */ 3592 MLXSW_ITEM32(reg, qpcr, rate_type, 0x04, 8, 2); 3593 3594 /* reg_qpc_cbs 3595 * Policer's committed burst size. 3596 * The policer is working with time slices of 50 nano sec. By default every 3597 * slice is granted the proportionate share of the committed rate. If we want to 3598 * allow a slice to exceed that share (while still keeping the rate per sec) we 3599 * can allow burst. The burst size is between the default proportionate share 3600 * (and no lower than 8) to 32Gb. (Even though giving a number higher than the 3601 * committed rate will result in exceeding the rate). The burst size must be a 3602 * log of 2 and will be determined by 2^cbs. 3603 * Access: RW 3604 */ 3605 MLXSW_ITEM32(reg, qpcr, cbs, 0x08, 24, 6); 3606 3607 /* reg_qpcr_cir 3608 * Policer's committed rate. 3609 * The rate used for sungle rate, the lower rate for double rate. 3610 * For bytes limits, the rate will be this value * the unit from ir_units. 3611 * (Resolution error is up to 1%). 3612 * Access: RW 3613 */ 3614 MLXSW_ITEM32(reg, qpcr, cir, 0x0C, 0, 32); 3615 3616 /* reg_qpcr_eir 3617 * Policer's exceed rate. 3618 * The higher rate for double rate, reserved for single rate. 3619 * Lower rate for double rate policer. 3620 * For bytes limits, the rate will be this value * the unit from ir_units. 3621 * (Resolution error is up to 1%). 3622 * Access: RW 3623 */ 3624 MLXSW_ITEM32(reg, qpcr, eir, 0x10, 0, 32); 3625 3626 #define MLXSW_REG_QPCR_DOUBLE_RATE_ACTION 2 3627 3628 /* reg_qpcr_exceed_action. 3629 * What to do with packets between the 2 limits for double rate. 3630 * Access: RW for unbounded policer. RO for bounded policer. 3631 */ 3632 MLXSW_ITEM32(reg, qpcr, exceed_action, 0x14, 0, 4); 3633 3634 enum mlxsw_reg_qpcr_action { 3635 /* Discard */ 3636 MLXSW_REG_QPCR_ACTION_DISCARD = 1, 3637 /* Forward and set color to red. 3638 * If the packet is intended to cpu port, it will be dropped. 3639 */ 3640 MLXSW_REG_QPCR_ACTION_FORWARD = 2, 3641 }; 3642 3643 /* reg_qpcr_violate_action 3644 * What to do with packets that cross the cir limit (for single rate) or the eir 3645 * limit (for double rate). 3646 * Access: RW for unbounded policer. RO for bounded policer. 3647 */ 3648 MLXSW_ITEM32(reg, qpcr, violate_action, 0x18, 0, 4); 3649 3650 /* reg_qpcr_violate_count 3651 * Counts the number of times violate_action happened on this PID. 3652 * Access: RW 3653 */ 3654 MLXSW_ITEM64(reg, qpcr, violate_count, 0x20, 0, 64); 3655 3656 /* Packets */ 3657 #define MLXSW_REG_QPCR_LOWEST_CIR 1 3658 #define MLXSW_REG_QPCR_HIGHEST_CIR (2 * 1000 * 1000 * 1000) /* 2Gpps */ 3659 #define MLXSW_REG_QPCR_LOWEST_CBS 4 3660 #define MLXSW_REG_QPCR_HIGHEST_CBS 24 3661 3662 /* Bandwidth */ 3663 #define MLXSW_REG_QPCR_LOWEST_CIR_BITS 1024 /* bps */ 3664 #define MLXSW_REG_QPCR_HIGHEST_CIR_BITS 2000000000000ULL /* 2Tbps */ 3665 #define MLXSW_REG_QPCR_LOWEST_CBS_BITS_SP1 4 3666 #define MLXSW_REG_QPCR_LOWEST_CBS_BITS_SP2 4 3667 #define MLXSW_REG_QPCR_HIGHEST_CBS_BITS_SP1 25 3668 #define MLXSW_REG_QPCR_HIGHEST_CBS_BITS_SP2 31 3669 3670 static inline void mlxsw_reg_qpcr_pack(char *payload, u16 pid, 3671 enum mlxsw_reg_qpcr_ir_units ir_units, 3672 bool bytes, u32 cir, u16 cbs) 3673 { 3674 MLXSW_REG_ZERO(qpcr, payload); 3675 mlxsw_reg_qpcr_pid_set(payload, pid); 3676 mlxsw_reg_qpcr_g_set(payload, MLXSW_REG_QPCR_G_GLOBAL); 3677 mlxsw_reg_qpcr_rate_type_set(payload, MLXSW_REG_QPCR_RATE_TYPE_SINGLE); 3678 mlxsw_reg_qpcr_violate_action_set(payload, 3679 MLXSW_REG_QPCR_ACTION_DISCARD); 3680 mlxsw_reg_qpcr_cir_set(payload, cir); 3681 mlxsw_reg_qpcr_ir_units_set(payload, ir_units); 3682 mlxsw_reg_qpcr_bytes_set(payload, bytes); 3683 mlxsw_reg_qpcr_cbs_set(payload, cbs); 3684 } 3685 3686 /* QTCT - QoS Switch Traffic Class Table 3687 * ------------------------------------- 3688 * Configures the mapping between the packet switch priority and the 3689 * traffic class on the transmit port. 3690 */ 3691 #define MLXSW_REG_QTCT_ID 0x400A 3692 #define MLXSW_REG_QTCT_LEN 0x08 3693 3694 MLXSW_REG_DEFINE(qtct, MLXSW_REG_QTCT_ID, MLXSW_REG_QTCT_LEN); 3695 3696 /* reg_qtct_local_port 3697 * Local port number. 3698 * Access: Index 3699 * 3700 * Note: CPU port is not supported. 3701 */ 3702 MLXSW_ITEM32_LP(reg, qtct, 0x00, 16, 0x00, 12); 3703 3704 /* reg_qtct_sub_port 3705 * Virtual port within the physical port. 3706 * Should be set to 0 when virtual ports are not enabled on the port. 3707 * Access: Index 3708 */ 3709 MLXSW_ITEM32(reg, qtct, sub_port, 0x00, 8, 8); 3710 3711 /* reg_qtct_switch_prio 3712 * Switch priority. 3713 * Access: Index 3714 */ 3715 MLXSW_ITEM32(reg, qtct, switch_prio, 0x00, 0, 4); 3716 3717 /* reg_qtct_tclass 3718 * Traffic class. 3719 * Default values: 3720 * switch_prio 0 : tclass 1 3721 * switch_prio 1 : tclass 0 3722 * switch_prio i : tclass i, for i > 1 3723 * Access: RW 3724 */ 3725 MLXSW_ITEM32(reg, qtct, tclass, 0x04, 0, 4); 3726 3727 static inline void mlxsw_reg_qtct_pack(char *payload, u16 local_port, 3728 u8 switch_prio, u8 tclass) 3729 { 3730 MLXSW_REG_ZERO(qtct, payload); 3731 mlxsw_reg_qtct_local_port_set(payload, local_port); 3732 mlxsw_reg_qtct_switch_prio_set(payload, switch_prio); 3733 mlxsw_reg_qtct_tclass_set(payload, tclass); 3734 } 3735 3736 /* QEEC - QoS ETS Element Configuration Register 3737 * --------------------------------------------- 3738 * Configures the ETS elements. 3739 */ 3740 #define MLXSW_REG_QEEC_ID 0x400D 3741 #define MLXSW_REG_QEEC_LEN 0x20 3742 3743 MLXSW_REG_DEFINE(qeec, MLXSW_REG_QEEC_ID, MLXSW_REG_QEEC_LEN); 3744 3745 /* reg_qeec_local_port 3746 * Local port number. 3747 * Access: Index 3748 * 3749 * Note: CPU port is supported. 3750 */ 3751 MLXSW_ITEM32_LP(reg, qeec, 0x00, 16, 0x00, 12); 3752 3753 enum mlxsw_reg_qeec_hr { 3754 MLXSW_REG_QEEC_HR_PORT, 3755 MLXSW_REG_QEEC_HR_GROUP, 3756 MLXSW_REG_QEEC_HR_SUBGROUP, 3757 MLXSW_REG_QEEC_HR_TC, 3758 }; 3759 3760 /* reg_qeec_element_hierarchy 3761 * 0 - Port 3762 * 1 - Group 3763 * 2 - Subgroup 3764 * 3 - Traffic Class 3765 * Access: Index 3766 */ 3767 MLXSW_ITEM32(reg, qeec, element_hierarchy, 0x04, 16, 4); 3768 3769 /* reg_qeec_element_index 3770 * The index of the element in the hierarchy. 3771 * Access: Index 3772 */ 3773 MLXSW_ITEM32(reg, qeec, element_index, 0x04, 0, 8); 3774 3775 /* reg_qeec_next_element_index 3776 * The index of the next (lower) element in the hierarchy. 3777 * Access: RW 3778 * 3779 * Note: Reserved for element_hierarchy 0. 3780 */ 3781 MLXSW_ITEM32(reg, qeec, next_element_index, 0x08, 0, 8); 3782 3783 /* reg_qeec_mise 3784 * Min shaper configuration enable. Enables configuration of the min 3785 * shaper on this ETS element 3786 * 0 - Disable 3787 * 1 - Enable 3788 * Access: RW 3789 */ 3790 MLXSW_ITEM32(reg, qeec, mise, 0x0C, 31, 1); 3791 3792 /* reg_qeec_ptps 3793 * PTP shaper 3794 * 0: regular shaper mode 3795 * 1: PTP oriented shaper 3796 * Allowed only for hierarchy 0 3797 * Not supported for CPU port 3798 * Note that ptps mode may affect the shaper rates of all hierarchies 3799 * Supported only on Spectrum-1 3800 * Access: RW 3801 */ 3802 MLXSW_ITEM32(reg, qeec, ptps, 0x0C, 29, 1); 3803 3804 enum { 3805 MLXSW_REG_QEEC_BYTES_MODE, 3806 MLXSW_REG_QEEC_PACKETS_MODE, 3807 }; 3808 3809 /* reg_qeec_pb 3810 * Packets or bytes mode. 3811 * 0 - Bytes mode 3812 * 1 - Packets mode 3813 * Access: RW 3814 * 3815 * Note: Used for max shaper configuration. For Spectrum, packets mode 3816 * is supported only for traffic classes of CPU port. 3817 */ 3818 MLXSW_ITEM32(reg, qeec, pb, 0x0C, 28, 1); 3819 3820 /* The smallest permitted min shaper rate. */ 3821 #define MLXSW_REG_QEEC_MIS_MIN 200000 /* Kbps */ 3822 3823 /* reg_qeec_min_shaper_rate 3824 * Min shaper information rate. 3825 * For CPU port, can only be configured for port hierarchy. 3826 * When in bytes mode, value is specified in units of 1000bps. 3827 * Access: RW 3828 */ 3829 MLXSW_ITEM32(reg, qeec, min_shaper_rate, 0x0C, 0, 28); 3830 3831 /* reg_qeec_mase 3832 * Max shaper configuration enable. Enables configuration of the max 3833 * shaper on this ETS element. 3834 * 0 - Disable 3835 * 1 - Enable 3836 * Access: RW 3837 */ 3838 MLXSW_ITEM32(reg, qeec, mase, 0x10, 31, 1); 3839 3840 /* The largest max shaper value possible to disable the shaper. */ 3841 #define MLXSW_REG_QEEC_MAS_DIS ((1u << 31) - 1) /* Kbps */ 3842 3843 /* reg_qeec_max_shaper_rate 3844 * Max shaper information rate. 3845 * For CPU port, can only be configured for port hierarchy. 3846 * When in bytes mode, value is specified in units of 1000bps. 3847 * Access: RW 3848 */ 3849 MLXSW_ITEM32(reg, qeec, max_shaper_rate, 0x10, 0, 31); 3850 3851 /* reg_qeec_de 3852 * DWRR configuration enable. Enables configuration of the dwrr and 3853 * dwrr_weight. 3854 * 0 - Disable 3855 * 1 - Enable 3856 * Access: RW 3857 */ 3858 MLXSW_ITEM32(reg, qeec, de, 0x18, 31, 1); 3859 3860 /* reg_qeec_dwrr 3861 * Transmission selection algorithm to use on the link going down from 3862 * the ETS element. 3863 * 0 - Strict priority 3864 * 1 - DWRR 3865 * Access: RW 3866 */ 3867 MLXSW_ITEM32(reg, qeec, dwrr, 0x18, 15, 1); 3868 3869 /* reg_qeec_dwrr_weight 3870 * DWRR weight on the link going down from the ETS element. The 3871 * percentage of bandwidth guaranteed to an ETS element within 3872 * its hierarchy. The sum of all weights across all ETS elements 3873 * within one hierarchy should be equal to 100. Reserved when 3874 * transmission selection algorithm is strict priority. 3875 * Access: RW 3876 */ 3877 MLXSW_ITEM32(reg, qeec, dwrr_weight, 0x18, 0, 8); 3878 3879 /* reg_qeec_max_shaper_bs 3880 * Max shaper burst size 3881 * Burst size is 2^max_shaper_bs * 512 bits 3882 * For Spectrum-1: Range is: 5..25 3883 * For Spectrum-2: Range is: 11..25 3884 * Reserved when ptps = 1 3885 * Access: RW 3886 */ 3887 MLXSW_ITEM32(reg, qeec, max_shaper_bs, 0x1C, 0, 6); 3888 3889 #define MLXSW_REG_QEEC_HIGHEST_SHAPER_BS 25 3890 #define MLXSW_REG_QEEC_LOWEST_SHAPER_BS_SP1 5 3891 #define MLXSW_REG_QEEC_LOWEST_SHAPER_BS_SP2 11 3892 #define MLXSW_REG_QEEC_LOWEST_SHAPER_BS_SP3 11 3893 3894 static inline void mlxsw_reg_qeec_pack(char *payload, u16 local_port, 3895 enum mlxsw_reg_qeec_hr hr, u8 index, 3896 u8 next_index) 3897 { 3898 MLXSW_REG_ZERO(qeec, payload); 3899 mlxsw_reg_qeec_local_port_set(payload, local_port); 3900 mlxsw_reg_qeec_element_hierarchy_set(payload, hr); 3901 mlxsw_reg_qeec_element_index_set(payload, index); 3902 mlxsw_reg_qeec_next_element_index_set(payload, next_index); 3903 } 3904 3905 static inline void mlxsw_reg_qeec_ptps_pack(char *payload, u16 local_port, 3906 bool ptps) 3907 { 3908 MLXSW_REG_ZERO(qeec, payload); 3909 mlxsw_reg_qeec_local_port_set(payload, local_port); 3910 mlxsw_reg_qeec_element_hierarchy_set(payload, MLXSW_REG_QEEC_HR_PORT); 3911 mlxsw_reg_qeec_ptps_set(payload, ptps); 3912 } 3913 3914 /* QRWE - QoS ReWrite Enable 3915 * ------------------------- 3916 * This register configures the rewrite enable per receive port. 3917 */ 3918 #define MLXSW_REG_QRWE_ID 0x400F 3919 #define MLXSW_REG_QRWE_LEN 0x08 3920 3921 MLXSW_REG_DEFINE(qrwe, MLXSW_REG_QRWE_ID, MLXSW_REG_QRWE_LEN); 3922 3923 /* reg_qrwe_local_port 3924 * Local port number. 3925 * Access: Index 3926 * 3927 * Note: CPU port is supported. No support for router port. 3928 */ 3929 MLXSW_ITEM32_LP(reg, qrwe, 0x00, 16, 0x00, 12); 3930 3931 /* reg_qrwe_dscp 3932 * Whether to enable DSCP rewrite (default is 0, don't rewrite). 3933 * Access: RW 3934 */ 3935 MLXSW_ITEM32(reg, qrwe, dscp, 0x04, 1, 1); 3936 3937 /* reg_qrwe_pcp 3938 * Whether to enable PCP and DEI rewrite (default is 0, don't rewrite). 3939 * Access: RW 3940 */ 3941 MLXSW_ITEM32(reg, qrwe, pcp, 0x04, 0, 1); 3942 3943 static inline void mlxsw_reg_qrwe_pack(char *payload, u16 local_port, 3944 bool rewrite_pcp, bool rewrite_dscp) 3945 { 3946 MLXSW_REG_ZERO(qrwe, payload); 3947 mlxsw_reg_qrwe_local_port_set(payload, local_port); 3948 mlxsw_reg_qrwe_pcp_set(payload, rewrite_pcp); 3949 mlxsw_reg_qrwe_dscp_set(payload, rewrite_dscp); 3950 } 3951 3952 /* QPDSM - QoS Priority to DSCP Mapping 3953 * ------------------------------------ 3954 * QoS Priority to DSCP Mapping Register 3955 */ 3956 #define MLXSW_REG_QPDSM_ID 0x4011 3957 #define MLXSW_REG_QPDSM_BASE_LEN 0x04 /* base length, without records */ 3958 #define MLXSW_REG_QPDSM_PRIO_ENTRY_REC_LEN 0x4 /* record length */ 3959 #define MLXSW_REG_QPDSM_PRIO_ENTRY_REC_MAX_COUNT 16 3960 #define MLXSW_REG_QPDSM_LEN (MLXSW_REG_QPDSM_BASE_LEN + \ 3961 MLXSW_REG_QPDSM_PRIO_ENTRY_REC_LEN * \ 3962 MLXSW_REG_QPDSM_PRIO_ENTRY_REC_MAX_COUNT) 3963 3964 MLXSW_REG_DEFINE(qpdsm, MLXSW_REG_QPDSM_ID, MLXSW_REG_QPDSM_LEN); 3965 3966 /* reg_qpdsm_local_port 3967 * Local Port. Supported for data packets from CPU port. 3968 * Access: Index 3969 */ 3970 MLXSW_ITEM32_LP(reg, qpdsm, 0x00, 16, 0x00, 12); 3971 3972 /* reg_qpdsm_prio_entry_color0_e 3973 * Enable update of the entry for color 0 and a given port. 3974 * Access: WO 3975 */ 3976 MLXSW_ITEM32_INDEXED(reg, qpdsm, prio_entry_color0_e, 3977 MLXSW_REG_QPDSM_BASE_LEN, 31, 1, 3978 MLXSW_REG_QPDSM_PRIO_ENTRY_REC_LEN, 0x00, false); 3979 3980 /* reg_qpdsm_prio_entry_color0_dscp 3981 * DSCP field in the outer label of the packet for color 0 and a given port. 3982 * Reserved when e=0. 3983 * Access: RW 3984 */ 3985 MLXSW_ITEM32_INDEXED(reg, qpdsm, prio_entry_color0_dscp, 3986 MLXSW_REG_QPDSM_BASE_LEN, 24, 6, 3987 MLXSW_REG_QPDSM_PRIO_ENTRY_REC_LEN, 0x00, false); 3988 3989 /* reg_qpdsm_prio_entry_color1_e 3990 * Enable update of the entry for color 1 and a given port. 3991 * Access: WO 3992 */ 3993 MLXSW_ITEM32_INDEXED(reg, qpdsm, prio_entry_color1_e, 3994 MLXSW_REG_QPDSM_BASE_LEN, 23, 1, 3995 MLXSW_REG_QPDSM_PRIO_ENTRY_REC_LEN, 0x00, false); 3996 3997 /* reg_qpdsm_prio_entry_color1_dscp 3998 * DSCP field in the outer label of the packet for color 1 and a given port. 3999 * Reserved when e=0. 4000 * Access: RW 4001 */ 4002 MLXSW_ITEM32_INDEXED(reg, qpdsm, prio_entry_color1_dscp, 4003 MLXSW_REG_QPDSM_BASE_LEN, 16, 6, 4004 MLXSW_REG_QPDSM_PRIO_ENTRY_REC_LEN, 0x00, false); 4005 4006 /* reg_qpdsm_prio_entry_color2_e 4007 * Enable update of the entry for color 2 and a given port. 4008 * Access: WO 4009 */ 4010 MLXSW_ITEM32_INDEXED(reg, qpdsm, prio_entry_color2_e, 4011 MLXSW_REG_QPDSM_BASE_LEN, 15, 1, 4012 MLXSW_REG_QPDSM_PRIO_ENTRY_REC_LEN, 0x00, false); 4013 4014 /* reg_qpdsm_prio_entry_color2_dscp 4015 * DSCP field in the outer label of the packet for color 2 and a given port. 4016 * Reserved when e=0. 4017 * Access: RW 4018 */ 4019 MLXSW_ITEM32_INDEXED(reg, qpdsm, prio_entry_color2_dscp, 4020 MLXSW_REG_QPDSM_BASE_LEN, 8, 6, 4021 MLXSW_REG_QPDSM_PRIO_ENTRY_REC_LEN, 0x00, false); 4022 4023 static inline void mlxsw_reg_qpdsm_pack(char *payload, u16 local_port) 4024 { 4025 MLXSW_REG_ZERO(qpdsm, payload); 4026 mlxsw_reg_qpdsm_local_port_set(payload, local_port); 4027 } 4028 4029 static inline void 4030 mlxsw_reg_qpdsm_prio_pack(char *payload, unsigned short prio, u8 dscp) 4031 { 4032 mlxsw_reg_qpdsm_prio_entry_color0_e_set(payload, prio, 1); 4033 mlxsw_reg_qpdsm_prio_entry_color0_dscp_set(payload, prio, dscp); 4034 mlxsw_reg_qpdsm_prio_entry_color1_e_set(payload, prio, 1); 4035 mlxsw_reg_qpdsm_prio_entry_color1_dscp_set(payload, prio, dscp); 4036 mlxsw_reg_qpdsm_prio_entry_color2_e_set(payload, prio, 1); 4037 mlxsw_reg_qpdsm_prio_entry_color2_dscp_set(payload, prio, dscp); 4038 } 4039 4040 /* QPDP - QoS Port DSCP to Priority Mapping Register 4041 * ------------------------------------------------- 4042 * This register controls the port default Switch Priority and Color. The 4043 * default Switch Priority and Color are used for frames where the trust state 4044 * uses default values. All member ports of a LAG should be configured with the 4045 * same default values. 4046 */ 4047 #define MLXSW_REG_QPDP_ID 0x4007 4048 #define MLXSW_REG_QPDP_LEN 0x8 4049 4050 MLXSW_REG_DEFINE(qpdp, MLXSW_REG_QPDP_ID, MLXSW_REG_QPDP_LEN); 4051 4052 /* reg_qpdp_local_port 4053 * Local Port. Supported for data packets from CPU port. 4054 * Access: Index 4055 */ 4056 MLXSW_ITEM32_LP(reg, qpdp, 0x00, 16, 0x00, 12); 4057 4058 /* reg_qpdp_switch_prio 4059 * Default port Switch Priority (default 0) 4060 * Access: RW 4061 */ 4062 MLXSW_ITEM32(reg, qpdp, switch_prio, 0x04, 0, 4); 4063 4064 static inline void mlxsw_reg_qpdp_pack(char *payload, u16 local_port, 4065 u8 switch_prio) 4066 { 4067 MLXSW_REG_ZERO(qpdp, payload); 4068 mlxsw_reg_qpdp_local_port_set(payload, local_port); 4069 mlxsw_reg_qpdp_switch_prio_set(payload, switch_prio); 4070 } 4071 4072 /* QPDPM - QoS Port DSCP to Priority Mapping Register 4073 * -------------------------------------------------- 4074 * This register controls the mapping from DSCP field to 4075 * Switch Priority for IP packets. 4076 */ 4077 #define MLXSW_REG_QPDPM_ID 0x4013 4078 #define MLXSW_REG_QPDPM_BASE_LEN 0x4 /* base length, without records */ 4079 #define MLXSW_REG_QPDPM_DSCP_ENTRY_REC_LEN 0x2 /* record length */ 4080 #define MLXSW_REG_QPDPM_DSCP_ENTRY_REC_MAX_COUNT 64 4081 #define MLXSW_REG_QPDPM_LEN (MLXSW_REG_QPDPM_BASE_LEN + \ 4082 MLXSW_REG_QPDPM_DSCP_ENTRY_REC_LEN * \ 4083 MLXSW_REG_QPDPM_DSCP_ENTRY_REC_MAX_COUNT) 4084 4085 MLXSW_REG_DEFINE(qpdpm, MLXSW_REG_QPDPM_ID, MLXSW_REG_QPDPM_LEN); 4086 4087 /* reg_qpdpm_local_port 4088 * Local Port. Supported for data packets from CPU port. 4089 * Access: Index 4090 */ 4091 MLXSW_ITEM32_LP(reg, qpdpm, 0x00, 16, 0x00, 12); 4092 4093 /* reg_qpdpm_dscp_e 4094 * Enable update of the specific entry. When cleared, the switch_prio and color 4095 * fields are ignored and the previous switch_prio and color values are 4096 * preserved. 4097 * Access: WO 4098 */ 4099 MLXSW_ITEM16_INDEXED(reg, qpdpm, dscp_entry_e, MLXSW_REG_QPDPM_BASE_LEN, 15, 1, 4100 MLXSW_REG_QPDPM_DSCP_ENTRY_REC_LEN, 0x00, false); 4101 4102 /* reg_qpdpm_dscp_prio 4103 * The new Switch Priority value for the relevant DSCP value. 4104 * Access: RW 4105 */ 4106 MLXSW_ITEM16_INDEXED(reg, qpdpm, dscp_entry_prio, 4107 MLXSW_REG_QPDPM_BASE_LEN, 0, 4, 4108 MLXSW_REG_QPDPM_DSCP_ENTRY_REC_LEN, 0x00, false); 4109 4110 static inline void mlxsw_reg_qpdpm_pack(char *payload, u16 local_port) 4111 { 4112 MLXSW_REG_ZERO(qpdpm, payload); 4113 mlxsw_reg_qpdpm_local_port_set(payload, local_port); 4114 } 4115 4116 static inline void 4117 mlxsw_reg_qpdpm_dscp_pack(char *payload, unsigned short dscp, u8 prio) 4118 { 4119 mlxsw_reg_qpdpm_dscp_entry_e_set(payload, dscp, 1); 4120 mlxsw_reg_qpdpm_dscp_entry_prio_set(payload, dscp, prio); 4121 } 4122 4123 /* QTCTM - QoS Switch Traffic Class Table is Multicast-Aware Register 4124 * ------------------------------------------------------------------ 4125 * This register configures if the Switch Priority to Traffic Class mapping is 4126 * based on Multicast packet indication. If so, then multicast packets will get 4127 * a Traffic Class that is plus (cap_max_tclass_data/2) the value configured by 4128 * QTCT. 4129 * By default, Switch Priority to Traffic Class mapping is not based on 4130 * Multicast packet indication. 4131 */ 4132 #define MLXSW_REG_QTCTM_ID 0x401A 4133 #define MLXSW_REG_QTCTM_LEN 0x08 4134 4135 MLXSW_REG_DEFINE(qtctm, MLXSW_REG_QTCTM_ID, MLXSW_REG_QTCTM_LEN); 4136 4137 /* reg_qtctm_local_port 4138 * Local port number. 4139 * No support for CPU port. 4140 * Access: Index 4141 */ 4142 MLXSW_ITEM32_LP(reg, qtctm, 0x00, 16, 0x00, 12); 4143 4144 /* reg_qtctm_mc 4145 * Multicast Mode 4146 * Whether Switch Priority to Traffic Class mapping is based on Multicast packet 4147 * indication (default is 0, not based on Multicast packet indication). 4148 */ 4149 MLXSW_ITEM32(reg, qtctm, mc, 0x04, 0, 1); 4150 4151 static inline void 4152 mlxsw_reg_qtctm_pack(char *payload, u16 local_port, bool mc) 4153 { 4154 MLXSW_REG_ZERO(qtctm, payload); 4155 mlxsw_reg_qtctm_local_port_set(payload, local_port); 4156 mlxsw_reg_qtctm_mc_set(payload, mc); 4157 } 4158 4159 /* QPSC - QoS PTP Shaper Configuration Register 4160 * -------------------------------------------- 4161 * The QPSC allows advanced configuration of the shapers when QEEC.ptps=1. 4162 * Supported only on Spectrum-1. 4163 */ 4164 #define MLXSW_REG_QPSC_ID 0x401B 4165 #define MLXSW_REG_QPSC_LEN 0x28 4166 4167 MLXSW_REG_DEFINE(qpsc, MLXSW_REG_QPSC_ID, MLXSW_REG_QPSC_LEN); 4168 4169 enum mlxsw_reg_qpsc_port_speed { 4170 MLXSW_REG_QPSC_PORT_SPEED_100M, 4171 MLXSW_REG_QPSC_PORT_SPEED_1G, 4172 MLXSW_REG_QPSC_PORT_SPEED_10G, 4173 MLXSW_REG_QPSC_PORT_SPEED_25G, 4174 }; 4175 4176 /* reg_qpsc_port_speed 4177 * Port speed. 4178 * Access: Index 4179 */ 4180 MLXSW_ITEM32(reg, qpsc, port_speed, 0x00, 0, 4); 4181 4182 /* reg_qpsc_shaper_time_exp 4183 * The base-time-interval for updating the shapers tokens (for all hierarchies). 4184 * shaper_update_rate = 2 ^ shaper_time_exp * (1 + shaper_time_mantissa) * 32nSec 4185 * shaper_rate = 64bit * shaper_inc / shaper_update_rate 4186 * Access: RW 4187 */ 4188 MLXSW_ITEM32(reg, qpsc, shaper_time_exp, 0x04, 16, 4); 4189 4190 /* reg_qpsc_shaper_time_mantissa 4191 * The base-time-interval for updating the shapers tokens (for all hierarchies). 4192 * shaper_update_rate = 2 ^ shaper_time_exp * (1 + shaper_time_mantissa) * 32nSec 4193 * shaper_rate = 64bit * shaper_inc / shaper_update_rate 4194 * Access: RW 4195 */ 4196 MLXSW_ITEM32(reg, qpsc, shaper_time_mantissa, 0x04, 0, 5); 4197 4198 /* reg_qpsc_shaper_inc 4199 * Number of tokens added to shaper on each update. 4200 * Units of 8B. 4201 * Access: RW 4202 */ 4203 MLXSW_ITEM32(reg, qpsc, shaper_inc, 0x08, 0, 5); 4204 4205 /* reg_qpsc_shaper_bs 4206 * Max shaper Burst size. 4207 * Burst size is 2 ^ max_shaper_bs * 512 [bits] 4208 * Range is: 5..25 (from 2KB..2GB) 4209 * Access: RW 4210 */ 4211 MLXSW_ITEM32(reg, qpsc, shaper_bs, 0x0C, 0, 6); 4212 4213 /* reg_qpsc_ptsc_we 4214 * Write enable to port_to_shaper_credits. 4215 * Access: WO 4216 */ 4217 MLXSW_ITEM32(reg, qpsc, ptsc_we, 0x10, 31, 1); 4218 4219 /* reg_qpsc_port_to_shaper_credits 4220 * For split ports: range 1..57 4221 * For non-split ports: range 1..112 4222 * Written only when ptsc_we is set. 4223 * Access: RW 4224 */ 4225 MLXSW_ITEM32(reg, qpsc, port_to_shaper_credits, 0x10, 0, 8); 4226 4227 /* reg_qpsc_ing_timestamp_inc 4228 * Ingress timestamp increment. 4229 * 2's complement. 4230 * The timestamp of MTPPTR at ingress will be incremented by this value. Global 4231 * value for all ports. 4232 * Same units as used by MTPPTR. 4233 * Access: RW 4234 */ 4235 MLXSW_ITEM32(reg, qpsc, ing_timestamp_inc, 0x20, 0, 32); 4236 4237 /* reg_qpsc_egr_timestamp_inc 4238 * Egress timestamp increment. 4239 * 2's complement. 4240 * The timestamp of MTPPTR at egress will be incremented by this value. Global 4241 * value for all ports. 4242 * Same units as used by MTPPTR. 4243 * Access: RW 4244 */ 4245 MLXSW_ITEM32(reg, qpsc, egr_timestamp_inc, 0x24, 0, 32); 4246 4247 static inline void 4248 mlxsw_reg_qpsc_pack(char *payload, enum mlxsw_reg_qpsc_port_speed port_speed, 4249 u8 shaper_time_exp, u8 shaper_time_mantissa, u8 shaper_inc, 4250 u8 shaper_bs, u8 port_to_shaper_credits, 4251 int ing_timestamp_inc, int egr_timestamp_inc) 4252 { 4253 MLXSW_REG_ZERO(qpsc, payload); 4254 mlxsw_reg_qpsc_port_speed_set(payload, port_speed); 4255 mlxsw_reg_qpsc_shaper_time_exp_set(payload, shaper_time_exp); 4256 mlxsw_reg_qpsc_shaper_time_mantissa_set(payload, shaper_time_mantissa); 4257 mlxsw_reg_qpsc_shaper_inc_set(payload, shaper_inc); 4258 mlxsw_reg_qpsc_shaper_bs_set(payload, shaper_bs); 4259 mlxsw_reg_qpsc_ptsc_we_set(payload, true); 4260 mlxsw_reg_qpsc_port_to_shaper_credits_set(payload, port_to_shaper_credits); 4261 mlxsw_reg_qpsc_ing_timestamp_inc_set(payload, ing_timestamp_inc); 4262 mlxsw_reg_qpsc_egr_timestamp_inc_set(payload, egr_timestamp_inc); 4263 } 4264 4265 /* PMLP - Ports Module to Local Port Register 4266 * ------------------------------------------ 4267 * Configures the assignment of modules to local ports. 4268 */ 4269 #define MLXSW_REG_PMLP_ID 0x5002 4270 #define MLXSW_REG_PMLP_LEN 0x40 4271 4272 MLXSW_REG_DEFINE(pmlp, MLXSW_REG_PMLP_ID, MLXSW_REG_PMLP_LEN); 4273 4274 /* reg_pmlp_rxtx 4275 * 0 - Tx value is used for both Tx and Rx. 4276 * 1 - Rx value is taken from a separte field. 4277 * Access: RW 4278 */ 4279 MLXSW_ITEM32(reg, pmlp, rxtx, 0x00, 31, 1); 4280 4281 /* reg_pmlp_local_port 4282 * Local port number. 4283 * Access: Index 4284 */ 4285 MLXSW_ITEM32_LP(reg, pmlp, 0x00, 16, 0x00, 12); 4286 4287 /* reg_pmlp_width 4288 * 0 - Unmap local port. 4289 * 1 - Lane 0 is used. 4290 * 2 - Lanes 0 and 1 are used. 4291 * 4 - Lanes 0, 1, 2 and 3 are used. 4292 * 8 - Lanes 0-7 are used. 4293 * Access: RW 4294 */ 4295 MLXSW_ITEM32(reg, pmlp, width, 0x00, 0, 8); 4296 4297 /* reg_pmlp_module 4298 * Module number. 4299 * Access: RW 4300 */ 4301 MLXSW_ITEM32_INDEXED(reg, pmlp, module, 0x04, 0, 8, 0x04, 0x00, false); 4302 4303 /* reg_pmlp_tx_lane 4304 * Tx Lane. When rxtx field is cleared, this field is used for Rx as well. 4305 * Access: RW 4306 */ 4307 MLXSW_ITEM32_INDEXED(reg, pmlp, tx_lane, 0x04, 16, 4, 0x04, 0x00, false); 4308 4309 /* reg_pmlp_rx_lane 4310 * Rx Lane. When rxtx field is cleared, this field is ignored and Rx lane is 4311 * equal to Tx lane. 4312 * Access: RW 4313 */ 4314 MLXSW_ITEM32_INDEXED(reg, pmlp, rx_lane, 0x04, 24, 4, 0x04, 0x00, false); 4315 4316 static inline void mlxsw_reg_pmlp_pack(char *payload, u16 local_port) 4317 { 4318 MLXSW_REG_ZERO(pmlp, payload); 4319 mlxsw_reg_pmlp_local_port_set(payload, local_port); 4320 } 4321 4322 /* PMTU - Port MTU Register 4323 * ------------------------ 4324 * Configures and reports the port MTU. 4325 */ 4326 #define MLXSW_REG_PMTU_ID 0x5003 4327 #define MLXSW_REG_PMTU_LEN 0x10 4328 4329 MLXSW_REG_DEFINE(pmtu, MLXSW_REG_PMTU_ID, MLXSW_REG_PMTU_LEN); 4330 4331 /* reg_pmtu_local_port 4332 * Local port number. 4333 * Access: Index 4334 */ 4335 MLXSW_ITEM32_LP(reg, pmtu, 0x00, 16, 0x00, 12); 4336 4337 /* reg_pmtu_max_mtu 4338 * Maximum MTU. 4339 * When port type (e.g. Ethernet) is configured, the relevant MTU is 4340 * reported, otherwise the minimum between the max_mtu of the different 4341 * types is reported. 4342 * Access: RO 4343 */ 4344 MLXSW_ITEM32(reg, pmtu, max_mtu, 0x04, 16, 16); 4345 4346 /* reg_pmtu_admin_mtu 4347 * MTU value to set port to. Must be smaller or equal to max_mtu. 4348 * Note: If port type is Infiniband, then port must be disabled, when its 4349 * MTU is set. 4350 * Access: RW 4351 */ 4352 MLXSW_ITEM32(reg, pmtu, admin_mtu, 0x08, 16, 16); 4353 4354 /* reg_pmtu_oper_mtu 4355 * The actual MTU configured on the port. Packets exceeding this size 4356 * will be dropped. 4357 * Note: In Ethernet and FC oper_mtu == admin_mtu, however, in Infiniband 4358 * oper_mtu might be smaller than admin_mtu. 4359 * Access: RO 4360 */ 4361 MLXSW_ITEM32(reg, pmtu, oper_mtu, 0x0C, 16, 16); 4362 4363 static inline void mlxsw_reg_pmtu_pack(char *payload, u16 local_port, 4364 u16 new_mtu) 4365 { 4366 MLXSW_REG_ZERO(pmtu, payload); 4367 mlxsw_reg_pmtu_local_port_set(payload, local_port); 4368 mlxsw_reg_pmtu_max_mtu_set(payload, 0); 4369 mlxsw_reg_pmtu_admin_mtu_set(payload, new_mtu); 4370 mlxsw_reg_pmtu_oper_mtu_set(payload, 0); 4371 } 4372 4373 /* PTYS - Port Type and Speed Register 4374 * ----------------------------------- 4375 * Configures and reports the port speed type. 4376 * 4377 * Note: When set while the link is up, the changes will not take effect 4378 * until the port transitions from down to up state. 4379 */ 4380 #define MLXSW_REG_PTYS_ID 0x5004 4381 #define MLXSW_REG_PTYS_LEN 0x40 4382 4383 MLXSW_REG_DEFINE(ptys, MLXSW_REG_PTYS_ID, MLXSW_REG_PTYS_LEN); 4384 4385 /* an_disable_admin 4386 * Auto negotiation disable administrative configuration 4387 * 0 - Device doesn't support AN disable. 4388 * 1 - Device supports AN disable. 4389 * Access: RW 4390 */ 4391 MLXSW_ITEM32(reg, ptys, an_disable_admin, 0x00, 30, 1); 4392 4393 /* reg_ptys_local_port 4394 * Local port number. 4395 * Access: Index 4396 */ 4397 MLXSW_ITEM32_LP(reg, ptys, 0x00, 16, 0x00, 12); 4398 4399 #define MLXSW_REG_PTYS_PROTO_MASK_IB BIT(0) 4400 #define MLXSW_REG_PTYS_PROTO_MASK_ETH BIT(2) 4401 4402 /* reg_ptys_proto_mask 4403 * Protocol mask. Indicates which protocol is used. 4404 * 0 - Infiniband. 4405 * 1 - Fibre Channel. 4406 * 2 - Ethernet. 4407 * Access: Index 4408 */ 4409 MLXSW_ITEM32(reg, ptys, proto_mask, 0x00, 0, 3); 4410 4411 enum { 4412 MLXSW_REG_PTYS_AN_STATUS_NA, 4413 MLXSW_REG_PTYS_AN_STATUS_OK, 4414 MLXSW_REG_PTYS_AN_STATUS_FAIL, 4415 }; 4416 4417 /* reg_ptys_an_status 4418 * Autonegotiation status. 4419 * Access: RO 4420 */ 4421 MLXSW_ITEM32(reg, ptys, an_status, 0x04, 28, 4); 4422 4423 #define MLXSW_REG_PTYS_EXT_ETH_SPEED_SGMII_100M BIT(0) 4424 #define MLXSW_REG_PTYS_EXT_ETH_SPEED_1000BASE_X_SGMII BIT(1) 4425 #define MLXSW_REG_PTYS_EXT_ETH_SPEED_5GBASE_R BIT(3) 4426 #define MLXSW_REG_PTYS_EXT_ETH_SPEED_XFI_XAUI_1_10G BIT(4) 4427 #define MLXSW_REG_PTYS_EXT_ETH_SPEED_XLAUI_4_XLPPI_4_40G BIT(5) 4428 #define MLXSW_REG_PTYS_EXT_ETH_SPEED_25GAUI_1_25GBASE_CR_KR BIT(6) 4429 #define MLXSW_REG_PTYS_EXT_ETH_SPEED_50GAUI_2_LAUI_2_50GBASE_CR2_KR2 BIT(7) 4430 #define MLXSW_REG_PTYS_EXT_ETH_SPEED_50GAUI_1_LAUI_1_50GBASE_CR_KR BIT(8) 4431 #define MLXSW_REG_PTYS_EXT_ETH_SPEED_CAUI_4_100GBASE_CR4_KR4 BIT(9) 4432 #define MLXSW_REG_PTYS_EXT_ETH_SPEED_100GAUI_2_100GBASE_CR2_KR2 BIT(10) 4433 #define MLXSW_REG_PTYS_EXT_ETH_SPEED_200GAUI_4_200GBASE_CR4_KR4 BIT(12) 4434 #define MLXSW_REG_PTYS_EXT_ETH_SPEED_400GAUI_8 BIT(15) 4435 4436 /* reg_ptys_ext_eth_proto_cap 4437 * Extended Ethernet port supported speeds and protocols. 4438 * Access: RO 4439 */ 4440 MLXSW_ITEM32(reg, ptys, ext_eth_proto_cap, 0x08, 0, 32); 4441 4442 #define MLXSW_REG_PTYS_ETH_SPEED_SGMII BIT(0) 4443 #define MLXSW_REG_PTYS_ETH_SPEED_1000BASE_KX BIT(1) 4444 #define MLXSW_REG_PTYS_ETH_SPEED_10GBASE_CX4 BIT(2) 4445 #define MLXSW_REG_PTYS_ETH_SPEED_10GBASE_KX4 BIT(3) 4446 #define MLXSW_REG_PTYS_ETH_SPEED_10GBASE_KR BIT(4) 4447 #define MLXSW_REG_PTYS_ETH_SPEED_40GBASE_CR4 BIT(6) 4448 #define MLXSW_REG_PTYS_ETH_SPEED_40GBASE_KR4 BIT(7) 4449 #define MLXSW_REG_PTYS_ETH_SPEED_10GBASE_CR BIT(12) 4450 #define MLXSW_REG_PTYS_ETH_SPEED_10GBASE_SR BIT(13) 4451 #define MLXSW_REG_PTYS_ETH_SPEED_10GBASE_ER_LR BIT(14) 4452 #define MLXSW_REG_PTYS_ETH_SPEED_40GBASE_SR4 BIT(15) 4453 #define MLXSW_REG_PTYS_ETH_SPEED_40GBASE_LR4_ER4 BIT(16) 4454 #define MLXSW_REG_PTYS_ETH_SPEED_50GBASE_SR2 BIT(18) 4455 #define MLXSW_REG_PTYS_ETH_SPEED_50GBASE_KR4 BIT(19) 4456 #define MLXSW_REG_PTYS_ETH_SPEED_100GBASE_CR4 BIT(20) 4457 #define MLXSW_REG_PTYS_ETH_SPEED_100GBASE_SR4 BIT(21) 4458 #define MLXSW_REG_PTYS_ETH_SPEED_100GBASE_KR4 BIT(22) 4459 #define MLXSW_REG_PTYS_ETH_SPEED_100GBASE_LR4_ER4 BIT(23) 4460 #define MLXSW_REG_PTYS_ETH_SPEED_25GBASE_CR BIT(27) 4461 #define MLXSW_REG_PTYS_ETH_SPEED_25GBASE_KR BIT(28) 4462 #define MLXSW_REG_PTYS_ETH_SPEED_25GBASE_SR BIT(29) 4463 #define MLXSW_REG_PTYS_ETH_SPEED_50GBASE_CR2 BIT(30) 4464 #define MLXSW_REG_PTYS_ETH_SPEED_50GBASE_KR2 BIT(31) 4465 4466 /* reg_ptys_eth_proto_cap 4467 * Ethernet port supported speeds and protocols. 4468 * Access: RO 4469 */ 4470 MLXSW_ITEM32(reg, ptys, eth_proto_cap, 0x0C, 0, 32); 4471 4472 /* reg_ptys_ib_link_width_cap 4473 * IB port supported widths. 4474 * Access: RO 4475 */ 4476 MLXSW_ITEM32(reg, ptys, ib_link_width_cap, 0x10, 16, 16); 4477 4478 #define MLXSW_REG_PTYS_IB_SPEED_SDR BIT(0) 4479 #define MLXSW_REG_PTYS_IB_SPEED_DDR BIT(1) 4480 #define MLXSW_REG_PTYS_IB_SPEED_QDR BIT(2) 4481 #define MLXSW_REG_PTYS_IB_SPEED_FDR10 BIT(3) 4482 #define MLXSW_REG_PTYS_IB_SPEED_FDR BIT(4) 4483 #define MLXSW_REG_PTYS_IB_SPEED_EDR BIT(5) 4484 4485 /* reg_ptys_ib_proto_cap 4486 * IB port supported speeds and protocols. 4487 * Access: RO 4488 */ 4489 MLXSW_ITEM32(reg, ptys, ib_proto_cap, 0x10, 0, 16); 4490 4491 /* reg_ptys_ext_eth_proto_admin 4492 * Extended speed and protocol to set port to. 4493 * Access: RW 4494 */ 4495 MLXSW_ITEM32(reg, ptys, ext_eth_proto_admin, 0x14, 0, 32); 4496 4497 /* reg_ptys_eth_proto_admin 4498 * Speed and protocol to set port to. 4499 * Access: RW 4500 */ 4501 MLXSW_ITEM32(reg, ptys, eth_proto_admin, 0x18, 0, 32); 4502 4503 /* reg_ptys_ib_link_width_admin 4504 * IB width to set port to. 4505 * Access: RW 4506 */ 4507 MLXSW_ITEM32(reg, ptys, ib_link_width_admin, 0x1C, 16, 16); 4508 4509 /* reg_ptys_ib_proto_admin 4510 * IB speeds and protocols to set port to. 4511 * Access: RW 4512 */ 4513 MLXSW_ITEM32(reg, ptys, ib_proto_admin, 0x1C, 0, 16); 4514 4515 /* reg_ptys_ext_eth_proto_oper 4516 * The extended current speed and protocol configured for the port. 4517 * Access: RO 4518 */ 4519 MLXSW_ITEM32(reg, ptys, ext_eth_proto_oper, 0x20, 0, 32); 4520 4521 /* reg_ptys_eth_proto_oper 4522 * The current speed and protocol configured for the port. 4523 * Access: RO 4524 */ 4525 MLXSW_ITEM32(reg, ptys, eth_proto_oper, 0x24, 0, 32); 4526 4527 /* reg_ptys_ib_link_width_oper 4528 * The current IB width to set port to. 4529 * Access: RO 4530 */ 4531 MLXSW_ITEM32(reg, ptys, ib_link_width_oper, 0x28, 16, 16); 4532 4533 /* reg_ptys_ib_proto_oper 4534 * The current IB speed and protocol. 4535 * Access: RO 4536 */ 4537 MLXSW_ITEM32(reg, ptys, ib_proto_oper, 0x28, 0, 16); 4538 4539 enum mlxsw_reg_ptys_connector_type { 4540 MLXSW_REG_PTYS_CONNECTOR_TYPE_UNKNOWN_OR_NO_CONNECTOR, 4541 MLXSW_REG_PTYS_CONNECTOR_TYPE_PORT_NONE, 4542 MLXSW_REG_PTYS_CONNECTOR_TYPE_PORT_TP, 4543 MLXSW_REG_PTYS_CONNECTOR_TYPE_PORT_AUI, 4544 MLXSW_REG_PTYS_CONNECTOR_TYPE_PORT_BNC, 4545 MLXSW_REG_PTYS_CONNECTOR_TYPE_PORT_MII, 4546 MLXSW_REG_PTYS_CONNECTOR_TYPE_PORT_FIBRE, 4547 MLXSW_REG_PTYS_CONNECTOR_TYPE_PORT_DA, 4548 MLXSW_REG_PTYS_CONNECTOR_TYPE_PORT_OTHER, 4549 }; 4550 4551 /* reg_ptys_connector_type 4552 * Connector type indication. 4553 * Access: RO 4554 */ 4555 MLXSW_ITEM32(reg, ptys, connector_type, 0x2C, 0, 4); 4556 4557 static inline void mlxsw_reg_ptys_eth_pack(char *payload, u16 local_port, 4558 u32 proto_admin, bool autoneg) 4559 { 4560 MLXSW_REG_ZERO(ptys, payload); 4561 mlxsw_reg_ptys_local_port_set(payload, local_port); 4562 mlxsw_reg_ptys_proto_mask_set(payload, MLXSW_REG_PTYS_PROTO_MASK_ETH); 4563 mlxsw_reg_ptys_eth_proto_admin_set(payload, proto_admin); 4564 mlxsw_reg_ptys_an_disable_admin_set(payload, !autoneg); 4565 } 4566 4567 static inline void mlxsw_reg_ptys_ext_eth_pack(char *payload, u16 local_port, 4568 u32 proto_admin, bool autoneg) 4569 { 4570 MLXSW_REG_ZERO(ptys, payload); 4571 mlxsw_reg_ptys_local_port_set(payload, local_port); 4572 mlxsw_reg_ptys_proto_mask_set(payload, MLXSW_REG_PTYS_PROTO_MASK_ETH); 4573 mlxsw_reg_ptys_ext_eth_proto_admin_set(payload, proto_admin); 4574 mlxsw_reg_ptys_an_disable_admin_set(payload, !autoneg); 4575 } 4576 4577 static inline void mlxsw_reg_ptys_eth_unpack(char *payload, 4578 u32 *p_eth_proto_cap, 4579 u32 *p_eth_proto_admin, 4580 u32 *p_eth_proto_oper) 4581 { 4582 if (p_eth_proto_cap) 4583 *p_eth_proto_cap = 4584 mlxsw_reg_ptys_eth_proto_cap_get(payload); 4585 if (p_eth_proto_admin) 4586 *p_eth_proto_admin = 4587 mlxsw_reg_ptys_eth_proto_admin_get(payload); 4588 if (p_eth_proto_oper) 4589 *p_eth_proto_oper = 4590 mlxsw_reg_ptys_eth_proto_oper_get(payload); 4591 } 4592 4593 static inline void mlxsw_reg_ptys_ext_eth_unpack(char *payload, 4594 u32 *p_eth_proto_cap, 4595 u32 *p_eth_proto_admin, 4596 u32 *p_eth_proto_oper) 4597 { 4598 if (p_eth_proto_cap) 4599 *p_eth_proto_cap = 4600 mlxsw_reg_ptys_ext_eth_proto_cap_get(payload); 4601 if (p_eth_proto_admin) 4602 *p_eth_proto_admin = 4603 mlxsw_reg_ptys_ext_eth_proto_admin_get(payload); 4604 if (p_eth_proto_oper) 4605 *p_eth_proto_oper = 4606 mlxsw_reg_ptys_ext_eth_proto_oper_get(payload); 4607 } 4608 4609 static inline void mlxsw_reg_ptys_ib_pack(char *payload, u16 local_port, 4610 u16 proto_admin, u16 link_width) 4611 { 4612 MLXSW_REG_ZERO(ptys, payload); 4613 mlxsw_reg_ptys_local_port_set(payload, local_port); 4614 mlxsw_reg_ptys_proto_mask_set(payload, MLXSW_REG_PTYS_PROTO_MASK_IB); 4615 mlxsw_reg_ptys_ib_proto_admin_set(payload, proto_admin); 4616 mlxsw_reg_ptys_ib_link_width_admin_set(payload, link_width); 4617 } 4618 4619 static inline void mlxsw_reg_ptys_ib_unpack(char *payload, u16 *p_ib_proto_cap, 4620 u16 *p_ib_link_width_cap, 4621 u16 *p_ib_proto_oper, 4622 u16 *p_ib_link_width_oper) 4623 { 4624 if (p_ib_proto_cap) 4625 *p_ib_proto_cap = mlxsw_reg_ptys_ib_proto_cap_get(payload); 4626 if (p_ib_link_width_cap) 4627 *p_ib_link_width_cap = 4628 mlxsw_reg_ptys_ib_link_width_cap_get(payload); 4629 if (p_ib_proto_oper) 4630 *p_ib_proto_oper = mlxsw_reg_ptys_ib_proto_oper_get(payload); 4631 if (p_ib_link_width_oper) 4632 *p_ib_link_width_oper = 4633 mlxsw_reg_ptys_ib_link_width_oper_get(payload); 4634 } 4635 4636 /* PPAD - Port Physical Address Register 4637 * ------------------------------------- 4638 * The PPAD register configures the per port physical MAC address. 4639 */ 4640 #define MLXSW_REG_PPAD_ID 0x5005 4641 #define MLXSW_REG_PPAD_LEN 0x10 4642 4643 MLXSW_REG_DEFINE(ppad, MLXSW_REG_PPAD_ID, MLXSW_REG_PPAD_LEN); 4644 4645 /* reg_ppad_single_base_mac 4646 * 0: base_mac, local port should be 0 and mac[7:0] is 4647 * reserved. HW will set incremental 4648 * 1: single_mac - mac of the local_port 4649 * Access: RW 4650 */ 4651 MLXSW_ITEM32(reg, ppad, single_base_mac, 0x00, 28, 1); 4652 4653 /* reg_ppad_local_port 4654 * port number, if single_base_mac = 0 then local_port is reserved 4655 * Access: RW 4656 */ 4657 MLXSW_ITEM32_LP(reg, ppad, 0x00, 16, 0x00, 24); 4658 4659 /* reg_ppad_mac 4660 * If single_base_mac = 0 - base MAC address, mac[7:0] is reserved. 4661 * If single_base_mac = 1 - the per port MAC address 4662 * Access: RW 4663 */ 4664 MLXSW_ITEM_BUF(reg, ppad, mac, 0x02, 6); 4665 4666 static inline void mlxsw_reg_ppad_pack(char *payload, bool single_base_mac, 4667 u16 local_port) 4668 { 4669 MLXSW_REG_ZERO(ppad, payload); 4670 mlxsw_reg_ppad_single_base_mac_set(payload, !!single_base_mac); 4671 mlxsw_reg_ppad_local_port_set(payload, local_port); 4672 } 4673 4674 /* PAOS - Ports Administrative and Operational Status Register 4675 * ----------------------------------------------------------- 4676 * Configures and retrieves per port administrative and operational status. 4677 */ 4678 #define MLXSW_REG_PAOS_ID 0x5006 4679 #define MLXSW_REG_PAOS_LEN 0x10 4680 4681 MLXSW_REG_DEFINE(paos, MLXSW_REG_PAOS_ID, MLXSW_REG_PAOS_LEN); 4682 4683 /* reg_paos_swid 4684 * Switch partition ID with which to associate the port. 4685 * Note: while external ports uses unique local port numbers (and thus swid is 4686 * redundant), router ports use the same local port number where swid is the 4687 * only indication for the relevant port. 4688 * Access: Index 4689 */ 4690 MLXSW_ITEM32(reg, paos, swid, 0x00, 24, 8); 4691 4692 /* reg_paos_local_port 4693 * Local port number. 4694 * Access: Index 4695 */ 4696 MLXSW_ITEM32_LP(reg, paos, 0x00, 16, 0x00, 12); 4697 4698 /* reg_paos_admin_status 4699 * Port administrative state (the desired state of the port): 4700 * 1 - Up. 4701 * 2 - Down. 4702 * 3 - Up once. This means that in case of link failure, the port won't go 4703 * into polling mode, but will wait to be re-enabled by software. 4704 * 4 - Disabled by system. Can only be set by hardware. 4705 * Access: RW 4706 */ 4707 MLXSW_ITEM32(reg, paos, admin_status, 0x00, 8, 4); 4708 4709 /* reg_paos_oper_status 4710 * Port operational state (the current state): 4711 * 1 - Up. 4712 * 2 - Down. 4713 * 3 - Down by port failure. This means that the device will not let the 4714 * port up again until explicitly specified by software. 4715 * Access: RO 4716 */ 4717 MLXSW_ITEM32(reg, paos, oper_status, 0x00, 0, 4); 4718 4719 /* reg_paos_ase 4720 * Admin state update enabled. 4721 * Access: WO 4722 */ 4723 MLXSW_ITEM32(reg, paos, ase, 0x04, 31, 1); 4724 4725 /* reg_paos_ee 4726 * Event update enable. If this bit is set, event generation will be 4727 * updated based on the e field. 4728 * Access: WO 4729 */ 4730 MLXSW_ITEM32(reg, paos, ee, 0x04, 30, 1); 4731 4732 /* reg_paos_e 4733 * Event generation on operational state change: 4734 * 0 - Do not generate event. 4735 * 1 - Generate Event. 4736 * 2 - Generate Single Event. 4737 * Access: RW 4738 */ 4739 MLXSW_ITEM32(reg, paos, e, 0x04, 0, 2); 4740 4741 static inline void mlxsw_reg_paos_pack(char *payload, u16 local_port, 4742 enum mlxsw_port_admin_status status) 4743 { 4744 MLXSW_REG_ZERO(paos, payload); 4745 mlxsw_reg_paos_swid_set(payload, 0); 4746 mlxsw_reg_paos_local_port_set(payload, local_port); 4747 mlxsw_reg_paos_admin_status_set(payload, status); 4748 mlxsw_reg_paos_oper_status_set(payload, 0); 4749 mlxsw_reg_paos_ase_set(payload, 1); 4750 mlxsw_reg_paos_ee_set(payload, 1); 4751 mlxsw_reg_paos_e_set(payload, 1); 4752 } 4753 4754 /* PFCC - Ports Flow Control Configuration Register 4755 * ------------------------------------------------ 4756 * Configures and retrieves the per port flow control configuration. 4757 */ 4758 #define MLXSW_REG_PFCC_ID 0x5007 4759 #define MLXSW_REG_PFCC_LEN 0x20 4760 4761 MLXSW_REG_DEFINE(pfcc, MLXSW_REG_PFCC_ID, MLXSW_REG_PFCC_LEN); 4762 4763 /* reg_pfcc_local_port 4764 * Local port number. 4765 * Access: Index 4766 */ 4767 MLXSW_ITEM32_LP(reg, pfcc, 0x00, 16, 0x00, 12); 4768 4769 /* reg_pfcc_pnat 4770 * Port number access type. Determines the way local_port is interpreted: 4771 * 0 - Local port number. 4772 * 1 - IB / label port number. 4773 * Access: Index 4774 */ 4775 MLXSW_ITEM32(reg, pfcc, pnat, 0x00, 14, 2); 4776 4777 /* reg_pfcc_shl_cap 4778 * Send to higher layers capabilities: 4779 * 0 - No capability of sending Pause and PFC frames to higher layers. 4780 * 1 - Device has capability of sending Pause and PFC frames to higher 4781 * layers. 4782 * Access: RO 4783 */ 4784 MLXSW_ITEM32(reg, pfcc, shl_cap, 0x00, 1, 1); 4785 4786 /* reg_pfcc_shl_opr 4787 * Send to higher layers operation: 4788 * 0 - Pause and PFC frames are handled by the port (default). 4789 * 1 - Pause and PFC frames are handled by the port and also sent to 4790 * higher layers. Only valid if shl_cap = 1. 4791 * Access: RW 4792 */ 4793 MLXSW_ITEM32(reg, pfcc, shl_opr, 0x00, 0, 1); 4794 4795 /* reg_pfcc_ppan 4796 * Pause policy auto negotiation. 4797 * 0 - Disabled. Generate / ignore Pause frames based on pptx / pprtx. 4798 * 1 - Enabled. When auto-negotiation is performed, set the Pause policy 4799 * based on the auto-negotiation resolution. 4800 * Access: RW 4801 * 4802 * Note: The auto-negotiation advertisement is set according to pptx and 4803 * pprtx. When PFC is set on Tx / Rx, ppan must be set to 0. 4804 */ 4805 MLXSW_ITEM32(reg, pfcc, ppan, 0x04, 28, 4); 4806 4807 /* reg_pfcc_prio_mask_tx 4808 * Bit per priority indicating if Tx flow control policy should be 4809 * updated based on bit pfctx. 4810 * Access: WO 4811 */ 4812 MLXSW_ITEM32(reg, pfcc, prio_mask_tx, 0x04, 16, 8); 4813 4814 /* reg_pfcc_prio_mask_rx 4815 * Bit per priority indicating if Rx flow control policy should be 4816 * updated based on bit pfcrx. 4817 * Access: WO 4818 */ 4819 MLXSW_ITEM32(reg, pfcc, prio_mask_rx, 0x04, 0, 8); 4820 4821 /* reg_pfcc_pptx 4822 * Admin Pause policy on Tx. 4823 * 0 - Never generate Pause frames (default). 4824 * 1 - Generate Pause frames according to Rx buffer threshold. 4825 * Access: RW 4826 */ 4827 MLXSW_ITEM32(reg, pfcc, pptx, 0x08, 31, 1); 4828 4829 /* reg_pfcc_aptx 4830 * Active (operational) Pause policy on Tx. 4831 * 0 - Never generate Pause frames. 4832 * 1 - Generate Pause frames according to Rx buffer threshold. 4833 * Access: RO 4834 */ 4835 MLXSW_ITEM32(reg, pfcc, aptx, 0x08, 30, 1); 4836 4837 /* reg_pfcc_pfctx 4838 * Priority based flow control policy on Tx[7:0]. Per-priority bit mask: 4839 * 0 - Never generate priority Pause frames on the specified priority 4840 * (default). 4841 * 1 - Generate priority Pause frames according to Rx buffer threshold on 4842 * the specified priority. 4843 * Access: RW 4844 * 4845 * Note: pfctx and pptx must be mutually exclusive. 4846 */ 4847 MLXSW_ITEM32(reg, pfcc, pfctx, 0x08, 16, 8); 4848 4849 /* reg_pfcc_pprx 4850 * Admin Pause policy on Rx. 4851 * 0 - Ignore received Pause frames (default). 4852 * 1 - Respect received Pause frames. 4853 * Access: RW 4854 */ 4855 MLXSW_ITEM32(reg, pfcc, pprx, 0x0C, 31, 1); 4856 4857 /* reg_pfcc_aprx 4858 * Active (operational) Pause policy on Rx. 4859 * 0 - Ignore received Pause frames. 4860 * 1 - Respect received Pause frames. 4861 * Access: RO 4862 */ 4863 MLXSW_ITEM32(reg, pfcc, aprx, 0x0C, 30, 1); 4864 4865 /* reg_pfcc_pfcrx 4866 * Priority based flow control policy on Rx[7:0]. Per-priority bit mask: 4867 * 0 - Ignore incoming priority Pause frames on the specified priority 4868 * (default). 4869 * 1 - Respect incoming priority Pause frames on the specified priority. 4870 * Access: RW 4871 */ 4872 MLXSW_ITEM32(reg, pfcc, pfcrx, 0x0C, 16, 8); 4873 4874 #define MLXSW_REG_PFCC_ALL_PRIO 0xFF 4875 4876 static inline void mlxsw_reg_pfcc_prio_pack(char *payload, u8 pfc_en) 4877 { 4878 mlxsw_reg_pfcc_prio_mask_tx_set(payload, MLXSW_REG_PFCC_ALL_PRIO); 4879 mlxsw_reg_pfcc_prio_mask_rx_set(payload, MLXSW_REG_PFCC_ALL_PRIO); 4880 mlxsw_reg_pfcc_pfctx_set(payload, pfc_en); 4881 mlxsw_reg_pfcc_pfcrx_set(payload, pfc_en); 4882 } 4883 4884 static inline void mlxsw_reg_pfcc_pack(char *payload, u16 local_port) 4885 { 4886 MLXSW_REG_ZERO(pfcc, payload); 4887 mlxsw_reg_pfcc_local_port_set(payload, local_port); 4888 } 4889 4890 /* PPCNT - Ports Performance Counters Register 4891 * ------------------------------------------- 4892 * The PPCNT register retrieves per port performance counters. 4893 */ 4894 #define MLXSW_REG_PPCNT_ID 0x5008 4895 #define MLXSW_REG_PPCNT_LEN 0x100 4896 #define MLXSW_REG_PPCNT_COUNTERS_OFFSET 0x08 4897 4898 MLXSW_REG_DEFINE(ppcnt, MLXSW_REG_PPCNT_ID, MLXSW_REG_PPCNT_LEN); 4899 4900 /* reg_ppcnt_swid 4901 * For HCA: must be always 0. 4902 * Switch partition ID to associate port with. 4903 * Switch partitions are numbered from 0 to 7 inclusively. 4904 * Switch partition 254 indicates stacking ports. 4905 * Switch partition 255 indicates all switch partitions. 4906 * Only valid on Set() operation with local_port=255. 4907 * Access: Index 4908 */ 4909 MLXSW_ITEM32(reg, ppcnt, swid, 0x00, 24, 8); 4910 4911 /* reg_ppcnt_local_port 4912 * Local port number. 4913 * Access: Index 4914 */ 4915 MLXSW_ITEM32_LP(reg, ppcnt, 0x00, 16, 0x00, 12); 4916 4917 /* reg_ppcnt_pnat 4918 * Port number access type: 4919 * 0 - Local port number 4920 * 1 - IB port number 4921 * Access: Index 4922 */ 4923 MLXSW_ITEM32(reg, ppcnt, pnat, 0x00, 14, 2); 4924 4925 enum mlxsw_reg_ppcnt_grp { 4926 MLXSW_REG_PPCNT_IEEE_8023_CNT = 0x0, 4927 MLXSW_REG_PPCNT_RFC_2863_CNT = 0x1, 4928 MLXSW_REG_PPCNT_RFC_2819_CNT = 0x2, 4929 MLXSW_REG_PPCNT_RFC_3635_CNT = 0x3, 4930 MLXSW_REG_PPCNT_EXT_CNT = 0x5, 4931 MLXSW_REG_PPCNT_DISCARD_CNT = 0x6, 4932 MLXSW_REG_PPCNT_PRIO_CNT = 0x10, 4933 MLXSW_REG_PPCNT_TC_CNT = 0x11, 4934 MLXSW_REG_PPCNT_TC_CONG_CNT = 0x13, 4935 }; 4936 4937 /* reg_ppcnt_grp 4938 * Performance counter group. 4939 * Group 63 indicates all groups. Only valid on Set() operation with 4940 * clr bit set. 4941 * 0x0: IEEE 802.3 Counters 4942 * 0x1: RFC 2863 Counters 4943 * 0x2: RFC 2819 Counters 4944 * 0x3: RFC 3635 Counters 4945 * 0x5: Ethernet Extended Counters 4946 * 0x6: Ethernet Discard Counters 4947 * 0x8: Link Level Retransmission Counters 4948 * 0x10: Per Priority Counters 4949 * 0x11: Per Traffic Class Counters 4950 * 0x12: Physical Layer Counters 4951 * 0x13: Per Traffic Class Congestion Counters 4952 * Access: Index 4953 */ 4954 MLXSW_ITEM32(reg, ppcnt, grp, 0x00, 0, 6); 4955 4956 /* reg_ppcnt_clr 4957 * Clear counters. Setting the clr bit will reset the counter value 4958 * for all counters in the counter group. This bit can be set 4959 * for both Set() and Get() operation. 4960 * Access: OP 4961 */ 4962 MLXSW_ITEM32(reg, ppcnt, clr, 0x04, 31, 1); 4963 4964 /* reg_ppcnt_lp_gl 4965 * Local port global variable. 4966 * 0: local_port 255 = all ports of the device. 4967 * 1: local_port indicates local port number for all ports. 4968 * Access: OP 4969 */ 4970 MLXSW_ITEM32(reg, ppcnt, lp_gl, 0x04, 30, 1); 4971 4972 /* reg_ppcnt_prio_tc 4973 * Priority for counter set that support per priority, valid values: 0-7. 4974 * Traffic class for counter set that support per traffic class, 4975 * valid values: 0- cap_max_tclass-1 . 4976 * For HCA: cap_max_tclass is always 8. 4977 * Otherwise must be 0. 4978 * Access: Index 4979 */ 4980 MLXSW_ITEM32(reg, ppcnt, prio_tc, 0x04, 0, 5); 4981 4982 /* Ethernet IEEE 802.3 Counter Group */ 4983 4984 /* reg_ppcnt_a_frames_transmitted_ok 4985 * Access: RO 4986 */ 4987 MLXSW_ITEM64(reg, ppcnt, a_frames_transmitted_ok, 4988 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x00, 0, 64); 4989 4990 /* reg_ppcnt_a_frames_received_ok 4991 * Access: RO 4992 */ 4993 MLXSW_ITEM64(reg, ppcnt, a_frames_received_ok, 4994 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x08, 0, 64); 4995 4996 /* reg_ppcnt_a_frame_check_sequence_errors 4997 * Access: RO 4998 */ 4999 MLXSW_ITEM64(reg, ppcnt, a_frame_check_sequence_errors, 5000 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x10, 0, 64); 5001 5002 /* reg_ppcnt_a_alignment_errors 5003 * Access: RO 5004 */ 5005 MLXSW_ITEM64(reg, ppcnt, a_alignment_errors, 5006 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x18, 0, 64); 5007 5008 /* reg_ppcnt_a_octets_transmitted_ok 5009 * Access: RO 5010 */ 5011 MLXSW_ITEM64(reg, ppcnt, a_octets_transmitted_ok, 5012 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x20, 0, 64); 5013 5014 /* reg_ppcnt_a_octets_received_ok 5015 * Access: RO 5016 */ 5017 MLXSW_ITEM64(reg, ppcnt, a_octets_received_ok, 5018 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x28, 0, 64); 5019 5020 /* reg_ppcnt_a_multicast_frames_xmitted_ok 5021 * Access: RO 5022 */ 5023 MLXSW_ITEM64(reg, ppcnt, a_multicast_frames_xmitted_ok, 5024 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x30, 0, 64); 5025 5026 /* reg_ppcnt_a_broadcast_frames_xmitted_ok 5027 * Access: RO 5028 */ 5029 MLXSW_ITEM64(reg, ppcnt, a_broadcast_frames_xmitted_ok, 5030 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x38, 0, 64); 5031 5032 /* reg_ppcnt_a_multicast_frames_received_ok 5033 * Access: RO 5034 */ 5035 MLXSW_ITEM64(reg, ppcnt, a_multicast_frames_received_ok, 5036 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x40, 0, 64); 5037 5038 /* reg_ppcnt_a_broadcast_frames_received_ok 5039 * Access: RO 5040 */ 5041 MLXSW_ITEM64(reg, ppcnt, a_broadcast_frames_received_ok, 5042 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x48, 0, 64); 5043 5044 /* reg_ppcnt_a_in_range_length_errors 5045 * Access: RO 5046 */ 5047 MLXSW_ITEM64(reg, ppcnt, a_in_range_length_errors, 5048 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x50, 0, 64); 5049 5050 /* reg_ppcnt_a_out_of_range_length_field 5051 * Access: RO 5052 */ 5053 MLXSW_ITEM64(reg, ppcnt, a_out_of_range_length_field, 5054 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x58, 0, 64); 5055 5056 /* reg_ppcnt_a_frame_too_long_errors 5057 * Access: RO 5058 */ 5059 MLXSW_ITEM64(reg, ppcnt, a_frame_too_long_errors, 5060 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x60, 0, 64); 5061 5062 /* reg_ppcnt_a_symbol_error_during_carrier 5063 * Access: RO 5064 */ 5065 MLXSW_ITEM64(reg, ppcnt, a_symbol_error_during_carrier, 5066 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x68, 0, 64); 5067 5068 /* reg_ppcnt_a_mac_control_frames_transmitted 5069 * Access: RO 5070 */ 5071 MLXSW_ITEM64(reg, ppcnt, a_mac_control_frames_transmitted, 5072 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x70, 0, 64); 5073 5074 /* reg_ppcnt_a_mac_control_frames_received 5075 * Access: RO 5076 */ 5077 MLXSW_ITEM64(reg, ppcnt, a_mac_control_frames_received, 5078 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x78, 0, 64); 5079 5080 /* reg_ppcnt_a_unsupported_opcodes_received 5081 * Access: RO 5082 */ 5083 MLXSW_ITEM64(reg, ppcnt, a_unsupported_opcodes_received, 5084 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x80, 0, 64); 5085 5086 /* reg_ppcnt_a_pause_mac_ctrl_frames_received 5087 * Access: RO 5088 */ 5089 MLXSW_ITEM64(reg, ppcnt, a_pause_mac_ctrl_frames_received, 5090 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x88, 0, 64); 5091 5092 /* reg_ppcnt_a_pause_mac_ctrl_frames_transmitted 5093 * Access: RO 5094 */ 5095 MLXSW_ITEM64(reg, ppcnt, a_pause_mac_ctrl_frames_transmitted, 5096 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x90, 0, 64); 5097 5098 /* Ethernet RFC 2863 Counter Group */ 5099 5100 /* reg_ppcnt_if_in_discards 5101 * Access: RO 5102 */ 5103 MLXSW_ITEM64(reg, ppcnt, if_in_discards, 5104 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x10, 0, 64); 5105 5106 /* reg_ppcnt_if_out_discards 5107 * Access: RO 5108 */ 5109 MLXSW_ITEM64(reg, ppcnt, if_out_discards, 5110 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x38, 0, 64); 5111 5112 /* reg_ppcnt_if_out_errors 5113 * Access: RO 5114 */ 5115 MLXSW_ITEM64(reg, ppcnt, if_out_errors, 5116 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x40, 0, 64); 5117 5118 /* Ethernet RFC 2819 Counter Group */ 5119 5120 /* reg_ppcnt_ether_stats_undersize_pkts 5121 * Access: RO 5122 */ 5123 MLXSW_ITEM64(reg, ppcnt, ether_stats_undersize_pkts, 5124 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x30, 0, 64); 5125 5126 /* reg_ppcnt_ether_stats_oversize_pkts 5127 * Access: RO 5128 */ 5129 MLXSW_ITEM64(reg, ppcnt, ether_stats_oversize_pkts, 5130 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x38, 0, 64); 5131 5132 /* reg_ppcnt_ether_stats_fragments 5133 * Access: RO 5134 */ 5135 MLXSW_ITEM64(reg, ppcnt, ether_stats_fragments, 5136 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x40, 0, 64); 5137 5138 /* reg_ppcnt_ether_stats_pkts64octets 5139 * Access: RO 5140 */ 5141 MLXSW_ITEM64(reg, ppcnt, ether_stats_pkts64octets, 5142 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x58, 0, 64); 5143 5144 /* reg_ppcnt_ether_stats_pkts65to127octets 5145 * Access: RO 5146 */ 5147 MLXSW_ITEM64(reg, ppcnt, ether_stats_pkts65to127octets, 5148 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x60, 0, 64); 5149 5150 /* reg_ppcnt_ether_stats_pkts128to255octets 5151 * Access: RO 5152 */ 5153 MLXSW_ITEM64(reg, ppcnt, ether_stats_pkts128to255octets, 5154 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x68, 0, 64); 5155 5156 /* reg_ppcnt_ether_stats_pkts256to511octets 5157 * Access: RO 5158 */ 5159 MLXSW_ITEM64(reg, ppcnt, ether_stats_pkts256to511octets, 5160 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x70, 0, 64); 5161 5162 /* reg_ppcnt_ether_stats_pkts512to1023octets 5163 * Access: RO 5164 */ 5165 MLXSW_ITEM64(reg, ppcnt, ether_stats_pkts512to1023octets, 5166 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x78, 0, 64); 5167 5168 /* reg_ppcnt_ether_stats_pkts1024to1518octets 5169 * Access: RO 5170 */ 5171 MLXSW_ITEM64(reg, ppcnt, ether_stats_pkts1024to1518octets, 5172 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x80, 0, 64); 5173 5174 /* reg_ppcnt_ether_stats_pkts1519to2047octets 5175 * Access: RO 5176 */ 5177 MLXSW_ITEM64(reg, ppcnt, ether_stats_pkts1519to2047octets, 5178 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x88, 0, 64); 5179 5180 /* reg_ppcnt_ether_stats_pkts2048to4095octets 5181 * Access: RO 5182 */ 5183 MLXSW_ITEM64(reg, ppcnt, ether_stats_pkts2048to4095octets, 5184 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x90, 0, 64); 5185 5186 /* reg_ppcnt_ether_stats_pkts4096to8191octets 5187 * Access: RO 5188 */ 5189 MLXSW_ITEM64(reg, ppcnt, ether_stats_pkts4096to8191octets, 5190 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x98, 0, 64); 5191 5192 /* reg_ppcnt_ether_stats_pkts8192to10239octets 5193 * Access: RO 5194 */ 5195 MLXSW_ITEM64(reg, ppcnt, ether_stats_pkts8192to10239octets, 5196 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0xA0, 0, 64); 5197 5198 /* Ethernet RFC 3635 Counter Group */ 5199 5200 /* reg_ppcnt_dot3stats_fcs_errors 5201 * Access: RO 5202 */ 5203 MLXSW_ITEM64(reg, ppcnt, dot3stats_fcs_errors, 5204 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x08, 0, 64); 5205 5206 /* reg_ppcnt_dot3stats_symbol_errors 5207 * Access: RO 5208 */ 5209 MLXSW_ITEM64(reg, ppcnt, dot3stats_symbol_errors, 5210 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x60, 0, 64); 5211 5212 /* reg_ppcnt_dot3control_in_unknown_opcodes 5213 * Access: RO 5214 */ 5215 MLXSW_ITEM64(reg, ppcnt, dot3control_in_unknown_opcodes, 5216 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x68, 0, 64); 5217 5218 /* reg_ppcnt_dot3in_pause_frames 5219 * Access: RO 5220 */ 5221 MLXSW_ITEM64(reg, ppcnt, dot3in_pause_frames, 5222 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x70, 0, 64); 5223 5224 /* Ethernet Extended Counter Group Counters */ 5225 5226 /* reg_ppcnt_ecn_marked 5227 * Access: RO 5228 */ 5229 MLXSW_ITEM64(reg, ppcnt, ecn_marked, 5230 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x08, 0, 64); 5231 5232 /* Ethernet Discard Counter Group Counters */ 5233 5234 /* reg_ppcnt_ingress_general 5235 * Access: RO 5236 */ 5237 MLXSW_ITEM64(reg, ppcnt, ingress_general, 5238 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x00, 0, 64); 5239 5240 /* reg_ppcnt_ingress_policy_engine 5241 * Access: RO 5242 */ 5243 MLXSW_ITEM64(reg, ppcnt, ingress_policy_engine, 5244 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x08, 0, 64); 5245 5246 /* reg_ppcnt_ingress_vlan_membership 5247 * Access: RO 5248 */ 5249 MLXSW_ITEM64(reg, ppcnt, ingress_vlan_membership, 5250 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x10, 0, 64); 5251 5252 /* reg_ppcnt_ingress_tag_frame_type 5253 * Access: RO 5254 */ 5255 MLXSW_ITEM64(reg, ppcnt, ingress_tag_frame_type, 5256 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x18, 0, 64); 5257 5258 /* reg_ppcnt_egress_vlan_membership 5259 * Access: RO 5260 */ 5261 MLXSW_ITEM64(reg, ppcnt, egress_vlan_membership, 5262 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x20, 0, 64); 5263 5264 /* reg_ppcnt_loopback_filter 5265 * Access: RO 5266 */ 5267 MLXSW_ITEM64(reg, ppcnt, loopback_filter, 5268 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x28, 0, 64); 5269 5270 /* reg_ppcnt_egress_general 5271 * Access: RO 5272 */ 5273 MLXSW_ITEM64(reg, ppcnt, egress_general, 5274 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x30, 0, 64); 5275 5276 /* reg_ppcnt_egress_hoq 5277 * Access: RO 5278 */ 5279 MLXSW_ITEM64(reg, ppcnt, egress_hoq, 5280 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x40, 0, 64); 5281 5282 /* reg_ppcnt_egress_policy_engine 5283 * Access: RO 5284 */ 5285 MLXSW_ITEM64(reg, ppcnt, egress_policy_engine, 5286 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x50, 0, 64); 5287 5288 /* reg_ppcnt_ingress_tx_link_down 5289 * Access: RO 5290 */ 5291 MLXSW_ITEM64(reg, ppcnt, ingress_tx_link_down, 5292 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x58, 0, 64); 5293 5294 /* reg_ppcnt_egress_stp_filter 5295 * Access: RO 5296 */ 5297 MLXSW_ITEM64(reg, ppcnt, egress_stp_filter, 5298 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x60, 0, 64); 5299 5300 /* reg_ppcnt_egress_sll 5301 * Access: RO 5302 */ 5303 MLXSW_ITEM64(reg, ppcnt, egress_sll, 5304 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x70, 0, 64); 5305 5306 /* Ethernet Per Priority Group Counters */ 5307 5308 /* reg_ppcnt_rx_octets 5309 * Access: RO 5310 */ 5311 MLXSW_ITEM64(reg, ppcnt, rx_octets, 5312 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x00, 0, 64); 5313 5314 /* reg_ppcnt_rx_frames 5315 * Access: RO 5316 */ 5317 MLXSW_ITEM64(reg, ppcnt, rx_frames, 5318 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x20, 0, 64); 5319 5320 /* reg_ppcnt_tx_octets 5321 * Access: RO 5322 */ 5323 MLXSW_ITEM64(reg, ppcnt, tx_octets, 5324 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x28, 0, 64); 5325 5326 /* reg_ppcnt_tx_frames 5327 * Access: RO 5328 */ 5329 MLXSW_ITEM64(reg, ppcnt, tx_frames, 5330 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x48, 0, 64); 5331 5332 /* reg_ppcnt_rx_pause 5333 * Access: RO 5334 */ 5335 MLXSW_ITEM64(reg, ppcnt, rx_pause, 5336 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x50, 0, 64); 5337 5338 /* reg_ppcnt_rx_pause_duration 5339 * Access: RO 5340 */ 5341 MLXSW_ITEM64(reg, ppcnt, rx_pause_duration, 5342 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x58, 0, 64); 5343 5344 /* reg_ppcnt_tx_pause 5345 * Access: RO 5346 */ 5347 MLXSW_ITEM64(reg, ppcnt, tx_pause, 5348 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x60, 0, 64); 5349 5350 /* reg_ppcnt_tx_pause_duration 5351 * Access: RO 5352 */ 5353 MLXSW_ITEM64(reg, ppcnt, tx_pause_duration, 5354 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x68, 0, 64); 5355 5356 /* reg_ppcnt_rx_pause_transition 5357 * Access: RO 5358 */ 5359 MLXSW_ITEM64(reg, ppcnt, tx_pause_transition, 5360 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x70, 0, 64); 5361 5362 /* Ethernet Per Traffic Class Counters */ 5363 5364 /* reg_ppcnt_tc_transmit_queue 5365 * Contains the transmit queue depth in cells of traffic class 5366 * selected by prio_tc and the port selected by local_port. 5367 * The field cannot be cleared. 5368 * Access: RO 5369 */ 5370 MLXSW_ITEM64(reg, ppcnt, tc_transmit_queue, 5371 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x00, 0, 64); 5372 5373 /* reg_ppcnt_tc_no_buffer_discard_uc 5374 * The number of unicast packets dropped due to lack of shared 5375 * buffer resources. 5376 * Access: RO 5377 */ 5378 MLXSW_ITEM64(reg, ppcnt, tc_no_buffer_discard_uc, 5379 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x08, 0, 64); 5380 5381 /* Ethernet Per Traffic Class Congestion Group Counters */ 5382 5383 /* reg_ppcnt_wred_discard 5384 * Access: RO 5385 */ 5386 MLXSW_ITEM64(reg, ppcnt, wred_discard, 5387 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x00, 0, 64); 5388 5389 /* reg_ppcnt_ecn_marked_tc 5390 * Access: RO 5391 */ 5392 MLXSW_ITEM64(reg, ppcnt, ecn_marked_tc, 5393 MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x08, 0, 64); 5394 5395 static inline void mlxsw_reg_ppcnt_pack(char *payload, u16 local_port, 5396 enum mlxsw_reg_ppcnt_grp grp, 5397 u8 prio_tc) 5398 { 5399 MLXSW_REG_ZERO(ppcnt, payload); 5400 mlxsw_reg_ppcnt_swid_set(payload, 0); 5401 mlxsw_reg_ppcnt_local_port_set(payload, local_port); 5402 mlxsw_reg_ppcnt_pnat_set(payload, 0); 5403 mlxsw_reg_ppcnt_grp_set(payload, grp); 5404 mlxsw_reg_ppcnt_clr_set(payload, 0); 5405 mlxsw_reg_ppcnt_lp_gl_set(payload, 1); 5406 mlxsw_reg_ppcnt_prio_tc_set(payload, prio_tc); 5407 } 5408 5409 /* PLIB - Port Local to InfiniBand Port 5410 * ------------------------------------ 5411 * The PLIB register performs mapping from Local Port into InfiniBand Port. 5412 */ 5413 #define MLXSW_REG_PLIB_ID 0x500A 5414 #define MLXSW_REG_PLIB_LEN 0x10 5415 5416 MLXSW_REG_DEFINE(plib, MLXSW_REG_PLIB_ID, MLXSW_REG_PLIB_LEN); 5417 5418 /* reg_plib_local_port 5419 * Local port number. 5420 * Access: Index 5421 */ 5422 MLXSW_ITEM32_LP(reg, plib, 0x00, 16, 0x00, 12); 5423 5424 /* reg_plib_ib_port 5425 * InfiniBand port remapping for local_port. 5426 * Access: RW 5427 */ 5428 MLXSW_ITEM32(reg, plib, ib_port, 0x00, 0, 8); 5429 5430 /* PPTB - Port Prio To Buffer Register 5431 * ----------------------------------- 5432 * Configures the switch priority to buffer table. 5433 */ 5434 #define MLXSW_REG_PPTB_ID 0x500B 5435 #define MLXSW_REG_PPTB_LEN 0x10 5436 5437 MLXSW_REG_DEFINE(pptb, MLXSW_REG_PPTB_ID, MLXSW_REG_PPTB_LEN); 5438 5439 enum { 5440 MLXSW_REG_PPTB_MM_UM, 5441 MLXSW_REG_PPTB_MM_UNICAST, 5442 MLXSW_REG_PPTB_MM_MULTICAST, 5443 }; 5444 5445 /* reg_pptb_mm 5446 * Mapping mode. 5447 * 0 - Map both unicast and multicast packets to the same buffer. 5448 * 1 - Map only unicast packets. 5449 * 2 - Map only multicast packets. 5450 * Access: Index 5451 * 5452 * Note: SwitchX-2 only supports the first option. 5453 */ 5454 MLXSW_ITEM32(reg, pptb, mm, 0x00, 28, 2); 5455 5456 /* reg_pptb_local_port 5457 * Local port number. 5458 * Access: Index 5459 */ 5460 MLXSW_ITEM32_LP(reg, pptb, 0x00, 16, 0x00, 12); 5461 5462 /* reg_pptb_um 5463 * Enables the update of the untagged_buf field. 5464 * Access: RW 5465 */ 5466 MLXSW_ITEM32(reg, pptb, um, 0x00, 8, 1); 5467 5468 /* reg_pptb_pm 5469 * Enables the update of the prio_to_buff field. 5470 * Bit <i> is a flag for updating the mapping for switch priority <i>. 5471 * Access: RW 5472 */ 5473 MLXSW_ITEM32(reg, pptb, pm, 0x00, 0, 8); 5474 5475 /* reg_pptb_prio_to_buff 5476 * Mapping of switch priority <i> to one of the allocated receive port 5477 * buffers. 5478 * Access: RW 5479 */ 5480 MLXSW_ITEM_BIT_ARRAY(reg, pptb, prio_to_buff, 0x04, 0x04, 4); 5481 5482 /* reg_pptb_pm_msb 5483 * Enables the update of the prio_to_buff field. 5484 * Bit <i> is a flag for updating the mapping for switch priority <i+8>. 5485 * Access: RW 5486 */ 5487 MLXSW_ITEM32(reg, pptb, pm_msb, 0x08, 24, 8); 5488 5489 /* reg_pptb_untagged_buff 5490 * Mapping of untagged frames to one of the allocated receive port buffers. 5491 * Access: RW 5492 * 5493 * Note: In SwitchX-2 this field must be mapped to buffer 8. Reserved for 5494 * Spectrum, as it maps untagged packets based on the default switch priority. 5495 */ 5496 MLXSW_ITEM32(reg, pptb, untagged_buff, 0x08, 0, 4); 5497 5498 /* reg_pptb_prio_to_buff_msb 5499 * Mapping of switch priority <i+8> to one of the allocated receive port 5500 * buffers. 5501 * Access: RW 5502 */ 5503 MLXSW_ITEM_BIT_ARRAY(reg, pptb, prio_to_buff_msb, 0x0C, 0x04, 4); 5504 5505 #define MLXSW_REG_PPTB_ALL_PRIO 0xFF 5506 5507 static inline void mlxsw_reg_pptb_pack(char *payload, u16 local_port) 5508 { 5509 MLXSW_REG_ZERO(pptb, payload); 5510 mlxsw_reg_pptb_mm_set(payload, MLXSW_REG_PPTB_MM_UM); 5511 mlxsw_reg_pptb_local_port_set(payload, local_port); 5512 mlxsw_reg_pptb_pm_set(payload, MLXSW_REG_PPTB_ALL_PRIO); 5513 mlxsw_reg_pptb_pm_msb_set(payload, MLXSW_REG_PPTB_ALL_PRIO); 5514 } 5515 5516 static inline void mlxsw_reg_pptb_prio_to_buff_pack(char *payload, u8 prio, 5517 u8 buff) 5518 { 5519 mlxsw_reg_pptb_prio_to_buff_set(payload, prio, buff); 5520 mlxsw_reg_pptb_prio_to_buff_msb_set(payload, prio, buff); 5521 } 5522 5523 /* PBMC - Port Buffer Management Control Register 5524 * ---------------------------------------------- 5525 * The PBMC register configures and retrieves the port packet buffer 5526 * allocation for different Prios, and the Pause threshold management. 5527 */ 5528 #define MLXSW_REG_PBMC_ID 0x500C 5529 #define MLXSW_REG_PBMC_LEN 0x6C 5530 5531 MLXSW_REG_DEFINE(pbmc, MLXSW_REG_PBMC_ID, MLXSW_REG_PBMC_LEN); 5532 5533 /* reg_pbmc_local_port 5534 * Local port number. 5535 * Access: Index 5536 */ 5537 MLXSW_ITEM32_LP(reg, pbmc, 0x00, 16, 0x00, 12); 5538 5539 /* reg_pbmc_xoff_timer_value 5540 * When device generates a pause frame, it uses this value as the pause 5541 * timer (time for the peer port to pause in quota-512 bit time). 5542 * Access: RW 5543 */ 5544 MLXSW_ITEM32(reg, pbmc, xoff_timer_value, 0x04, 16, 16); 5545 5546 /* reg_pbmc_xoff_refresh 5547 * The time before a new pause frame should be sent to refresh the pause RW 5548 * state. Using the same units as xoff_timer_value above (in quota-512 bit 5549 * time). 5550 * Access: RW 5551 */ 5552 MLXSW_ITEM32(reg, pbmc, xoff_refresh, 0x04, 0, 16); 5553 5554 #define MLXSW_REG_PBMC_PORT_SHARED_BUF_IDX 11 5555 5556 /* reg_pbmc_buf_lossy 5557 * The field indicates if the buffer is lossy. 5558 * 0 - Lossless 5559 * 1 - Lossy 5560 * Access: RW 5561 */ 5562 MLXSW_ITEM32_INDEXED(reg, pbmc, buf_lossy, 0x0C, 25, 1, 0x08, 0x00, false); 5563 5564 /* reg_pbmc_buf_epsb 5565 * Eligible for Port Shared buffer. 5566 * If epsb is set, packets assigned to buffer are allowed to insert the port 5567 * shared buffer. 5568 * When buf_lossy is MLXSW_REG_PBMC_LOSSY_LOSSY this field is reserved. 5569 * Access: RW 5570 */ 5571 MLXSW_ITEM32_INDEXED(reg, pbmc, buf_epsb, 0x0C, 24, 1, 0x08, 0x00, false); 5572 5573 /* reg_pbmc_buf_size 5574 * The part of the packet buffer array is allocated for the specific buffer. 5575 * Units are represented in cells. 5576 * Access: RW 5577 */ 5578 MLXSW_ITEM32_INDEXED(reg, pbmc, buf_size, 0x0C, 0, 16, 0x08, 0x00, false); 5579 5580 /* reg_pbmc_buf_xoff_threshold 5581 * Once the amount of data in the buffer goes above this value, device 5582 * starts sending PFC frames for all priorities associated with the 5583 * buffer. Units are represented in cells. Reserved in case of lossy 5584 * buffer. 5585 * Access: RW 5586 * 5587 * Note: In Spectrum, reserved for buffer[9]. 5588 */ 5589 MLXSW_ITEM32_INDEXED(reg, pbmc, buf_xoff_threshold, 0x0C, 16, 16, 5590 0x08, 0x04, false); 5591 5592 /* reg_pbmc_buf_xon_threshold 5593 * When the amount of data in the buffer goes below this value, device 5594 * stops sending PFC frames for the priorities associated with the 5595 * buffer. Units are represented in cells. Reserved in case of lossy 5596 * buffer. 5597 * Access: RW 5598 * 5599 * Note: In Spectrum, reserved for buffer[9]. 5600 */ 5601 MLXSW_ITEM32_INDEXED(reg, pbmc, buf_xon_threshold, 0x0C, 0, 16, 5602 0x08, 0x04, false); 5603 5604 static inline void mlxsw_reg_pbmc_pack(char *payload, u16 local_port, 5605 u16 xoff_timer_value, u16 xoff_refresh) 5606 { 5607 MLXSW_REG_ZERO(pbmc, payload); 5608 mlxsw_reg_pbmc_local_port_set(payload, local_port); 5609 mlxsw_reg_pbmc_xoff_timer_value_set(payload, xoff_timer_value); 5610 mlxsw_reg_pbmc_xoff_refresh_set(payload, xoff_refresh); 5611 } 5612 5613 static inline void mlxsw_reg_pbmc_lossy_buffer_pack(char *payload, 5614 int buf_index, 5615 u16 size) 5616 { 5617 mlxsw_reg_pbmc_buf_lossy_set(payload, buf_index, 1); 5618 mlxsw_reg_pbmc_buf_epsb_set(payload, buf_index, 0); 5619 mlxsw_reg_pbmc_buf_size_set(payload, buf_index, size); 5620 } 5621 5622 static inline void mlxsw_reg_pbmc_lossless_buffer_pack(char *payload, 5623 int buf_index, u16 size, 5624 u16 threshold) 5625 { 5626 mlxsw_reg_pbmc_buf_lossy_set(payload, buf_index, 0); 5627 mlxsw_reg_pbmc_buf_epsb_set(payload, buf_index, 0); 5628 mlxsw_reg_pbmc_buf_size_set(payload, buf_index, size); 5629 mlxsw_reg_pbmc_buf_xoff_threshold_set(payload, buf_index, threshold); 5630 mlxsw_reg_pbmc_buf_xon_threshold_set(payload, buf_index, threshold); 5631 } 5632 5633 /* PSPA - Port Switch Partition Allocation 5634 * --------------------------------------- 5635 * Controls the association of a port with a switch partition and enables 5636 * configuring ports as stacking ports. 5637 */ 5638 #define MLXSW_REG_PSPA_ID 0x500D 5639 #define MLXSW_REG_PSPA_LEN 0x8 5640 5641 MLXSW_REG_DEFINE(pspa, MLXSW_REG_PSPA_ID, MLXSW_REG_PSPA_LEN); 5642 5643 /* reg_pspa_swid 5644 * Switch partition ID. 5645 * Access: RW 5646 */ 5647 MLXSW_ITEM32(reg, pspa, swid, 0x00, 24, 8); 5648 5649 /* reg_pspa_local_port 5650 * Local port number. 5651 * Access: Index 5652 */ 5653 MLXSW_ITEM32_LP(reg, pspa, 0x00, 16, 0x00, 0); 5654 5655 /* reg_pspa_sub_port 5656 * Virtual port within the local port. Set to 0 when virtual ports are 5657 * disabled on the local port. 5658 * Access: Index 5659 */ 5660 MLXSW_ITEM32(reg, pspa, sub_port, 0x00, 8, 8); 5661 5662 static inline void mlxsw_reg_pspa_pack(char *payload, u8 swid, u16 local_port) 5663 { 5664 MLXSW_REG_ZERO(pspa, payload); 5665 mlxsw_reg_pspa_swid_set(payload, swid); 5666 mlxsw_reg_pspa_local_port_set(payload, local_port); 5667 mlxsw_reg_pspa_sub_port_set(payload, 0); 5668 } 5669 5670 /* PMAOS - Ports Module Administrative and Operational Status 5671 * ---------------------------------------------------------- 5672 * This register configures and retrieves the per module status. 5673 */ 5674 #define MLXSW_REG_PMAOS_ID 0x5012 5675 #define MLXSW_REG_PMAOS_LEN 0x10 5676 5677 MLXSW_REG_DEFINE(pmaos, MLXSW_REG_PMAOS_ID, MLXSW_REG_PMAOS_LEN); 5678 5679 /* reg_pmaos_rst 5680 * Module reset toggle. 5681 * Note: Setting reset while module is plugged-in will result in transition to 5682 * "initializing" operational state. 5683 * Access: OP 5684 */ 5685 MLXSW_ITEM32(reg, pmaos, rst, 0x00, 31, 1); 5686 5687 /* reg_pmaos_slot_index 5688 * Slot index. 5689 * Access: Index 5690 */ 5691 MLXSW_ITEM32(reg, pmaos, slot_index, 0x00, 24, 4); 5692 5693 /* reg_pmaos_module 5694 * Module number. 5695 * Access: Index 5696 */ 5697 MLXSW_ITEM32(reg, pmaos, module, 0x00, 16, 8); 5698 5699 enum mlxsw_reg_pmaos_admin_status { 5700 MLXSW_REG_PMAOS_ADMIN_STATUS_ENABLED = 1, 5701 MLXSW_REG_PMAOS_ADMIN_STATUS_DISABLED = 2, 5702 /* If the module is active and then unplugged, or experienced an error 5703 * event, the operational status should go to "disabled" and can only 5704 * be enabled upon explicit enable command. 5705 */ 5706 MLXSW_REG_PMAOS_ADMIN_STATUS_ENABLED_ONCE = 3, 5707 }; 5708 5709 /* reg_pmaos_admin_status 5710 * Module administrative state (the desired state of the module). 5711 * Note: To disable a module, all ports associated with the port must be 5712 * administatively down first. 5713 * Access: RW 5714 */ 5715 MLXSW_ITEM32(reg, pmaos, admin_status, 0x00, 8, 4); 5716 5717 /* reg_pmaos_ase 5718 * Admin state update enable. 5719 * If this bit is set, admin state will be updated based on admin_state field. 5720 * Only relevant on Set() operations. 5721 * Access: WO 5722 */ 5723 MLXSW_ITEM32(reg, pmaos, ase, 0x04, 31, 1); 5724 5725 /* reg_pmaos_ee 5726 * Event update enable. 5727 * If this bit is set, event generation will be updated based on the e field. 5728 * Only relevant on Set operations. 5729 * Access: WO 5730 */ 5731 MLXSW_ITEM32(reg, pmaos, ee, 0x04, 30, 1); 5732 5733 enum mlxsw_reg_pmaos_e { 5734 MLXSW_REG_PMAOS_E_DO_NOT_GENERATE_EVENT, 5735 MLXSW_REG_PMAOS_E_GENERATE_EVENT, 5736 MLXSW_REG_PMAOS_E_GENERATE_SINGLE_EVENT, 5737 }; 5738 5739 /* reg_pmaos_e 5740 * Event Generation on operational state change. 5741 * Access: RW 5742 */ 5743 MLXSW_ITEM32(reg, pmaos, e, 0x04, 0, 2); 5744 5745 static inline void mlxsw_reg_pmaos_pack(char *payload, u8 module) 5746 { 5747 MLXSW_REG_ZERO(pmaos, payload); 5748 mlxsw_reg_pmaos_module_set(payload, module); 5749 } 5750 5751 /* PPLR - Port Physical Loopback Register 5752 * -------------------------------------- 5753 * This register allows configuration of the port's loopback mode. 5754 */ 5755 #define MLXSW_REG_PPLR_ID 0x5018 5756 #define MLXSW_REG_PPLR_LEN 0x8 5757 5758 MLXSW_REG_DEFINE(pplr, MLXSW_REG_PPLR_ID, MLXSW_REG_PPLR_LEN); 5759 5760 /* reg_pplr_local_port 5761 * Local port number. 5762 * Access: Index 5763 */ 5764 MLXSW_ITEM32_LP(reg, pplr, 0x00, 16, 0x00, 12); 5765 5766 /* Phy local loopback. When set the port's egress traffic is looped back 5767 * to the receiver and the port transmitter is disabled. 5768 */ 5769 #define MLXSW_REG_PPLR_LB_TYPE_BIT_PHY_LOCAL BIT(1) 5770 5771 /* reg_pplr_lb_en 5772 * Loopback enable. 5773 * Access: RW 5774 */ 5775 MLXSW_ITEM32(reg, pplr, lb_en, 0x04, 0, 8); 5776 5777 static inline void mlxsw_reg_pplr_pack(char *payload, u16 local_port, 5778 bool phy_local) 5779 { 5780 MLXSW_REG_ZERO(pplr, payload); 5781 mlxsw_reg_pplr_local_port_set(payload, local_port); 5782 mlxsw_reg_pplr_lb_en_set(payload, 5783 phy_local ? 5784 MLXSW_REG_PPLR_LB_TYPE_BIT_PHY_LOCAL : 0); 5785 } 5786 5787 /* PMTDB - Port Module To local DataBase Register 5788 * ---------------------------------------------- 5789 * The PMTDB register allows to query the possible module<->local port 5790 * mapping than can be used in PMLP. It does not represent the actual/current 5791 * mapping of the local to module. Actual mapping is only defined by PMLP. 5792 */ 5793 #define MLXSW_REG_PMTDB_ID 0x501A 5794 #define MLXSW_REG_PMTDB_LEN 0x40 5795 5796 MLXSW_REG_DEFINE(pmtdb, MLXSW_REG_PMTDB_ID, MLXSW_REG_PMTDB_LEN); 5797 5798 /* reg_pmtdb_slot_index 5799 * Slot index (0: Main board). 5800 * Access: Index 5801 */ 5802 MLXSW_ITEM32(reg, pmtdb, slot_index, 0x00, 24, 4); 5803 5804 /* reg_pmtdb_module 5805 * Module number. 5806 * Access: Index 5807 */ 5808 MLXSW_ITEM32(reg, pmtdb, module, 0x00, 16, 8); 5809 5810 /* reg_pmtdb_ports_width 5811 * Port's width 5812 * Access: Index 5813 */ 5814 MLXSW_ITEM32(reg, pmtdb, ports_width, 0x00, 12, 4); 5815 5816 /* reg_pmtdb_num_ports 5817 * Number of ports in a single module (split/breakout) 5818 * Access: Index 5819 */ 5820 MLXSW_ITEM32(reg, pmtdb, num_ports, 0x00, 8, 4); 5821 5822 enum mlxsw_reg_pmtdb_status { 5823 MLXSW_REG_PMTDB_STATUS_SUCCESS, 5824 }; 5825 5826 /* reg_pmtdb_status 5827 * Status 5828 * Access: RO 5829 */ 5830 MLXSW_ITEM32(reg, pmtdb, status, 0x00, 0, 4); 5831 5832 /* reg_pmtdb_port_num 5833 * The local_port value which can be assigned to the module. 5834 * In case of more than one port, port<x> represent the /<x> port of 5835 * the module. 5836 * Access: RO 5837 */ 5838 MLXSW_ITEM16_INDEXED(reg, pmtdb, port_num, 0x04, 0, 10, 0x02, 0x00, false); 5839 5840 static inline void mlxsw_reg_pmtdb_pack(char *payload, u8 slot_index, u8 module, 5841 u8 ports_width, u8 num_ports) 5842 { 5843 MLXSW_REG_ZERO(pmtdb, payload); 5844 mlxsw_reg_pmtdb_slot_index_set(payload, slot_index); 5845 mlxsw_reg_pmtdb_module_set(payload, module); 5846 mlxsw_reg_pmtdb_ports_width_set(payload, ports_width); 5847 mlxsw_reg_pmtdb_num_ports_set(payload, num_ports); 5848 } 5849 5850 /* PMPE - Port Module Plug/Unplug Event Register 5851 * --------------------------------------------- 5852 * This register reports any operational status change of a module. 5853 * A change in the module’s state will generate an event only if the change 5854 * happens after arming the event mechanism. Any changes to the module state 5855 * while the event mechanism is not armed will not be reported. Software can 5856 * query the PMPE register for module status. 5857 */ 5858 #define MLXSW_REG_PMPE_ID 0x5024 5859 #define MLXSW_REG_PMPE_LEN 0x10 5860 5861 MLXSW_REG_DEFINE(pmpe, MLXSW_REG_PMPE_ID, MLXSW_REG_PMPE_LEN); 5862 5863 /* reg_pmpe_slot_index 5864 * Slot index. 5865 * Access: Index 5866 */ 5867 MLXSW_ITEM32(reg, pmpe, slot_index, 0x00, 24, 4); 5868 5869 /* reg_pmpe_module 5870 * Module number. 5871 * Access: Index 5872 */ 5873 MLXSW_ITEM32(reg, pmpe, module, 0x00, 16, 8); 5874 5875 enum mlxsw_reg_pmpe_module_status { 5876 MLXSW_REG_PMPE_MODULE_STATUS_PLUGGED_ENABLED = 1, 5877 MLXSW_REG_PMPE_MODULE_STATUS_UNPLUGGED, 5878 MLXSW_REG_PMPE_MODULE_STATUS_PLUGGED_ERROR, 5879 MLXSW_REG_PMPE_MODULE_STATUS_PLUGGED_DISABLED, 5880 }; 5881 5882 /* reg_pmpe_module_status 5883 * Module status. 5884 * Access: RO 5885 */ 5886 MLXSW_ITEM32(reg, pmpe, module_status, 0x00, 0, 4); 5887 5888 /* reg_pmpe_error_type 5889 * Module error details. 5890 * Access: RO 5891 */ 5892 MLXSW_ITEM32(reg, pmpe, error_type, 0x04, 8, 4); 5893 5894 /* PDDR - Port Diagnostics Database Register 5895 * ----------------------------------------- 5896 * The PDDR enables to read the Phy debug database 5897 */ 5898 #define MLXSW_REG_PDDR_ID 0x5031 5899 #define MLXSW_REG_PDDR_LEN 0x100 5900 5901 MLXSW_REG_DEFINE(pddr, MLXSW_REG_PDDR_ID, MLXSW_REG_PDDR_LEN); 5902 5903 /* reg_pddr_local_port 5904 * Local port number. 5905 * Access: Index 5906 */ 5907 MLXSW_ITEM32_LP(reg, pddr, 0x00, 16, 0x00, 12); 5908 5909 enum mlxsw_reg_pddr_page_select { 5910 MLXSW_REG_PDDR_PAGE_SELECT_TROUBLESHOOTING_INFO = 1, 5911 }; 5912 5913 /* reg_pddr_page_select 5914 * Page select index. 5915 * Access: Index 5916 */ 5917 MLXSW_ITEM32(reg, pddr, page_select, 0x04, 0, 8); 5918 5919 enum mlxsw_reg_pddr_trblsh_group_opcode { 5920 /* Monitor opcodes */ 5921 MLXSW_REG_PDDR_TRBLSH_GROUP_OPCODE_MONITOR, 5922 }; 5923 5924 /* reg_pddr_group_opcode 5925 * Group selector. 5926 * Access: Index 5927 */ 5928 MLXSW_ITEM32(reg, pddr, trblsh_group_opcode, 0x08, 0, 16); 5929 5930 /* reg_pddr_status_opcode 5931 * Group selector. 5932 * Access: RO 5933 */ 5934 MLXSW_ITEM32(reg, pddr, trblsh_status_opcode, 0x0C, 0, 16); 5935 5936 static inline void mlxsw_reg_pddr_pack(char *payload, u16 local_port, 5937 u8 page_select) 5938 { 5939 MLXSW_REG_ZERO(pddr, payload); 5940 mlxsw_reg_pddr_local_port_set(payload, local_port); 5941 mlxsw_reg_pddr_page_select_set(payload, page_select); 5942 } 5943 5944 /* PMMP - Port Module Memory Map Properties Register 5945 * ------------------------------------------------- 5946 * The PMMP register allows to override the module memory map advertisement. 5947 * The register can only be set when the module is disabled by PMAOS register. 5948 */ 5949 #define MLXSW_REG_PMMP_ID 0x5044 5950 #define MLXSW_REG_PMMP_LEN 0x2C 5951 5952 MLXSW_REG_DEFINE(pmmp, MLXSW_REG_PMMP_ID, MLXSW_REG_PMMP_LEN); 5953 5954 /* reg_pmmp_module 5955 * Module number. 5956 * Access: Index 5957 */ 5958 MLXSW_ITEM32(reg, pmmp, module, 0x00, 16, 8); 5959 5960 /* reg_pmmp_sticky 5961 * When set, will keep eeprom_override values after plug-out event. 5962 * Access: OP 5963 */ 5964 MLXSW_ITEM32(reg, pmmp, sticky, 0x00, 0, 1); 5965 5966 /* reg_pmmp_eeprom_override_mask 5967 * Write mask bit (negative polarity). 5968 * 0 - Allow write 5969 * 1 - Ignore write 5970 * On write, indicates which of the bits from eeprom_override field are 5971 * updated. 5972 * Access: WO 5973 */ 5974 MLXSW_ITEM32(reg, pmmp, eeprom_override_mask, 0x04, 16, 16); 5975 5976 enum { 5977 /* Set module to low power mode */ 5978 MLXSW_REG_PMMP_EEPROM_OVERRIDE_LOW_POWER_MASK = BIT(8), 5979 }; 5980 5981 /* reg_pmmp_eeprom_override 5982 * Override / ignore EEPROM advertisement properties bitmask 5983 * Access: RW 5984 */ 5985 MLXSW_ITEM32(reg, pmmp, eeprom_override, 0x04, 0, 16); 5986 5987 static inline void mlxsw_reg_pmmp_pack(char *payload, u8 module) 5988 { 5989 MLXSW_REG_ZERO(pmmp, payload); 5990 mlxsw_reg_pmmp_module_set(payload, module); 5991 } 5992 5993 /* PLLP - Port Local port to Label Port mapping Register 5994 * ----------------------------------------------------- 5995 * The PLLP register returns the mapping from Local Port into Label Port. 5996 */ 5997 #define MLXSW_REG_PLLP_ID 0x504A 5998 #define MLXSW_REG_PLLP_LEN 0x10 5999 6000 MLXSW_REG_DEFINE(pllp, MLXSW_REG_PLLP_ID, MLXSW_REG_PLLP_LEN); 6001 6002 /* reg_pllp_local_port 6003 * Local port number. 6004 * Access: Index 6005 */ 6006 MLXSW_ITEM32_LP(reg, pllp, 0x00, 16, 0x00, 12); 6007 6008 /* reg_pllp_label_port 6009 * Front panel label of the port. 6010 * Access: RO 6011 */ 6012 MLXSW_ITEM32(reg, pllp, label_port, 0x00, 0, 8); 6013 6014 /* reg_pllp_split_num 6015 * Label split mapping for local_port. 6016 * Access: RO 6017 */ 6018 MLXSW_ITEM32(reg, pllp, split_num, 0x04, 0, 4); 6019 6020 /* reg_pllp_slot_index 6021 * Slot index (0: Main board). 6022 * Access: RO 6023 */ 6024 MLXSW_ITEM32(reg, pllp, slot_index, 0x08, 0, 4); 6025 6026 static inline void mlxsw_reg_pllp_pack(char *payload, u16 local_port) 6027 { 6028 MLXSW_REG_ZERO(pllp, payload); 6029 mlxsw_reg_pllp_local_port_set(payload, local_port); 6030 } 6031 6032 static inline void mlxsw_reg_pllp_unpack(char *payload, u8 *label_port, 6033 u8 *split_num, u8 *slot_index) 6034 { 6035 *label_port = mlxsw_reg_pllp_label_port_get(payload); 6036 *split_num = mlxsw_reg_pllp_split_num_get(payload); 6037 *slot_index = mlxsw_reg_pllp_slot_index_get(payload); 6038 } 6039 6040 /* HTGT - Host Trap Group Table 6041 * ---------------------------- 6042 * Configures the properties for forwarding to CPU. 6043 */ 6044 #define MLXSW_REG_HTGT_ID 0x7002 6045 #define MLXSW_REG_HTGT_LEN 0x20 6046 6047 MLXSW_REG_DEFINE(htgt, MLXSW_REG_HTGT_ID, MLXSW_REG_HTGT_LEN); 6048 6049 /* reg_htgt_swid 6050 * Switch partition ID. 6051 * Access: Index 6052 */ 6053 MLXSW_ITEM32(reg, htgt, swid, 0x00, 24, 8); 6054 6055 #define MLXSW_REG_HTGT_PATH_TYPE_LOCAL 0x0 /* For locally attached CPU */ 6056 6057 /* reg_htgt_type 6058 * CPU path type. 6059 * Access: RW 6060 */ 6061 MLXSW_ITEM32(reg, htgt, type, 0x00, 8, 4); 6062 6063 enum mlxsw_reg_htgt_trap_group { 6064 MLXSW_REG_HTGT_TRAP_GROUP_EMAD, 6065 MLXSW_REG_HTGT_TRAP_GROUP_MFDE, 6066 MLXSW_REG_HTGT_TRAP_GROUP_MTWE, 6067 MLXSW_REG_HTGT_TRAP_GROUP_PMPE, 6068 MLXSW_REG_HTGT_TRAP_GROUP_SP_STP, 6069 MLXSW_REG_HTGT_TRAP_GROUP_SP_LACP, 6070 MLXSW_REG_HTGT_TRAP_GROUP_SP_LLDP, 6071 MLXSW_REG_HTGT_TRAP_GROUP_SP_MC_SNOOPING, 6072 MLXSW_REG_HTGT_TRAP_GROUP_SP_BGP, 6073 MLXSW_REG_HTGT_TRAP_GROUP_SP_OSPF, 6074 MLXSW_REG_HTGT_TRAP_GROUP_SP_PIM, 6075 MLXSW_REG_HTGT_TRAP_GROUP_SP_MULTICAST, 6076 MLXSW_REG_HTGT_TRAP_GROUP_SP_NEIGH_DISCOVERY, 6077 MLXSW_REG_HTGT_TRAP_GROUP_SP_ROUTER_EXP, 6078 MLXSW_REG_HTGT_TRAP_GROUP_SP_EXTERNAL_ROUTE, 6079 MLXSW_REG_HTGT_TRAP_GROUP_SP_IP2ME, 6080 MLXSW_REG_HTGT_TRAP_GROUP_SP_DHCP, 6081 MLXSW_REG_HTGT_TRAP_GROUP_SP_EVENT, 6082 MLXSW_REG_HTGT_TRAP_GROUP_SP_IPV6, 6083 MLXSW_REG_HTGT_TRAP_GROUP_SP_LBERROR, 6084 MLXSW_REG_HTGT_TRAP_GROUP_SP_PTP0, 6085 MLXSW_REG_HTGT_TRAP_GROUP_SP_PTP1, 6086 MLXSW_REG_HTGT_TRAP_GROUP_SP_VRRP, 6087 MLXSW_REG_HTGT_TRAP_GROUP_SP_PKT_SAMPLE, 6088 MLXSW_REG_HTGT_TRAP_GROUP_SP_FLOW_LOGGING, 6089 MLXSW_REG_HTGT_TRAP_GROUP_SP_FID_MISS, 6090 MLXSW_REG_HTGT_TRAP_GROUP_SP_BFD, 6091 MLXSW_REG_HTGT_TRAP_GROUP_SP_DUMMY, 6092 MLXSW_REG_HTGT_TRAP_GROUP_SP_L2_DISCARDS, 6093 MLXSW_REG_HTGT_TRAP_GROUP_SP_L3_DISCARDS, 6094 MLXSW_REG_HTGT_TRAP_GROUP_SP_L3_EXCEPTIONS, 6095 MLXSW_REG_HTGT_TRAP_GROUP_SP_TUNNEL_DISCARDS, 6096 MLXSW_REG_HTGT_TRAP_GROUP_SP_ACL_DISCARDS, 6097 MLXSW_REG_HTGT_TRAP_GROUP_SP_BUFFER_DISCARDS, 6098 6099 __MLXSW_REG_HTGT_TRAP_GROUP_MAX, 6100 MLXSW_REG_HTGT_TRAP_GROUP_MAX = __MLXSW_REG_HTGT_TRAP_GROUP_MAX - 1 6101 }; 6102 6103 /* reg_htgt_trap_group 6104 * Trap group number. User defined number specifying which trap groups 6105 * should be forwarded to the CPU. The mapping between trap IDs and trap 6106 * groups is configured using HPKT register. 6107 * Access: Index 6108 */ 6109 MLXSW_ITEM32(reg, htgt, trap_group, 0x00, 0, 8); 6110 6111 enum { 6112 MLXSW_REG_HTGT_POLICER_DISABLE, 6113 MLXSW_REG_HTGT_POLICER_ENABLE, 6114 }; 6115 6116 /* reg_htgt_pide 6117 * Enable policer ID specified using 'pid' field. 6118 * Access: RW 6119 */ 6120 MLXSW_ITEM32(reg, htgt, pide, 0x04, 15, 1); 6121 6122 #define MLXSW_REG_HTGT_INVALID_POLICER 0xff 6123 6124 /* reg_htgt_pid 6125 * Policer ID for the trap group. 6126 * Access: RW 6127 */ 6128 MLXSW_ITEM32(reg, htgt, pid, 0x04, 0, 8); 6129 6130 #define MLXSW_REG_HTGT_TRAP_TO_CPU 0x0 6131 6132 /* reg_htgt_mirror_action 6133 * Mirror action to use. 6134 * 0 - Trap to CPU. 6135 * 1 - Trap to CPU and mirror to a mirroring agent. 6136 * 2 - Mirror to a mirroring agent and do not trap to CPU. 6137 * Access: RW 6138 * 6139 * Note: Mirroring to a mirroring agent is only supported in Spectrum. 6140 */ 6141 MLXSW_ITEM32(reg, htgt, mirror_action, 0x08, 8, 2); 6142 6143 /* reg_htgt_mirroring_agent 6144 * Mirroring agent. 6145 * Access: RW 6146 */ 6147 MLXSW_ITEM32(reg, htgt, mirroring_agent, 0x08, 0, 3); 6148 6149 #define MLXSW_REG_HTGT_DEFAULT_PRIORITY 0 6150 6151 /* reg_htgt_priority 6152 * Trap group priority. 6153 * In case a packet matches multiple classification rules, the packet will 6154 * only be trapped once, based on the trap ID associated with the group (via 6155 * register HPKT) with the highest priority. 6156 * Supported values are 0-7, with 7 represnting the highest priority. 6157 * Access: RW 6158 * 6159 * Note: In SwitchX-2 this field is ignored and the priority value is replaced 6160 * by the 'trap_group' field. 6161 */ 6162 MLXSW_ITEM32(reg, htgt, priority, 0x0C, 0, 4); 6163 6164 #define MLXSW_REG_HTGT_DEFAULT_TC 7 6165 6166 /* reg_htgt_local_path_cpu_tclass 6167 * CPU ingress traffic class for the trap group. 6168 * Access: RW 6169 */ 6170 MLXSW_ITEM32(reg, htgt, local_path_cpu_tclass, 0x10, 16, 6); 6171 6172 enum mlxsw_reg_htgt_local_path_rdq { 6173 MLXSW_REG_HTGT_LOCAL_PATH_RDQ_SX2_CTRL = 0x13, 6174 MLXSW_REG_HTGT_LOCAL_PATH_RDQ_SX2_RX = 0x14, 6175 MLXSW_REG_HTGT_LOCAL_PATH_RDQ_SX2_EMAD = 0x15, 6176 MLXSW_REG_HTGT_LOCAL_PATH_RDQ_SIB_EMAD = 0x15, 6177 }; 6178 /* reg_htgt_local_path_rdq 6179 * Receive descriptor queue (RDQ) to use for the trap group. 6180 * Access: RW 6181 */ 6182 MLXSW_ITEM32(reg, htgt, local_path_rdq, 0x10, 0, 6); 6183 6184 static inline void mlxsw_reg_htgt_pack(char *payload, u8 group, u8 policer_id, 6185 u8 priority, u8 tc) 6186 { 6187 MLXSW_REG_ZERO(htgt, payload); 6188 6189 if (policer_id == MLXSW_REG_HTGT_INVALID_POLICER) { 6190 mlxsw_reg_htgt_pide_set(payload, 6191 MLXSW_REG_HTGT_POLICER_DISABLE); 6192 } else { 6193 mlxsw_reg_htgt_pide_set(payload, 6194 MLXSW_REG_HTGT_POLICER_ENABLE); 6195 mlxsw_reg_htgt_pid_set(payload, policer_id); 6196 } 6197 6198 mlxsw_reg_htgt_type_set(payload, MLXSW_REG_HTGT_PATH_TYPE_LOCAL); 6199 mlxsw_reg_htgt_trap_group_set(payload, group); 6200 mlxsw_reg_htgt_mirror_action_set(payload, MLXSW_REG_HTGT_TRAP_TO_CPU); 6201 mlxsw_reg_htgt_mirroring_agent_set(payload, 0); 6202 mlxsw_reg_htgt_priority_set(payload, priority); 6203 mlxsw_reg_htgt_local_path_cpu_tclass_set(payload, tc); 6204 mlxsw_reg_htgt_local_path_rdq_set(payload, group); 6205 } 6206 6207 /* HPKT - Host Packet Trap 6208 * ----------------------- 6209 * Configures trap IDs inside trap groups. 6210 */ 6211 #define MLXSW_REG_HPKT_ID 0x7003 6212 #define MLXSW_REG_HPKT_LEN 0x10 6213 6214 MLXSW_REG_DEFINE(hpkt, MLXSW_REG_HPKT_ID, MLXSW_REG_HPKT_LEN); 6215 6216 enum { 6217 MLXSW_REG_HPKT_ACK_NOT_REQUIRED, 6218 MLXSW_REG_HPKT_ACK_REQUIRED, 6219 }; 6220 6221 /* reg_hpkt_ack 6222 * Require acknowledgements from the host for events. 6223 * If set, then the device will wait for the event it sent to be acknowledged 6224 * by the host. This option is only relevant for event trap IDs. 6225 * Access: RW 6226 * 6227 * Note: Currently not supported by firmware. 6228 */ 6229 MLXSW_ITEM32(reg, hpkt, ack, 0x00, 24, 1); 6230 6231 enum mlxsw_reg_hpkt_action { 6232 MLXSW_REG_HPKT_ACTION_FORWARD, 6233 MLXSW_REG_HPKT_ACTION_TRAP_TO_CPU, 6234 MLXSW_REG_HPKT_ACTION_MIRROR_TO_CPU, 6235 MLXSW_REG_HPKT_ACTION_DISCARD, 6236 MLXSW_REG_HPKT_ACTION_SOFT_DISCARD, 6237 MLXSW_REG_HPKT_ACTION_TRAP_AND_SOFT_DISCARD, 6238 MLXSW_REG_HPKT_ACTION_TRAP_EXCEPTION_TO_CPU, 6239 MLXSW_REG_HPKT_ACTION_SET_FW_DEFAULT = 15, 6240 }; 6241 6242 /* reg_hpkt_action 6243 * Action to perform on packet when trapped. 6244 * 0 - No action. Forward to CPU based on switching rules. 6245 * 1 - Trap to CPU (CPU receives sole copy). 6246 * 2 - Mirror to CPU (CPU receives a replica of the packet). 6247 * 3 - Discard. 6248 * 4 - Soft discard (allow other traps to act on the packet). 6249 * 5 - Trap and soft discard (allow other traps to overwrite this trap). 6250 * 6 - Trap to CPU (CPU receives sole copy) and count it as error. 6251 * 15 - Restore the firmware's default action. 6252 * Access: RW 6253 * 6254 * Note: Must be set to 0 (forward) for event trap IDs, as they are already 6255 * addressed to the CPU. 6256 */ 6257 MLXSW_ITEM32(reg, hpkt, action, 0x00, 20, 3); 6258 6259 /* reg_hpkt_trap_group 6260 * Trap group to associate the trap with. 6261 * Access: RW 6262 */ 6263 MLXSW_ITEM32(reg, hpkt, trap_group, 0x00, 12, 6); 6264 6265 /* reg_hpkt_trap_id 6266 * Trap ID. 6267 * Access: Index 6268 * 6269 * Note: A trap ID can only be associated with a single trap group. The device 6270 * will associate the trap ID with the last trap group configured. 6271 */ 6272 MLXSW_ITEM32(reg, hpkt, trap_id, 0x00, 0, 10); 6273 6274 enum { 6275 MLXSW_REG_HPKT_CTRL_PACKET_DEFAULT, 6276 MLXSW_REG_HPKT_CTRL_PACKET_NO_BUFFER, 6277 MLXSW_REG_HPKT_CTRL_PACKET_USE_BUFFER, 6278 }; 6279 6280 /* reg_hpkt_ctrl 6281 * Configure dedicated buffer resources for control packets. 6282 * Ignored by SwitchX-2. 6283 * 0 - Keep factory defaults. 6284 * 1 - Do not use control buffer for this trap ID. 6285 * 2 - Use control buffer for this trap ID. 6286 * Access: RW 6287 */ 6288 MLXSW_ITEM32(reg, hpkt, ctrl, 0x04, 16, 2); 6289 6290 static inline void mlxsw_reg_hpkt_pack(char *payload, u8 action, u16 trap_id, 6291 enum mlxsw_reg_htgt_trap_group trap_group, 6292 bool is_ctrl) 6293 { 6294 MLXSW_REG_ZERO(hpkt, payload); 6295 mlxsw_reg_hpkt_ack_set(payload, MLXSW_REG_HPKT_ACK_NOT_REQUIRED); 6296 mlxsw_reg_hpkt_action_set(payload, action); 6297 mlxsw_reg_hpkt_trap_group_set(payload, trap_group); 6298 mlxsw_reg_hpkt_trap_id_set(payload, trap_id); 6299 mlxsw_reg_hpkt_ctrl_set(payload, is_ctrl ? 6300 MLXSW_REG_HPKT_CTRL_PACKET_USE_BUFFER : 6301 MLXSW_REG_HPKT_CTRL_PACKET_NO_BUFFER); 6302 } 6303 6304 /* RGCR - Router General Configuration Register 6305 * -------------------------------------------- 6306 * The register is used for setting up the router configuration. 6307 */ 6308 #define MLXSW_REG_RGCR_ID 0x8001 6309 #define MLXSW_REG_RGCR_LEN 0x28 6310 6311 MLXSW_REG_DEFINE(rgcr, MLXSW_REG_RGCR_ID, MLXSW_REG_RGCR_LEN); 6312 6313 /* reg_rgcr_ipv4_en 6314 * IPv4 router enable. 6315 * Access: RW 6316 */ 6317 MLXSW_ITEM32(reg, rgcr, ipv4_en, 0x00, 31, 1); 6318 6319 /* reg_rgcr_ipv6_en 6320 * IPv6 router enable. 6321 * Access: RW 6322 */ 6323 MLXSW_ITEM32(reg, rgcr, ipv6_en, 0x00, 30, 1); 6324 6325 /* reg_rgcr_max_router_interfaces 6326 * Defines the maximum number of active router interfaces for all virtual 6327 * routers. 6328 * Access: RW 6329 */ 6330 MLXSW_ITEM32(reg, rgcr, max_router_interfaces, 0x10, 0, 16); 6331 6332 /* reg_rgcr_usp 6333 * Update switch priority and packet color. 6334 * 0 - Preserve the value of Switch Priority and packet color. 6335 * 1 - Recalculate the value of Switch Priority and packet color. 6336 * Access: RW 6337 * 6338 * Note: Not supported by SwitchX and SwitchX-2. 6339 */ 6340 MLXSW_ITEM32(reg, rgcr, usp, 0x18, 20, 1); 6341 6342 /* reg_rgcr_pcp_rw 6343 * Indicates how to handle the pcp_rewrite_en value: 6344 * 0 - Preserve the value of pcp_rewrite_en. 6345 * 2 - Disable PCP rewrite. 6346 * 3 - Enable PCP rewrite. 6347 * Access: RW 6348 * 6349 * Note: Not supported by SwitchX and SwitchX-2. 6350 */ 6351 MLXSW_ITEM32(reg, rgcr, pcp_rw, 0x18, 16, 2); 6352 6353 /* reg_rgcr_activity_dis 6354 * Activity disable: 6355 * 0 - Activity will be set when an entry is hit (default). 6356 * 1 - Activity will not be set when an entry is hit. 6357 * 6358 * Bit 0 - Disable activity bit in Router Algorithmic LPM Unicast Entry 6359 * (RALUE). 6360 * Bit 1 - Disable activity bit in Router Algorithmic LPM Unicast Host 6361 * Entry (RAUHT). 6362 * Bits 2:7 are reserved. 6363 * Access: RW 6364 * 6365 * Note: Not supported by SwitchX, SwitchX-2 and Switch-IB. 6366 */ 6367 MLXSW_ITEM32(reg, rgcr, activity_dis, 0x20, 0, 8); 6368 6369 static inline void mlxsw_reg_rgcr_pack(char *payload, bool ipv4_en, 6370 bool ipv6_en) 6371 { 6372 MLXSW_REG_ZERO(rgcr, payload); 6373 mlxsw_reg_rgcr_ipv4_en_set(payload, ipv4_en); 6374 mlxsw_reg_rgcr_ipv6_en_set(payload, ipv6_en); 6375 } 6376 6377 /* RITR - Router Interface Table Register 6378 * -------------------------------------- 6379 * The register is used to configure the router interface table. 6380 */ 6381 #define MLXSW_REG_RITR_ID 0x8002 6382 #define MLXSW_REG_RITR_LEN 0x40 6383 6384 MLXSW_REG_DEFINE(ritr, MLXSW_REG_RITR_ID, MLXSW_REG_RITR_LEN); 6385 6386 /* reg_ritr_enable 6387 * Enables routing on the router interface. 6388 * Access: RW 6389 */ 6390 MLXSW_ITEM32(reg, ritr, enable, 0x00, 31, 1); 6391 6392 /* reg_ritr_ipv4 6393 * IPv4 routing enable. Enables routing of IPv4 traffic on the router 6394 * interface. 6395 * Access: RW 6396 */ 6397 MLXSW_ITEM32(reg, ritr, ipv4, 0x00, 29, 1); 6398 6399 /* reg_ritr_ipv6 6400 * IPv6 routing enable. Enables routing of IPv6 traffic on the router 6401 * interface. 6402 * Access: RW 6403 */ 6404 MLXSW_ITEM32(reg, ritr, ipv6, 0x00, 28, 1); 6405 6406 /* reg_ritr_ipv4_mc 6407 * IPv4 multicast routing enable. 6408 * Access: RW 6409 */ 6410 MLXSW_ITEM32(reg, ritr, ipv4_mc, 0x00, 27, 1); 6411 6412 /* reg_ritr_ipv6_mc 6413 * IPv6 multicast routing enable. 6414 * Access: RW 6415 */ 6416 MLXSW_ITEM32(reg, ritr, ipv6_mc, 0x00, 26, 1); 6417 6418 enum mlxsw_reg_ritr_if_type { 6419 /* VLAN interface. */ 6420 MLXSW_REG_RITR_VLAN_IF, 6421 /* FID interface. */ 6422 MLXSW_REG_RITR_FID_IF, 6423 /* Sub-port interface. */ 6424 MLXSW_REG_RITR_SP_IF, 6425 /* Loopback Interface. */ 6426 MLXSW_REG_RITR_LOOPBACK_IF, 6427 }; 6428 6429 /* reg_ritr_type 6430 * Router interface type as per enum mlxsw_reg_ritr_if_type. 6431 * Access: RW 6432 */ 6433 MLXSW_ITEM32(reg, ritr, type, 0x00, 23, 3); 6434 6435 enum { 6436 MLXSW_REG_RITR_RIF_CREATE, 6437 MLXSW_REG_RITR_RIF_DEL, 6438 }; 6439 6440 /* reg_ritr_op 6441 * Opcode: 6442 * 0 - Create or edit RIF. 6443 * 1 - Delete RIF. 6444 * Reserved for SwitchX-2. For Spectrum, editing of interface properties 6445 * is not supported. An interface must be deleted and re-created in order 6446 * to update properties. 6447 * Access: WO 6448 */ 6449 MLXSW_ITEM32(reg, ritr, op, 0x00, 20, 2); 6450 6451 /* reg_ritr_rif 6452 * Router interface index. A pointer to the Router Interface Table. 6453 * Access: Index 6454 */ 6455 MLXSW_ITEM32(reg, ritr, rif, 0x00, 0, 16); 6456 6457 /* reg_ritr_ipv4_fe 6458 * IPv4 Forwarding Enable. 6459 * Enables routing of IPv4 traffic on the router interface. When disabled, 6460 * forwarding is blocked but local traffic (traps and IP2ME) will be enabled. 6461 * Not supported in SwitchX-2. 6462 * Access: RW 6463 */ 6464 MLXSW_ITEM32(reg, ritr, ipv4_fe, 0x04, 29, 1); 6465 6466 /* reg_ritr_ipv6_fe 6467 * IPv6 Forwarding Enable. 6468 * Enables routing of IPv6 traffic on the router interface. When disabled, 6469 * forwarding is blocked but local traffic (traps and IP2ME) will be enabled. 6470 * Not supported in SwitchX-2. 6471 * Access: RW 6472 */ 6473 MLXSW_ITEM32(reg, ritr, ipv6_fe, 0x04, 28, 1); 6474 6475 /* reg_ritr_ipv4_mc_fe 6476 * IPv4 Multicast Forwarding Enable. 6477 * When disabled, forwarding is blocked but local traffic (traps and IP to me) 6478 * will be enabled. 6479 * Access: RW 6480 */ 6481 MLXSW_ITEM32(reg, ritr, ipv4_mc_fe, 0x04, 27, 1); 6482 6483 /* reg_ritr_ipv6_mc_fe 6484 * IPv6 Multicast Forwarding Enable. 6485 * When disabled, forwarding is blocked but local traffic (traps and IP to me) 6486 * will be enabled. 6487 * Access: RW 6488 */ 6489 MLXSW_ITEM32(reg, ritr, ipv6_mc_fe, 0x04, 26, 1); 6490 6491 /* reg_ritr_lb_en 6492 * Loop-back filter enable for unicast packets. 6493 * If the flag is set then loop-back filter for unicast packets is 6494 * implemented on the RIF. Multicast packets are always subject to 6495 * loop-back filtering. 6496 * Access: RW 6497 */ 6498 MLXSW_ITEM32(reg, ritr, lb_en, 0x04, 24, 1); 6499 6500 /* reg_ritr_virtual_router 6501 * Virtual router ID associated with the router interface. 6502 * Access: RW 6503 */ 6504 MLXSW_ITEM32(reg, ritr, virtual_router, 0x04, 0, 16); 6505 6506 /* reg_ritr_mtu 6507 * Router interface MTU. 6508 * Access: RW 6509 */ 6510 MLXSW_ITEM32(reg, ritr, mtu, 0x34, 0, 16); 6511 6512 /* reg_ritr_if_swid 6513 * Switch partition ID. 6514 * Access: RW 6515 */ 6516 MLXSW_ITEM32(reg, ritr, if_swid, 0x08, 24, 8); 6517 6518 /* reg_ritr_if_mac_profile_id 6519 * MAC msb profile ID. 6520 * Access: RW 6521 */ 6522 MLXSW_ITEM32(reg, ritr, if_mac_profile_id, 0x10, 16, 4); 6523 6524 /* reg_ritr_if_mac 6525 * Router interface MAC address. 6526 * In Spectrum, all MAC addresses must have the same 38 MSBits. 6527 * Access: RW 6528 */ 6529 MLXSW_ITEM_BUF(reg, ritr, if_mac, 0x12, 6); 6530 6531 /* reg_ritr_if_vrrp_id_ipv6 6532 * VRRP ID for IPv6 6533 * Note: Reserved for RIF types other than VLAN, FID and Sub-port. 6534 * Access: RW 6535 */ 6536 MLXSW_ITEM32(reg, ritr, if_vrrp_id_ipv6, 0x1C, 8, 8); 6537 6538 /* reg_ritr_if_vrrp_id_ipv4 6539 * VRRP ID for IPv4 6540 * Note: Reserved for RIF types other than VLAN, FID and Sub-port. 6541 * Access: RW 6542 */ 6543 MLXSW_ITEM32(reg, ritr, if_vrrp_id_ipv4, 0x1C, 0, 8); 6544 6545 /* VLAN Interface */ 6546 6547 /* reg_ritr_vlan_if_vid 6548 * VLAN ID. 6549 * Access: RW 6550 */ 6551 MLXSW_ITEM32(reg, ritr, vlan_if_vid, 0x08, 0, 12); 6552 6553 /* FID Interface */ 6554 6555 /* reg_ritr_fid_if_fid 6556 * Filtering ID. Used to connect a bridge to the router. Only FIDs from 6557 * the vFID range are supported. 6558 * Access: RW 6559 */ 6560 MLXSW_ITEM32(reg, ritr, fid_if_fid, 0x08, 0, 16); 6561 6562 static inline void mlxsw_reg_ritr_fid_set(char *payload, 6563 enum mlxsw_reg_ritr_if_type rif_type, 6564 u16 fid) 6565 { 6566 if (rif_type == MLXSW_REG_RITR_FID_IF) 6567 mlxsw_reg_ritr_fid_if_fid_set(payload, fid); 6568 else 6569 mlxsw_reg_ritr_vlan_if_vid_set(payload, fid); 6570 } 6571 6572 /* Sub-port Interface */ 6573 6574 /* reg_ritr_sp_if_lag 6575 * LAG indication. When this bit is set the system_port field holds the 6576 * LAG identifier. 6577 * Access: RW 6578 */ 6579 MLXSW_ITEM32(reg, ritr, sp_if_lag, 0x08, 24, 1); 6580 6581 /* reg_ritr_sp_system_port 6582 * Port unique indentifier. When lag bit is set, this field holds the 6583 * lag_id in bits 0:9. 6584 * Access: RW 6585 */ 6586 MLXSW_ITEM32(reg, ritr, sp_if_system_port, 0x08, 0, 16); 6587 6588 /* reg_ritr_sp_if_vid 6589 * VLAN ID. 6590 * Access: RW 6591 */ 6592 MLXSW_ITEM32(reg, ritr, sp_if_vid, 0x18, 0, 12); 6593 6594 /* Loopback Interface */ 6595 6596 enum mlxsw_reg_ritr_loopback_protocol { 6597 /* IPinIP IPv4 underlay Unicast */ 6598 MLXSW_REG_RITR_LOOPBACK_PROTOCOL_IPIP_IPV4, 6599 /* IPinIP IPv6 underlay Unicast */ 6600 MLXSW_REG_RITR_LOOPBACK_PROTOCOL_IPIP_IPV6, 6601 /* IPinIP generic - used for Spectrum-2 underlay RIF */ 6602 MLXSW_REG_RITR_LOOPBACK_GENERIC, 6603 }; 6604 6605 /* reg_ritr_loopback_protocol 6606 * Access: RW 6607 */ 6608 MLXSW_ITEM32(reg, ritr, loopback_protocol, 0x08, 28, 4); 6609 6610 enum mlxsw_reg_ritr_loopback_ipip_type { 6611 /* Tunnel is IPinIP. */ 6612 MLXSW_REG_RITR_LOOPBACK_IPIP_TYPE_IP_IN_IP, 6613 /* Tunnel is GRE, no key. */ 6614 MLXSW_REG_RITR_LOOPBACK_IPIP_TYPE_IP_IN_GRE_IN_IP, 6615 /* Tunnel is GRE, with a key. */ 6616 MLXSW_REG_RITR_LOOPBACK_IPIP_TYPE_IP_IN_GRE_KEY_IN_IP, 6617 }; 6618 6619 /* reg_ritr_loopback_ipip_type 6620 * Encapsulation type. 6621 * Access: RW 6622 */ 6623 MLXSW_ITEM32(reg, ritr, loopback_ipip_type, 0x10, 24, 4); 6624 6625 enum mlxsw_reg_ritr_loopback_ipip_options { 6626 /* The key is defined by gre_key. */ 6627 MLXSW_REG_RITR_LOOPBACK_IPIP_OPTIONS_GRE_KEY_PRESET, 6628 }; 6629 6630 /* reg_ritr_loopback_ipip_options 6631 * Access: RW 6632 */ 6633 MLXSW_ITEM32(reg, ritr, loopback_ipip_options, 0x10, 20, 4); 6634 6635 /* reg_ritr_loopback_ipip_uvr 6636 * Underlay Virtual Router ID. 6637 * Range is 0..cap_max_virtual_routers-1. 6638 * Reserved for Spectrum-2. 6639 * Access: RW 6640 */ 6641 MLXSW_ITEM32(reg, ritr, loopback_ipip_uvr, 0x10, 0, 16); 6642 6643 /* reg_ritr_loopback_ipip_underlay_rif 6644 * Underlay ingress router interface. 6645 * Reserved for Spectrum. 6646 * Access: RW 6647 */ 6648 MLXSW_ITEM32(reg, ritr, loopback_ipip_underlay_rif, 0x14, 0, 16); 6649 6650 /* reg_ritr_loopback_ipip_usip* 6651 * Encapsulation Underlay source IP. 6652 * Access: RW 6653 */ 6654 MLXSW_ITEM_BUF(reg, ritr, loopback_ipip_usip6, 0x18, 16); 6655 MLXSW_ITEM32(reg, ritr, loopback_ipip_usip4, 0x24, 0, 32); 6656 6657 /* reg_ritr_loopback_ipip_gre_key 6658 * GRE Key. 6659 * Reserved when ipip_type is not IP_IN_GRE_KEY_IN_IP. 6660 * Access: RW 6661 */ 6662 MLXSW_ITEM32(reg, ritr, loopback_ipip_gre_key, 0x28, 0, 32); 6663 6664 /* Shared between ingress/egress */ 6665 enum mlxsw_reg_ritr_counter_set_type { 6666 /* No Count. */ 6667 MLXSW_REG_RITR_COUNTER_SET_TYPE_NO_COUNT = 0x0, 6668 /* Basic. Used for router interfaces, counting the following: 6669 * - Error and Discard counters. 6670 * - Unicast, Multicast and Broadcast counters. Sharing the 6671 * same set of counters for the different type of traffic 6672 * (IPv4, IPv6 and mpls). 6673 */ 6674 MLXSW_REG_RITR_COUNTER_SET_TYPE_BASIC = 0x9, 6675 }; 6676 6677 /* reg_ritr_ingress_counter_index 6678 * Counter Index for flow counter. 6679 * Access: RW 6680 */ 6681 MLXSW_ITEM32(reg, ritr, ingress_counter_index, 0x38, 0, 24); 6682 6683 /* reg_ritr_ingress_counter_set_type 6684 * Igress Counter Set Type for router interface counter. 6685 * Access: RW 6686 */ 6687 MLXSW_ITEM32(reg, ritr, ingress_counter_set_type, 0x38, 24, 8); 6688 6689 /* reg_ritr_egress_counter_index 6690 * Counter Index for flow counter. 6691 * Access: RW 6692 */ 6693 MLXSW_ITEM32(reg, ritr, egress_counter_index, 0x3C, 0, 24); 6694 6695 /* reg_ritr_egress_counter_set_type 6696 * Egress Counter Set Type for router interface counter. 6697 * Access: RW 6698 */ 6699 MLXSW_ITEM32(reg, ritr, egress_counter_set_type, 0x3C, 24, 8); 6700 6701 static inline void mlxsw_reg_ritr_counter_pack(char *payload, u32 index, 6702 bool enable, bool egress) 6703 { 6704 enum mlxsw_reg_ritr_counter_set_type set_type; 6705 6706 if (enable) 6707 set_type = MLXSW_REG_RITR_COUNTER_SET_TYPE_BASIC; 6708 else 6709 set_type = MLXSW_REG_RITR_COUNTER_SET_TYPE_NO_COUNT; 6710 mlxsw_reg_ritr_egress_counter_set_type_set(payload, set_type); 6711 6712 if (egress) 6713 mlxsw_reg_ritr_egress_counter_index_set(payload, index); 6714 else 6715 mlxsw_reg_ritr_ingress_counter_index_set(payload, index); 6716 } 6717 6718 static inline void mlxsw_reg_ritr_rif_pack(char *payload, u16 rif) 6719 { 6720 MLXSW_REG_ZERO(ritr, payload); 6721 mlxsw_reg_ritr_rif_set(payload, rif); 6722 } 6723 6724 static inline void mlxsw_reg_ritr_sp_if_pack(char *payload, bool lag, 6725 u16 system_port, u16 vid) 6726 { 6727 mlxsw_reg_ritr_sp_if_lag_set(payload, lag); 6728 mlxsw_reg_ritr_sp_if_system_port_set(payload, system_port); 6729 mlxsw_reg_ritr_sp_if_vid_set(payload, vid); 6730 } 6731 6732 static inline void mlxsw_reg_ritr_pack(char *payload, bool enable, 6733 enum mlxsw_reg_ritr_if_type type, 6734 u16 rif, u16 vr_id, u16 mtu) 6735 { 6736 bool op = enable ? MLXSW_REG_RITR_RIF_CREATE : MLXSW_REG_RITR_RIF_DEL; 6737 6738 MLXSW_REG_ZERO(ritr, payload); 6739 mlxsw_reg_ritr_enable_set(payload, enable); 6740 mlxsw_reg_ritr_ipv4_set(payload, 1); 6741 mlxsw_reg_ritr_ipv6_set(payload, 1); 6742 mlxsw_reg_ritr_ipv4_mc_set(payload, 1); 6743 mlxsw_reg_ritr_ipv6_mc_set(payload, 1); 6744 mlxsw_reg_ritr_type_set(payload, type); 6745 mlxsw_reg_ritr_op_set(payload, op); 6746 mlxsw_reg_ritr_rif_set(payload, rif); 6747 mlxsw_reg_ritr_ipv4_fe_set(payload, 1); 6748 mlxsw_reg_ritr_ipv6_fe_set(payload, 1); 6749 mlxsw_reg_ritr_ipv4_mc_fe_set(payload, 1); 6750 mlxsw_reg_ritr_ipv6_mc_fe_set(payload, 1); 6751 mlxsw_reg_ritr_lb_en_set(payload, 1); 6752 mlxsw_reg_ritr_virtual_router_set(payload, vr_id); 6753 mlxsw_reg_ritr_mtu_set(payload, mtu); 6754 } 6755 6756 static inline void mlxsw_reg_ritr_mac_pack(char *payload, const char *mac) 6757 { 6758 mlxsw_reg_ritr_if_mac_memcpy_to(payload, mac); 6759 } 6760 6761 static inline void 6762 mlxsw_reg_ritr_loopback_ipip_common_pack(char *payload, 6763 enum mlxsw_reg_ritr_loopback_ipip_type ipip_type, 6764 enum mlxsw_reg_ritr_loopback_ipip_options options, 6765 u16 uvr_id, u16 underlay_rif, u32 gre_key) 6766 { 6767 mlxsw_reg_ritr_loopback_ipip_type_set(payload, ipip_type); 6768 mlxsw_reg_ritr_loopback_ipip_options_set(payload, options); 6769 mlxsw_reg_ritr_loopback_ipip_uvr_set(payload, uvr_id); 6770 mlxsw_reg_ritr_loopback_ipip_underlay_rif_set(payload, underlay_rif); 6771 mlxsw_reg_ritr_loopback_ipip_gre_key_set(payload, gre_key); 6772 } 6773 6774 static inline void 6775 mlxsw_reg_ritr_loopback_ipip4_pack(char *payload, 6776 enum mlxsw_reg_ritr_loopback_ipip_type ipip_type, 6777 enum mlxsw_reg_ritr_loopback_ipip_options options, 6778 u16 uvr_id, u16 underlay_rif, u32 usip, u32 gre_key) 6779 { 6780 mlxsw_reg_ritr_loopback_protocol_set(payload, 6781 MLXSW_REG_RITR_LOOPBACK_PROTOCOL_IPIP_IPV4); 6782 mlxsw_reg_ritr_loopback_ipip_common_pack(payload, ipip_type, options, 6783 uvr_id, underlay_rif, gre_key); 6784 mlxsw_reg_ritr_loopback_ipip_usip4_set(payload, usip); 6785 } 6786 6787 static inline void 6788 mlxsw_reg_ritr_loopback_ipip6_pack(char *payload, 6789 enum mlxsw_reg_ritr_loopback_ipip_type ipip_type, 6790 enum mlxsw_reg_ritr_loopback_ipip_options options, 6791 u16 uvr_id, u16 underlay_rif, 6792 const struct in6_addr *usip, u32 gre_key) 6793 { 6794 enum mlxsw_reg_ritr_loopback_protocol protocol = 6795 MLXSW_REG_RITR_LOOPBACK_PROTOCOL_IPIP_IPV6; 6796 6797 mlxsw_reg_ritr_loopback_protocol_set(payload, protocol); 6798 mlxsw_reg_ritr_loopback_ipip_common_pack(payload, ipip_type, options, 6799 uvr_id, underlay_rif, gre_key); 6800 mlxsw_reg_ritr_loopback_ipip_usip6_memcpy_to(payload, 6801 (const char *)usip); 6802 } 6803 6804 /* RTAR - Router TCAM Allocation Register 6805 * -------------------------------------- 6806 * This register is used for allocation of regions in the TCAM table. 6807 */ 6808 #define MLXSW_REG_RTAR_ID 0x8004 6809 #define MLXSW_REG_RTAR_LEN 0x20 6810 6811 MLXSW_REG_DEFINE(rtar, MLXSW_REG_RTAR_ID, MLXSW_REG_RTAR_LEN); 6812 6813 enum mlxsw_reg_rtar_op { 6814 MLXSW_REG_RTAR_OP_ALLOCATE, 6815 MLXSW_REG_RTAR_OP_RESIZE, 6816 MLXSW_REG_RTAR_OP_DEALLOCATE, 6817 }; 6818 6819 /* reg_rtar_op 6820 * Access: WO 6821 */ 6822 MLXSW_ITEM32(reg, rtar, op, 0x00, 28, 4); 6823 6824 enum mlxsw_reg_rtar_key_type { 6825 MLXSW_REG_RTAR_KEY_TYPE_IPV4_MULTICAST = 1, 6826 MLXSW_REG_RTAR_KEY_TYPE_IPV6_MULTICAST = 3 6827 }; 6828 6829 /* reg_rtar_key_type 6830 * TCAM key type for the region. 6831 * Access: WO 6832 */ 6833 MLXSW_ITEM32(reg, rtar, key_type, 0x00, 0, 8); 6834 6835 /* reg_rtar_region_size 6836 * TCAM region size. When allocating/resizing this is the requested 6837 * size, the response is the actual size. 6838 * Note: Actual size may be larger than requested. 6839 * Reserved for op = Deallocate 6840 * Access: WO 6841 */ 6842 MLXSW_ITEM32(reg, rtar, region_size, 0x04, 0, 16); 6843 6844 static inline void mlxsw_reg_rtar_pack(char *payload, 6845 enum mlxsw_reg_rtar_op op, 6846 enum mlxsw_reg_rtar_key_type key_type, 6847 u16 region_size) 6848 { 6849 MLXSW_REG_ZERO(rtar, payload); 6850 mlxsw_reg_rtar_op_set(payload, op); 6851 mlxsw_reg_rtar_key_type_set(payload, key_type); 6852 mlxsw_reg_rtar_region_size_set(payload, region_size); 6853 } 6854 6855 /* RATR - Router Adjacency Table Register 6856 * -------------------------------------- 6857 * The RATR register is used to configure the Router Adjacency (next-hop) 6858 * Table. 6859 */ 6860 #define MLXSW_REG_RATR_ID 0x8008 6861 #define MLXSW_REG_RATR_LEN 0x2C 6862 6863 MLXSW_REG_DEFINE(ratr, MLXSW_REG_RATR_ID, MLXSW_REG_RATR_LEN); 6864 6865 enum mlxsw_reg_ratr_op { 6866 /* Read */ 6867 MLXSW_REG_RATR_OP_QUERY_READ = 0, 6868 /* Read and clear activity */ 6869 MLXSW_REG_RATR_OP_QUERY_READ_CLEAR = 2, 6870 /* Write Adjacency entry */ 6871 MLXSW_REG_RATR_OP_WRITE_WRITE_ENTRY = 1, 6872 /* Write Adjacency entry only if the activity is cleared. 6873 * The write may not succeed if the activity is set. There is not 6874 * direct feedback if the write has succeeded or not, however 6875 * the get will reveal the actual entry (SW can compare the get 6876 * response to the set command). 6877 */ 6878 MLXSW_REG_RATR_OP_WRITE_WRITE_ENTRY_ON_ACTIVITY = 3, 6879 }; 6880 6881 /* reg_ratr_op 6882 * Note that Write operation may also be used for updating 6883 * counter_set_type and counter_index. In this case all other 6884 * fields must not be updated. 6885 * Access: OP 6886 */ 6887 MLXSW_ITEM32(reg, ratr, op, 0x00, 28, 4); 6888 6889 /* reg_ratr_v 6890 * Valid bit. Indicates if the adjacency entry is valid. 6891 * Note: the device may need some time before reusing an invalidated 6892 * entry. During this time the entry can not be reused. It is 6893 * recommended to use another entry before reusing an invalidated 6894 * entry (e.g. software can put it at the end of the list for 6895 * reusing). Trying to access an invalidated entry not yet cleared 6896 * by the device results with failure indicating "Try Again" status. 6897 * When valid is '0' then egress_router_interface,trap_action, 6898 * adjacency_parameters and counters are reserved 6899 * Access: RW 6900 */ 6901 MLXSW_ITEM32(reg, ratr, v, 0x00, 24, 1); 6902 6903 /* reg_ratr_a 6904 * Activity. Set for new entries. Set if a packet lookup has hit on 6905 * the specific entry. To clear the a bit, use "clear activity". 6906 * Access: RO 6907 */ 6908 MLXSW_ITEM32(reg, ratr, a, 0x00, 16, 1); 6909 6910 enum mlxsw_reg_ratr_type { 6911 /* Ethernet */ 6912 MLXSW_REG_RATR_TYPE_ETHERNET, 6913 /* IPoIB Unicast without GRH. 6914 * Reserved for Spectrum. 6915 */ 6916 MLXSW_REG_RATR_TYPE_IPOIB_UC, 6917 /* IPoIB Unicast with GRH. Supported only in table 0 (Ethernet unicast 6918 * adjacency). 6919 * Reserved for Spectrum. 6920 */ 6921 MLXSW_REG_RATR_TYPE_IPOIB_UC_W_GRH, 6922 /* IPoIB Multicast. 6923 * Reserved for Spectrum. 6924 */ 6925 MLXSW_REG_RATR_TYPE_IPOIB_MC, 6926 /* MPLS. 6927 * Reserved for SwitchX/-2. 6928 */ 6929 MLXSW_REG_RATR_TYPE_MPLS, 6930 /* IPinIP Encap. 6931 * Reserved for SwitchX/-2. 6932 */ 6933 MLXSW_REG_RATR_TYPE_IPIP, 6934 }; 6935 6936 /* reg_ratr_type 6937 * Adjacency entry type. 6938 * Access: RW 6939 */ 6940 MLXSW_ITEM32(reg, ratr, type, 0x04, 28, 4); 6941 6942 /* reg_ratr_adjacency_index_low 6943 * Bits 15:0 of index into the adjacency table. 6944 * For SwitchX and SwitchX-2, the adjacency table is linear and 6945 * used for adjacency entries only. 6946 * For Spectrum, the index is to the KVD linear. 6947 * Access: Index 6948 */ 6949 MLXSW_ITEM32(reg, ratr, adjacency_index_low, 0x04, 0, 16); 6950 6951 /* reg_ratr_egress_router_interface 6952 * Range is 0 .. cap_max_router_interfaces - 1 6953 * Access: RW 6954 */ 6955 MLXSW_ITEM32(reg, ratr, egress_router_interface, 0x08, 0, 16); 6956 6957 enum mlxsw_reg_ratr_trap_action { 6958 MLXSW_REG_RATR_TRAP_ACTION_NOP, 6959 MLXSW_REG_RATR_TRAP_ACTION_TRAP, 6960 MLXSW_REG_RATR_TRAP_ACTION_MIRROR_TO_CPU, 6961 MLXSW_REG_RATR_TRAP_ACTION_MIRROR, 6962 MLXSW_REG_RATR_TRAP_ACTION_DISCARD_ERRORS, 6963 }; 6964 6965 /* reg_ratr_trap_action 6966 * see mlxsw_reg_ratr_trap_action 6967 * Access: RW 6968 */ 6969 MLXSW_ITEM32(reg, ratr, trap_action, 0x0C, 28, 4); 6970 6971 /* reg_ratr_adjacency_index_high 6972 * Bits 23:16 of the adjacency_index. 6973 * Access: Index 6974 */ 6975 MLXSW_ITEM32(reg, ratr, adjacency_index_high, 0x0C, 16, 8); 6976 6977 enum mlxsw_reg_ratr_trap_id { 6978 MLXSW_REG_RATR_TRAP_ID_RTR_EGRESS0, 6979 MLXSW_REG_RATR_TRAP_ID_RTR_EGRESS1, 6980 }; 6981 6982 /* reg_ratr_trap_id 6983 * Trap ID to be reported to CPU. 6984 * Trap-ID is RTR_EGRESS0 or RTR_EGRESS1. 6985 * For trap_action of NOP, MIRROR and DISCARD_ERROR 6986 * Access: RW 6987 */ 6988 MLXSW_ITEM32(reg, ratr, trap_id, 0x0C, 0, 8); 6989 6990 /* reg_ratr_eth_destination_mac 6991 * MAC address of the destination next-hop. 6992 * Access: RW 6993 */ 6994 MLXSW_ITEM_BUF(reg, ratr, eth_destination_mac, 0x12, 6); 6995 6996 enum mlxsw_reg_ratr_ipip_type { 6997 /* IPv4, address set by mlxsw_reg_ratr_ipip_ipv4_udip. */ 6998 MLXSW_REG_RATR_IPIP_TYPE_IPV4, 6999 /* IPv6, address set by mlxsw_reg_ratr_ipip_ipv6_ptr. */ 7000 MLXSW_REG_RATR_IPIP_TYPE_IPV6, 7001 }; 7002 7003 /* reg_ratr_ipip_type 7004 * Underlay destination ip type. 7005 * Note: the type field must match the protocol of the router interface. 7006 * Access: RW 7007 */ 7008 MLXSW_ITEM32(reg, ratr, ipip_type, 0x10, 16, 4); 7009 7010 /* reg_ratr_ipip_ipv4_udip 7011 * Underlay ipv4 dip. 7012 * Reserved when ipip_type is IPv6. 7013 * Access: RW 7014 */ 7015 MLXSW_ITEM32(reg, ratr, ipip_ipv4_udip, 0x18, 0, 32); 7016 7017 /* reg_ratr_ipip_ipv6_ptr 7018 * Pointer to IPv6 underlay destination ip address. 7019 * For Spectrum: Pointer to KVD linear space. 7020 * Access: RW 7021 */ 7022 MLXSW_ITEM32(reg, ratr, ipip_ipv6_ptr, 0x1C, 0, 24); 7023 7024 enum mlxsw_reg_flow_counter_set_type { 7025 /* No count */ 7026 MLXSW_REG_FLOW_COUNTER_SET_TYPE_NO_COUNT = 0x00, 7027 /* Count packets and bytes */ 7028 MLXSW_REG_FLOW_COUNTER_SET_TYPE_PACKETS_BYTES = 0x03, 7029 /* Count only packets */ 7030 MLXSW_REG_FLOW_COUNTER_SET_TYPE_PACKETS = 0x05, 7031 }; 7032 7033 /* reg_ratr_counter_set_type 7034 * Counter set type for flow counters 7035 * Access: RW 7036 */ 7037 MLXSW_ITEM32(reg, ratr, counter_set_type, 0x28, 24, 8); 7038 7039 /* reg_ratr_counter_index 7040 * Counter index for flow counters 7041 * Access: RW 7042 */ 7043 MLXSW_ITEM32(reg, ratr, counter_index, 0x28, 0, 24); 7044 7045 static inline void 7046 mlxsw_reg_ratr_pack(char *payload, 7047 enum mlxsw_reg_ratr_op op, bool valid, 7048 enum mlxsw_reg_ratr_type type, 7049 u32 adjacency_index, u16 egress_rif) 7050 { 7051 MLXSW_REG_ZERO(ratr, payload); 7052 mlxsw_reg_ratr_op_set(payload, op); 7053 mlxsw_reg_ratr_v_set(payload, valid); 7054 mlxsw_reg_ratr_type_set(payload, type); 7055 mlxsw_reg_ratr_adjacency_index_low_set(payload, adjacency_index); 7056 mlxsw_reg_ratr_adjacency_index_high_set(payload, adjacency_index >> 16); 7057 mlxsw_reg_ratr_egress_router_interface_set(payload, egress_rif); 7058 } 7059 7060 static inline void mlxsw_reg_ratr_eth_entry_pack(char *payload, 7061 const char *dest_mac) 7062 { 7063 mlxsw_reg_ratr_eth_destination_mac_memcpy_to(payload, dest_mac); 7064 } 7065 7066 static inline void mlxsw_reg_ratr_ipip4_entry_pack(char *payload, u32 ipv4_udip) 7067 { 7068 mlxsw_reg_ratr_ipip_type_set(payload, MLXSW_REG_RATR_IPIP_TYPE_IPV4); 7069 mlxsw_reg_ratr_ipip_ipv4_udip_set(payload, ipv4_udip); 7070 } 7071 7072 static inline void mlxsw_reg_ratr_ipip6_entry_pack(char *payload, u32 ipv6_ptr) 7073 { 7074 mlxsw_reg_ratr_ipip_type_set(payload, MLXSW_REG_RATR_IPIP_TYPE_IPV6); 7075 mlxsw_reg_ratr_ipip_ipv6_ptr_set(payload, ipv6_ptr); 7076 } 7077 7078 static inline void mlxsw_reg_ratr_counter_pack(char *payload, u64 counter_index, 7079 bool counter_enable) 7080 { 7081 enum mlxsw_reg_flow_counter_set_type set_type; 7082 7083 if (counter_enable) 7084 set_type = MLXSW_REG_FLOW_COUNTER_SET_TYPE_PACKETS_BYTES; 7085 else 7086 set_type = MLXSW_REG_FLOW_COUNTER_SET_TYPE_NO_COUNT; 7087 7088 mlxsw_reg_ratr_counter_index_set(payload, counter_index); 7089 mlxsw_reg_ratr_counter_set_type_set(payload, set_type); 7090 } 7091 7092 /* RDPM - Router DSCP to Priority Mapping 7093 * -------------------------------------- 7094 * Controls the mapping from DSCP field to switch priority on routed packets 7095 */ 7096 #define MLXSW_REG_RDPM_ID 0x8009 7097 #define MLXSW_REG_RDPM_BASE_LEN 0x00 7098 #define MLXSW_REG_RDPM_DSCP_ENTRY_REC_LEN 0x01 7099 #define MLXSW_REG_RDPM_DSCP_ENTRY_REC_MAX_COUNT 64 7100 #define MLXSW_REG_RDPM_LEN 0x40 7101 #define MLXSW_REG_RDPM_LAST_ENTRY (MLXSW_REG_RDPM_BASE_LEN + \ 7102 MLXSW_REG_RDPM_LEN - \ 7103 MLXSW_REG_RDPM_DSCP_ENTRY_REC_LEN) 7104 7105 MLXSW_REG_DEFINE(rdpm, MLXSW_REG_RDPM_ID, MLXSW_REG_RDPM_LEN); 7106 7107 /* reg_dscp_entry_e 7108 * Enable update of the specific entry 7109 * Access: Index 7110 */ 7111 MLXSW_ITEM8_INDEXED(reg, rdpm, dscp_entry_e, MLXSW_REG_RDPM_LAST_ENTRY, 7, 1, 7112 -MLXSW_REG_RDPM_DSCP_ENTRY_REC_LEN, 0x00, false); 7113 7114 /* reg_dscp_entry_prio 7115 * Switch Priority 7116 * Access: RW 7117 */ 7118 MLXSW_ITEM8_INDEXED(reg, rdpm, dscp_entry_prio, MLXSW_REG_RDPM_LAST_ENTRY, 0, 4, 7119 -MLXSW_REG_RDPM_DSCP_ENTRY_REC_LEN, 0x00, false); 7120 7121 static inline void mlxsw_reg_rdpm_pack(char *payload, unsigned short index, 7122 u8 prio) 7123 { 7124 mlxsw_reg_rdpm_dscp_entry_e_set(payload, index, 1); 7125 mlxsw_reg_rdpm_dscp_entry_prio_set(payload, index, prio); 7126 } 7127 7128 /* RICNT - Router Interface Counter Register 7129 * ----------------------------------------- 7130 * The RICNT register retrieves per port performance counters 7131 */ 7132 #define MLXSW_REG_RICNT_ID 0x800B 7133 #define MLXSW_REG_RICNT_LEN 0x100 7134 7135 MLXSW_REG_DEFINE(ricnt, MLXSW_REG_RICNT_ID, MLXSW_REG_RICNT_LEN); 7136 7137 /* reg_ricnt_counter_index 7138 * Counter index 7139 * Access: RW 7140 */ 7141 MLXSW_ITEM32(reg, ricnt, counter_index, 0x04, 0, 24); 7142 7143 enum mlxsw_reg_ricnt_counter_set_type { 7144 /* No Count. */ 7145 MLXSW_REG_RICNT_COUNTER_SET_TYPE_NO_COUNT = 0x00, 7146 /* Basic. Used for router interfaces, counting the following: 7147 * - Error and Discard counters. 7148 * - Unicast, Multicast and Broadcast counters. Sharing the 7149 * same set of counters for the different type of traffic 7150 * (IPv4, IPv6 and mpls). 7151 */ 7152 MLXSW_REG_RICNT_COUNTER_SET_TYPE_BASIC = 0x09, 7153 }; 7154 7155 /* reg_ricnt_counter_set_type 7156 * Counter Set Type for router interface counter 7157 * Access: RW 7158 */ 7159 MLXSW_ITEM32(reg, ricnt, counter_set_type, 0x04, 24, 8); 7160 7161 enum mlxsw_reg_ricnt_opcode { 7162 /* Nop. Supported only for read access*/ 7163 MLXSW_REG_RICNT_OPCODE_NOP = 0x00, 7164 /* Clear. Setting the clr bit will reset the counter value for 7165 * all counters of the specified Router Interface. 7166 */ 7167 MLXSW_REG_RICNT_OPCODE_CLEAR = 0x08, 7168 }; 7169 7170 /* reg_ricnt_opcode 7171 * Opcode 7172 * Access: RW 7173 */ 7174 MLXSW_ITEM32(reg, ricnt, op, 0x00, 28, 4); 7175 7176 /* reg_ricnt_good_unicast_packets 7177 * good unicast packets. 7178 * Access: RW 7179 */ 7180 MLXSW_ITEM64(reg, ricnt, good_unicast_packets, 0x08, 0, 64); 7181 7182 /* reg_ricnt_good_multicast_packets 7183 * good multicast packets. 7184 * Access: RW 7185 */ 7186 MLXSW_ITEM64(reg, ricnt, good_multicast_packets, 0x10, 0, 64); 7187 7188 /* reg_ricnt_good_broadcast_packets 7189 * good broadcast packets 7190 * Access: RW 7191 */ 7192 MLXSW_ITEM64(reg, ricnt, good_broadcast_packets, 0x18, 0, 64); 7193 7194 /* reg_ricnt_good_unicast_bytes 7195 * A count of L3 data and padding octets not including L2 headers 7196 * for good unicast frames. 7197 * Access: RW 7198 */ 7199 MLXSW_ITEM64(reg, ricnt, good_unicast_bytes, 0x20, 0, 64); 7200 7201 /* reg_ricnt_good_multicast_bytes 7202 * A count of L3 data and padding octets not including L2 headers 7203 * for good multicast frames. 7204 * Access: RW 7205 */ 7206 MLXSW_ITEM64(reg, ricnt, good_multicast_bytes, 0x28, 0, 64); 7207 7208 /* reg_ritr_good_broadcast_bytes 7209 * A count of L3 data and padding octets not including L2 headers 7210 * for good broadcast frames. 7211 * Access: RW 7212 */ 7213 MLXSW_ITEM64(reg, ricnt, good_broadcast_bytes, 0x30, 0, 64); 7214 7215 /* reg_ricnt_error_packets 7216 * A count of errored frames that do not pass the router checks. 7217 * Access: RW 7218 */ 7219 MLXSW_ITEM64(reg, ricnt, error_packets, 0x38, 0, 64); 7220 7221 /* reg_ricnt_discrad_packets 7222 * A count of non-errored frames that do not pass the router checks. 7223 * Access: RW 7224 */ 7225 MLXSW_ITEM64(reg, ricnt, discard_packets, 0x40, 0, 64); 7226 7227 /* reg_ricnt_error_bytes 7228 * A count of L3 data and padding octets not including L2 headers 7229 * for errored frames. 7230 * Access: RW 7231 */ 7232 MLXSW_ITEM64(reg, ricnt, error_bytes, 0x48, 0, 64); 7233 7234 /* reg_ricnt_discard_bytes 7235 * A count of L3 data and padding octets not including L2 headers 7236 * for non-errored frames that do not pass the router checks. 7237 * Access: RW 7238 */ 7239 MLXSW_ITEM64(reg, ricnt, discard_bytes, 0x50, 0, 64); 7240 7241 static inline void mlxsw_reg_ricnt_pack(char *payload, u32 index, 7242 enum mlxsw_reg_ricnt_opcode op) 7243 { 7244 MLXSW_REG_ZERO(ricnt, payload); 7245 mlxsw_reg_ricnt_op_set(payload, op); 7246 mlxsw_reg_ricnt_counter_index_set(payload, index); 7247 mlxsw_reg_ricnt_counter_set_type_set(payload, 7248 MLXSW_REG_RICNT_COUNTER_SET_TYPE_BASIC); 7249 } 7250 7251 /* RRCR - Router Rules Copy Register Layout 7252 * ---------------------------------------- 7253 * This register is used for moving and copying route entry rules. 7254 */ 7255 #define MLXSW_REG_RRCR_ID 0x800F 7256 #define MLXSW_REG_RRCR_LEN 0x24 7257 7258 MLXSW_REG_DEFINE(rrcr, MLXSW_REG_RRCR_ID, MLXSW_REG_RRCR_LEN); 7259 7260 enum mlxsw_reg_rrcr_op { 7261 /* Move rules */ 7262 MLXSW_REG_RRCR_OP_MOVE, 7263 /* Copy rules */ 7264 MLXSW_REG_RRCR_OP_COPY, 7265 }; 7266 7267 /* reg_rrcr_op 7268 * Access: WO 7269 */ 7270 MLXSW_ITEM32(reg, rrcr, op, 0x00, 28, 4); 7271 7272 /* reg_rrcr_offset 7273 * Offset within the region from which to copy/move. 7274 * Access: Index 7275 */ 7276 MLXSW_ITEM32(reg, rrcr, offset, 0x00, 0, 16); 7277 7278 /* reg_rrcr_size 7279 * The number of rules to copy/move. 7280 * Access: WO 7281 */ 7282 MLXSW_ITEM32(reg, rrcr, size, 0x04, 0, 16); 7283 7284 /* reg_rrcr_table_id 7285 * Identifier of the table on which to perform the operation. Encoding is the 7286 * same as in RTAR.key_type 7287 * Access: Index 7288 */ 7289 MLXSW_ITEM32(reg, rrcr, table_id, 0x10, 0, 4); 7290 7291 /* reg_rrcr_dest_offset 7292 * Offset within the region to which to copy/move 7293 * Access: Index 7294 */ 7295 MLXSW_ITEM32(reg, rrcr, dest_offset, 0x20, 0, 16); 7296 7297 static inline void mlxsw_reg_rrcr_pack(char *payload, enum mlxsw_reg_rrcr_op op, 7298 u16 offset, u16 size, 7299 enum mlxsw_reg_rtar_key_type table_id, 7300 u16 dest_offset) 7301 { 7302 MLXSW_REG_ZERO(rrcr, payload); 7303 mlxsw_reg_rrcr_op_set(payload, op); 7304 mlxsw_reg_rrcr_offset_set(payload, offset); 7305 mlxsw_reg_rrcr_size_set(payload, size); 7306 mlxsw_reg_rrcr_table_id_set(payload, table_id); 7307 mlxsw_reg_rrcr_dest_offset_set(payload, dest_offset); 7308 } 7309 7310 /* RALTA - Router Algorithmic LPM Tree Allocation Register 7311 * ------------------------------------------------------- 7312 * RALTA is used to allocate the LPM trees of the SHSPM method. 7313 */ 7314 #define MLXSW_REG_RALTA_ID 0x8010 7315 #define MLXSW_REG_RALTA_LEN 0x04 7316 7317 MLXSW_REG_DEFINE(ralta, MLXSW_REG_RALTA_ID, MLXSW_REG_RALTA_LEN); 7318 7319 /* reg_ralta_op 7320 * opcode (valid for Write, must be 0 on Read) 7321 * 0 - allocate a tree 7322 * 1 - deallocate a tree 7323 * Access: OP 7324 */ 7325 MLXSW_ITEM32(reg, ralta, op, 0x00, 28, 2); 7326 7327 enum mlxsw_reg_ralxx_protocol { 7328 MLXSW_REG_RALXX_PROTOCOL_IPV4, 7329 MLXSW_REG_RALXX_PROTOCOL_IPV6, 7330 }; 7331 7332 /* reg_ralta_protocol 7333 * Protocol. 7334 * Deallocation opcode: Reserved. 7335 * Access: RW 7336 */ 7337 MLXSW_ITEM32(reg, ralta, protocol, 0x00, 24, 4); 7338 7339 /* reg_ralta_tree_id 7340 * An identifier (numbered from 1..cap_shspm_max_trees-1) representing 7341 * the tree identifier (managed by software). 7342 * Note that tree_id 0 is allocated for a default-route tree. 7343 * Access: Index 7344 */ 7345 MLXSW_ITEM32(reg, ralta, tree_id, 0x00, 0, 8); 7346 7347 static inline void mlxsw_reg_ralta_pack(char *payload, bool alloc, 7348 enum mlxsw_reg_ralxx_protocol protocol, 7349 u8 tree_id) 7350 { 7351 MLXSW_REG_ZERO(ralta, payload); 7352 mlxsw_reg_ralta_op_set(payload, !alloc); 7353 mlxsw_reg_ralta_protocol_set(payload, protocol); 7354 mlxsw_reg_ralta_tree_id_set(payload, tree_id); 7355 } 7356 7357 /* RALST - Router Algorithmic LPM Structure Tree Register 7358 * ------------------------------------------------------ 7359 * RALST is used to set and query the structure of an LPM tree. 7360 * The structure of the tree must be sorted as a sorted binary tree, while 7361 * each node is a bin that is tagged as the length of the prefixes the lookup 7362 * will refer to. Therefore, bin X refers to a set of entries with prefixes 7363 * of X bits to match with the destination address. The bin 0 indicates 7364 * the default action, when there is no match of any prefix. 7365 */ 7366 #define MLXSW_REG_RALST_ID 0x8011 7367 #define MLXSW_REG_RALST_LEN 0x104 7368 7369 MLXSW_REG_DEFINE(ralst, MLXSW_REG_RALST_ID, MLXSW_REG_RALST_LEN); 7370 7371 /* reg_ralst_root_bin 7372 * The bin number of the root bin. 7373 * 0<root_bin=<(length of IP address) 7374 * For a default-route tree configure 0xff 7375 * Access: RW 7376 */ 7377 MLXSW_ITEM32(reg, ralst, root_bin, 0x00, 16, 8); 7378 7379 /* reg_ralst_tree_id 7380 * Tree identifier numbered from 1..(cap_shspm_max_trees-1). 7381 * Access: Index 7382 */ 7383 MLXSW_ITEM32(reg, ralst, tree_id, 0x00, 0, 8); 7384 7385 #define MLXSW_REG_RALST_BIN_NO_CHILD 0xff 7386 #define MLXSW_REG_RALST_BIN_OFFSET 0x04 7387 #define MLXSW_REG_RALST_BIN_COUNT 128 7388 7389 /* reg_ralst_left_child_bin 7390 * Holding the children of the bin according to the stored tree's structure. 7391 * For trees composed of less than 4 blocks, the bins in excess are reserved. 7392 * Note that tree_id 0 is allocated for a default-route tree, bins are 0xff 7393 * Access: RW 7394 */ 7395 MLXSW_ITEM16_INDEXED(reg, ralst, left_child_bin, 0x04, 8, 8, 0x02, 0x00, false); 7396 7397 /* reg_ralst_right_child_bin 7398 * Holding the children of the bin according to the stored tree's structure. 7399 * For trees composed of less than 4 blocks, the bins in excess are reserved. 7400 * Note that tree_id 0 is allocated for a default-route tree, bins are 0xff 7401 * Access: RW 7402 */ 7403 MLXSW_ITEM16_INDEXED(reg, ralst, right_child_bin, 0x04, 0, 8, 0x02, 0x00, 7404 false); 7405 7406 static inline void mlxsw_reg_ralst_pack(char *payload, u8 root_bin, u8 tree_id) 7407 { 7408 MLXSW_REG_ZERO(ralst, payload); 7409 7410 /* Initialize all bins to have no left or right child */ 7411 memset(payload + MLXSW_REG_RALST_BIN_OFFSET, 7412 MLXSW_REG_RALST_BIN_NO_CHILD, MLXSW_REG_RALST_BIN_COUNT * 2); 7413 7414 mlxsw_reg_ralst_root_bin_set(payload, root_bin); 7415 mlxsw_reg_ralst_tree_id_set(payload, tree_id); 7416 } 7417 7418 static inline void mlxsw_reg_ralst_bin_pack(char *payload, u8 bin_number, 7419 u8 left_child_bin, 7420 u8 right_child_bin) 7421 { 7422 int bin_index = bin_number - 1; 7423 7424 mlxsw_reg_ralst_left_child_bin_set(payload, bin_index, left_child_bin); 7425 mlxsw_reg_ralst_right_child_bin_set(payload, bin_index, 7426 right_child_bin); 7427 } 7428 7429 /* RALTB - Router Algorithmic LPM Tree Binding Register 7430 * ---------------------------------------------------- 7431 * RALTB is used to bind virtual router and protocol to an allocated LPM tree. 7432 */ 7433 #define MLXSW_REG_RALTB_ID 0x8012 7434 #define MLXSW_REG_RALTB_LEN 0x04 7435 7436 MLXSW_REG_DEFINE(raltb, MLXSW_REG_RALTB_ID, MLXSW_REG_RALTB_LEN); 7437 7438 /* reg_raltb_virtual_router 7439 * Virtual Router ID 7440 * Range is 0..cap_max_virtual_routers-1 7441 * Access: Index 7442 */ 7443 MLXSW_ITEM32(reg, raltb, virtual_router, 0x00, 16, 16); 7444 7445 /* reg_raltb_protocol 7446 * Protocol. 7447 * Access: Index 7448 */ 7449 MLXSW_ITEM32(reg, raltb, protocol, 0x00, 12, 4); 7450 7451 /* reg_raltb_tree_id 7452 * Tree to be used for the {virtual_router, protocol} 7453 * Tree identifier numbered from 1..(cap_shspm_max_trees-1). 7454 * By default, all Unicast IPv4 and IPv6 are bound to tree_id 0. 7455 * Access: RW 7456 */ 7457 MLXSW_ITEM32(reg, raltb, tree_id, 0x00, 0, 8); 7458 7459 static inline void mlxsw_reg_raltb_pack(char *payload, u16 virtual_router, 7460 enum mlxsw_reg_ralxx_protocol protocol, 7461 u8 tree_id) 7462 { 7463 MLXSW_REG_ZERO(raltb, payload); 7464 mlxsw_reg_raltb_virtual_router_set(payload, virtual_router); 7465 mlxsw_reg_raltb_protocol_set(payload, protocol); 7466 mlxsw_reg_raltb_tree_id_set(payload, tree_id); 7467 } 7468 7469 /* RALUE - Router Algorithmic LPM Unicast Entry Register 7470 * ----------------------------------------------------- 7471 * RALUE is used to configure and query LPM entries that serve 7472 * the Unicast protocols. 7473 */ 7474 #define MLXSW_REG_RALUE_ID 0x8013 7475 #define MLXSW_REG_RALUE_LEN 0x38 7476 7477 MLXSW_REG_DEFINE(ralue, MLXSW_REG_RALUE_ID, MLXSW_REG_RALUE_LEN); 7478 7479 /* reg_ralue_protocol 7480 * Protocol. 7481 * Access: Index 7482 */ 7483 MLXSW_ITEM32(reg, ralue, protocol, 0x00, 24, 4); 7484 7485 enum mlxsw_reg_ralue_op { 7486 /* Read operation. If entry doesn't exist, the operation fails. */ 7487 MLXSW_REG_RALUE_OP_QUERY_READ = 0, 7488 /* Clear on read operation. Used to read entry and 7489 * clear Activity bit. 7490 */ 7491 MLXSW_REG_RALUE_OP_QUERY_CLEAR = 1, 7492 /* Write operation. Used to write a new entry to the table. All RW 7493 * fields are written for new entry. Activity bit is set 7494 * for new entries. 7495 */ 7496 MLXSW_REG_RALUE_OP_WRITE_WRITE = 0, 7497 /* Update operation. Used to update an existing route entry and 7498 * only update the RW fields that are detailed in the field 7499 * op_u_mask. If entry doesn't exist, the operation fails. 7500 */ 7501 MLXSW_REG_RALUE_OP_WRITE_UPDATE = 1, 7502 /* Clear activity. The Activity bit (the field a) is cleared 7503 * for the entry. 7504 */ 7505 MLXSW_REG_RALUE_OP_WRITE_CLEAR = 2, 7506 /* Delete operation. Used to delete an existing entry. If entry 7507 * doesn't exist, the operation fails. 7508 */ 7509 MLXSW_REG_RALUE_OP_WRITE_DELETE = 3, 7510 }; 7511 7512 /* reg_ralue_op 7513 * Operation. 7514 * Access: OP 7515 */ 7516 MLXSW_ITEM32(reg, ralue, op, 0x00, 20, 3); 7517 7518 /* reg_ralue_a 7519 * Activity. Set for new entries. Set if a packet lookup has hit on the 7520 * specific entry, only if the entry is a route. To clear the a bit, use 7521 * "clear activity" op. 7522 * Enabled by activity_dis in RGCR 7523 * Access: RO 7524 */ 7525 MLXSW_ITEM32(reg, ralue, a, 0x00, 16, 1); 7526 7527 /* reg_ralue_virtual_router 7528 * Virtual Router ID 7529 * Range is 0..cap_max_virtual_routers-1 7530 * Access: Index 7531 */ 7532 MLXSW_ITEM32(reg, ralue, virtual_router, 0x04, 16, 16); 7533 7534 #define MLXSW_REG_RALUE_OP_U_MASK_ENTRY_TYPE BIT(0) 7535 #define MLXSW_REG_RALUE_OP_U_MASK_BMP_LEN BIT(1) 7536 #define MLXSW_REG_RALUE_OP_U_MASK_ACTION BIT(2) 7537 7538 /* reg_ralue_op_u_mask 7539 * opcode update mask. 7540 * On read operation, this field is reserved. 7541 * This field is valid for update opcode, otherwise - reserved. 7542 * This field is a bitmask of the fields that should be updated. 7543 * Access: WO 7544 */ 7545 MLXSW_ITEM32(reg, ralue, op_u_mask, 0x04, 8, 3); 7546 7547 /* reg_ralue_prefix_len 7548 * Number of bits in the prefix of the LPM route. 7549 * Note that for IPv6 prefixes, if prefix_len>64 the entry consumes 7550 * two entries in the physical HW table. 7551 * Access: Index 7552 */ 7553 MLXSW_ITEM32(reg, ralue, prefix_len, 0x08, 0, 8); 7554 7555 /* reg_ralue_dip* 7556 * The prefix of the route or of the marker that the object of the LPM 7557 * is compared with. The most significant bits of the dip are the prefix. 7558 * The least significant bits must be '0' if the prefix_len is smaller 7559 * than 128 for IPv6 or smaller than 32 for IPv4. 7560 * IPv4 address uses bits dip[31:0] and bits dip[127:32] are reserved. 7561 * Access: Index 7562 */ 7563 MLXSW_ITEM32(reg, ralue, dip4, 0x18, 0, 32); 7564 MLXSW_ITEM_BUF(reg, ralue, dip6, 0x0C, 16); 7565 7566 enum mlxsw_reg_ralue_entry_type { 7567 MLXSW_REG_RALUE_ENTRY_TYPE_MARKER_ENTRY = 1, 7568 MLXSW_REG_RALUE_ENTRY_TYPE_ROUTE_ENTRY = 2, 7569 MLXSW_REG_RALUE_ENTRY_TYPE_MARKER_AND_ROUTE_ENTRY = 3, 7570 }; 7571 7572 /* reg_ralue_entry_type 7573 * Entry type. 7574 * Note - for Marker entries, the action_type and action fields are reserved. 7575 * Access: RW 7576 */ 7577 MLXSW_ITEM32(reg, ralue, entry_type, 0x1C, 30, 2); 7578 7579 /* reg_ralue_bmp_len 7580 * The best match prefix length in the case that there is no match for 7581 * longer prefixes. 7582 * If (entry_type != MARKER_ENTRY), bmp_len must be equal to prefix_len 7583 * Note for any update operation with entry_type modification this 7584 * field must be set. 7585 * Access: RW 7586 */ 7587 MLXSW_ITEM32(reg, ralue, bmp_len, 0x1C, 16, 8); 7588 7589 enum mlxsw_reg_ralue_action_type { 7590 MLXSW_REG_RALUE_ACTION_TYPE_REMOTE, 7591 MLXSW_REG_RALUE_ACTION_TYPE_LOCAL, 7592 MLXSW_REG_RALUE_ACTION_TYPE_IP2ME, 7593 }; 7594 7595 /* reg_ralue_action_type 7596 * Action Type 7597 * Indicates how the IP address is connected. 7598 * It can be connected to a local subnet through local_erif or can be 7599 * on a remote subnet connected through a next-hop router, 7600 * or transmitted to the CPU. 7601 * Reserved when entry_type = MARKER_ENTRY 7602 * Access: RW 7603 */ 7604 MLXSW_ITEM32(reg, ralue, action_type, 0x1C, 0, 2); 7605 7606 enum mlxsw_reg_ralue_trap_action { 7607 MLXSW_REG_RALUE_TRAP_ACTION_NOP, 7608 MLXSW_REG_RALUE_TRAP_ACTION_TRAP, 7609 MLXSW_REG_RALUE_TRAP_ACTION_MIRROR_TO_CPU, 7610 MLXSW_REG_RALUE_TRAP_ACTION_MIRROR, 7611 MLXSW_REG_RALUE_TRAP_ACTION_DISCARD_ERROR, 7612 }; 7613 7614 /* reg_ralue_trap_action 7615 * Trap action. 7616 * For IP2ME action, only NOP and MIRROR are possible. 7617 * Access: RW 7618 */ 7619 MLXSW_ITEM32(reg, ralue, trap_action, 0x20, 28, 4); 7620 7621 /* reg_ralue_trap_id 7622 * Trap ID to be reported to CPU. 7623 * Trap ID is RTR_INGRESS0 or RTR_INGRESS1. 7624 * For trap_action of NOP, MIRROR and DISCARD_ERROR, trap_id is reserved. 7625 * Access: RW 7626 */ 7627 MLXSW_ITEM32(reg, ralue, trap_id, 0x20, 0, 9); 7628 7629 /* reg_ralue_adjacency_index 7630 * Points to the first entry of the group-based ECMP. 7631 * Only relevant in case of REMOTE action. 7632 * Access: RW 7633 */ 7634 MLXSW_ITEM32(reg, ralue, adjacency_index, 0x24, 0, 24); 7635 7636 /* reg_ralue_ecmp_size 7637 * Amount of sequential entries starting 7638 * from the adjacency_index (the number of ECMPs). 7639 * The valid range is 1-64, 512, 1024, 2048 and 4096. 7640 * Reserved when trap_action is TRAP or DISCARD_ERROR. 7641 * Only relevant in case of REMOTE action. 7642 * Access: RW 7643 */ 7644 MLXSW_ITEM32(reg, ralue, ecmp_size, 0x28, 0, 13); 7645 7646 /* reg_ralue_local_erif 7647 * Egress Router Interface. 7648 * Only relevant in case of LOCAL action. 7649 * Access: RW 7650 */ 7651 MLXSW_ITEM32(reg, ralue, local_erif, 0x24, 0, 16); 7652 7653 /* reg_ralue_ip2me_v 7654 * Valid bit for the tunnel_ptr field. 7655 * If valid = 0 then trap to CPU as IP2ME trap ID. 7656 * If valid = 1 and the packet format allows NVE or IPinIP tunnel 7657 * decapsulation then tunnel decapsulation is done. 7658 * If valid = 1 and packet format does not allow NVE or IPinIP tunnel 7659 * decapsulation then trap as IP2ME trap ID. 7660 * Only relevant in case of IP2ME action. 7661 * Access: RW 7662 */ 7663 MLXSW_ITEM32(reg, ralue, ip2me_v, 0x24, 31, 1); 7664 7665 /* reg_ralue_ip2me_tunnel_ptr 7666 * Tunnel Pointer for NVE or IPinIP tunnel decapsulation. 7667 * For Spectrum, pointer to KVD Linear. 7668 * Only relevant in case of IP2ME action. 7669 * Access: RW 7670 */ 7671 MLXSW_ITEM32(reg, ralue, ip2me_tunnel_ptr, 0x24, 0, 24); 7672 7673 static inline void mlxsw_reg_ralue_pack(char *payload, 7674 enum mlxsw_reg_ralxx_protocol protocol, 7675 enum mlxsw_reg_ralue_op op, 7676 u16 virtual_router, u8 prefix_len) 7677 { 7678 MLXSW_REG_ZERO(ralue, payload); 7679 mlxsw_reg_ralue_protocol_set(payload, protocol); 7680 mlxsw_reg_ralue_op_set(payload, op); 7681 mlxsw_reg_ralue_virtual_router_set(payload, virtual_router); 7682 mlxsw_reg_ralue_prefix_len_set(payload, prefix_len); 7683 mlxsw_reg_ralue_entry_type_set(payload, 7684 MLXSW_REG_RALUE_ENTRY_TYPE_ROUTE_ENTRY); 7685 mlxsw_reg_ralue_bmp_len_set(payload, prefix_len); 7686 } 7687 7688 static inline void mlxsw_reg_ralue_pack4(char *payload, 7689 enum mlxsw_reg_ralxx_protocol protocol, 7690 enum mlxsw_reg_ralue_op op, 7691 u16 virtual_router, u8 prefix_len, 7692 u32 *dip) 7693 { 7694 mlxsw_reg_ralue_pack(payload, protocol, op, virtual_router, prefix_len); 7695 if (dip) 7696 mlxsw_reg_ralue_dip4_set(payload, *dip); 7697 } 7698 7699 static inline void mlxsw_reg_ralue_pack6(char *payload, 7700 enum mlxsw_reg_ralxx_protocol protocol, 7701 enum mlxsw_reg_ralue_op op, 7702 u16 virtual_router, u8 prefix_len, 7703 const void *dip) 7704 { 7705 mlxsw_reg_ralue_pack(payload, protocol, op, virtual_router, prefix_len); 7706 if (dip) 7707 mlxsw_reg_ralue_dip6_memcpy_to(payload, dip); 7708 } 7709 7710 static inline void 7711 mlxsw_reg_ralue_act_remote_pack(char *payload, 7712 enum mlxsw_reg_ralue_trap_action trap_action, 7713 u16 trap_id, u32 adjacency_index, u16 ecmp_size) 7714 { 7715 mlxsw_reg_ralue_action_type_set(payload, 7716 MLXSW_REG_RALUE_ACTION_TYPE_REMOTE); 7717 mlxsw_reg_ralue_trap_action_set(payload, trap_action); 7718 mlxsw_reg_ralue_trap_id_set(payload, trap_id); 7719 mlxsw_reg_ralue_adjacency_index_set(payload, adjacency_index); 7720 mlxsw_reg_ralue_ecmp_size_set(payload, ecmp_size); 7721 } 7722 7723 static inline void 7724 mlxsw_reg_ralue_act_local_pack(char *payload, 7725 enum mlxsw_reg_ralue_trap_action trap_action, 7726 u16 trap_id, u16 local_erif) 7727 { 7728 mlxsw_reg_ralue_action_type_set(payload, 7729 MLXSW_REG_RALUE_ACTION_TYPE_LOCAL); 7730 mlxsw_reg_ralue_trap_action_set(payload, trap_action); 7731 mlxsw_reg_ralue_trap_id_set(payload, trap_id); 7732 mlxsw_reg_ralue_local_erif_set(payload, local_erif); 7733 } 7734 7735 static inline void 7736 mlxsw_reg_ralue_act_ip2me_pack(char *payload) 7737 { 7738 mlxsw_reg_ralue_action_type_set(payload, 7739 MLXSW_REG_RALUE_ACTION_TYPE_IP2ME); 7740 } 7741 7742 static inline void 7743 mlxsw_reg_ralue_act_ip2me_tun_pack(char *payload, u32 tunnel_ptr) 7744 { 7745 mlxsw_reg_ralue_action_type_set(payload, 7746 MLXSW_REG_RALUE_ACTION_TYPE_IP2ME); 7747 mlxsw_reg_ralue_ip2me_v_set(payload, 1); 7748 mlxsw_reg_ralue_ip2me_tunnel_ptr_set(payload, tunnel_ptr); 7749 } 7750 7751 /* RAUHT - Router Algorithmic LPM Unicast Host Table Register 7752 * ---------------------------------------------------------- 7753 * The RAUHT register is used to configure and query the Unicast Host table in 7754 * devices that implement the Algorithmic LPM. 7755 */ 7756 #define MLXSW_REG_RAUHT_ID 0x8014 7757 #define MLXSW_REG_RAUHT_LEN 0x74 7758 7759 MLXSW_REG_DEFINE(rauht, MLXSW_REG_RAUHT_ID, MLXSW_REG_RAUHT_LEN); 7760 7761 enum mlxsw_reg_rauht_type { 7762 MLXSW_REG_RAUHT_TYPE_IPV4, 7763 MLXSW_REG_RAUHT_TYPE_IPV6, 7764 }; 7765 7766 /* reg_rauht_type 7767 * Access: Index 7768 */ 7769 MLXSW_ITEM32(reg, rauht, type, 0x00, 24, 2); 7770 7771 enum mlxsw_reg_rauht_op { 7772 MLXSW_REG_RAUHT_OP_QUERY_READ = 0, 7773 /* Read operation */ 7774 MLXSW_REG_RAUHT_OP_QUERY_CLEAR_ON_READ = 1, 7775 /* Clear on read operation. Used to read entry and clear 7776 * activity bit. 7777 */ 7778 MLXSW_REG_RAUHT_OP_WRITE_ADD = 0, 7779 /* Add. Used to write a new entry to the table. All R/W fields are 7780 * relevant for new entry. Activity bit is set for new entries. 7781 */ 7782 MLXSW_REG_RAUHT_OP_WRITE_UPDATE = 1, 7783 /* Update action. Used to update an existing route entry and 7784 * only update the following fields: 7785 * trap_action, trap_id, mac, counter_set_type, counter_index 7786 */ 7787 MLXSW_REG_RAUHT_OP_WRITE_CLEAR_ACTIVITY = 2, 7788 /* Clear activity. A bit is cleared for the entry. */ 7789 MLXSW_REG_RAUHT_OP_WRITE_DELETE = 3, 7790 /* Delete entry */ 7791 MLXSW_REG_RAUHT_OP_WRITE_DELETE_ALL = 4, 7792 /* Delete all host entries on a RIF. In this command, dip 7793 * field is reserved. 7794 */ 7795 }; 7796 7797 /* reg_rauht_op 7798 * Access: OP 7799 */ 7800 MLXSW_ITEM32(reg, rauht, op, 0x00, 20, 3); 7801 7802 /* reg_rauht_a 7803 * Activity. Set for new entries. Set if a packet lookup has hit on 7804 * the specific entry. 7805 * To clear the a bit, use "clear activity" op. 7806 * Enabled by activity_dis in RGCR 7807 * Access: RO 7808 */ 7809 MLXSW_ITEM32(reg, rauht, a, 0x00, 16, 1); 7810 7811 /* reg_rauht_rif 7812 * Router Interface 7813 * Access: Index 7814 */ 7815 MLXSW_ITEM32(reg, rauht, rif, 0x00, 0, 16); 7816 7817 /* reg_rauht_dip* 7818 * Destination address. 7819 * Access: Index 7820 */ 7821 MLXSW_ITEM32(reg, rauht, dip4, 0x1C, 0x0, 32); 7822 MLXSW_ITEM_BUF(reg, rauht, dip6, 0x10, 16); 7823 7824 enum mlxsw_reg_rauht_trap_action { 7825 MLXSW_REG_RAUHT_TRAP_ACTION_NOP, 7826 MLXSW_REG_RAUHT_TRAP_ACTION_TRAP, 7827 MLXSW_REG_RAUHT_TRAP_ACTION_MIRROR_TO_CPU, 7828 MLXSW_REG_RAUHT_TRAP_ACTION_MIRROR, 7829 MLXSW_REG_RAUHT_TRAP_ACTION_DISCARD_ERRORS, 7830 }; 7831 7832 /* reg_rauht_trap_action 7833 * Access: RW 7834 */ 7835 MLXSW_ITEM32(reg, rauht, trap_action, 0x60, 28, 4); 7836 7837 enum mlxsw_reg_rauht_trap_id { 7838 MLXSW_REG_RAUHT_TRAP_ID_RTR_EGRESS0, 7839 MLXSW_REG_RAUHT_TRAP_ID_RTR_EGRESS1, 7840 }; 7841 7842 /* reg_rauht_trap_id 7843 * Trap ID to be reported to CPU. 7844 * Trap-ID is RTR_EGRESS0 or RTR_EGRESS1. 7845 * For trap_action of NOP, MIRROR and DISCARD_ERROR, 7846 * trap_id is reserved. 7847 * Access: RW 7848 */ 7849 MLXSW_ITEM32(reg, rauht, trap_id, 0x60, 0, 9); 7850 7851 /* reg_rauht_counter_set_type 7852 * Counter set type for flow counters 7853 * Access: RW 7854 */ 7855 MLXSW_ITEM32(reg, rauht, counter_set_type, 0x68, 24, 8); 7856 7857 /* reg_rauht_counter_index 7858 * Counter index for flow counters 7859 * Access: RW 7860 */ 7861 MLXSW_ITEM32(reg, rauht, counter_index, 0x68, 0, 24); 7862 7863 /* reg_rauht_mac 7864 * MAC address. 7865 * Access: RW 7866 */ 7867 MLXSW_ITEM_BUF(reg, rauht, mac, 0x6E, 6); 7868 7869 static inline void mlxsw_reg_rauht_pack(char *payload, 7870 enum mlxsw_reg_rauht_op op, u16 rif, 7871 const char *mac) 7872 { 7873 MLXSW_REG_ZERO(rauht, payload); 7874 mlxsw_reg_rauht_op_set(payload, op); 7875 mlxsw_reg_rauht_rif_set(payload, rif); 7876 mlxsw_reg_rauht_mac_memcpy_to(payload, mac); 7877 } 7878 7879 static inline void mlxsw_reg_rauht_pack4(char *payload, 7880 enum mlxsw_reg_rauht_op op, u16 rif, 7881 const char *mac, u32 dip) 7882 { 7883 mlxsw_reg_rauht_pack(payload, op, rif, mac); 7884 mlxsw_reg_rauht_dip4_set(payload, dip); 7885 } 7886 7887 static inline void mlxsw_reg_rauht_pack6(char *payload, 7888 enum mlxsw_reg_rauht_op op, u16 rif, 7889 const char *mac, const char *dip) 7890 { 7891 mlxsw_reg_rauht_pack(payload, op, rif, mac); 7892 mlxsw_reg_rauht_type_set(payload, MLXSW_REG_RAUHT_TYPE_IPV6); 7893 mlxsw_reg_rauht_dip6_memcpy_to(payload, dip); 7894 } 7895 7896 static inline void mlxsw_reg_rauht_pack_counter(char *payload, 7897 u64 counter_index) 7898 { 7899 mlxsw_reg_rauht_counter_index_set(payload, counter_index); 7900 mlxsw_reg_rauht_counter_set_type_set(payload, 7901 MLXSW_REG_FLOW_COUNTER_SET_TYPE_PACKETS_BYTES); 7902 } 7903 7904 /* RALEU - Router Algorithmic LPM ECMP Update Register 7905 * --------------------------------------------------- 7906 * The register enables updating the ECMP section in the action for multiple 7907 * LPM Unicast entries in a single operation. The update is executed to 7908 * all entries of a {virtual router, protocol} tuple using the same ECMP group. 7909 */ 7910 #define MLXSW_REG_RALEU_ID 0x8015 7911 #define MLXSW_REG_RALEU_LEN 0x28 7912 7913 MLXSW_REG_DEFINE(raleu, MLXSW_REG_RALEU_ID, MLXSW_REG_RALEU_LEN); 7914 7915 /* reg_raleu_protocol 7916 * Protocol. 7917 * Access: Index 7918 */ 7919 MLXSW_ITEM32(reg, raleu, protocol, 0x00, 24, 4); 7920 7921 /* reg_raleu_virtual_router 7922 * Virtual Router ID 7923 * Range is 0..cap_max_virtual_routers-1 7924 * Access: Index 7925 */ 7926 MLXSW_ITEM32(reg, raleu, virtual_router, 0x00, 0, 16); 7927 7928 /* reg_raleu_adjacency_index 7929 * Adjacency Index used for matching on the existing entries. 7930 * Access: Index 7931 */ 7932 MLXSW_ITEM32(reg, raleu, adjacency_index, 0x10, 0, 24); 7933 7934 /* reg_raleu_ecmp_size 7935 * ECMP Size used for matching on the existing entries. 7936 * Access: Index 7937 */ 7938 MLXSW_ITEM32(reg, raleu, ecmp_size, 0x14, 0, 13); 7939 7940 /* reg_raleu_new_adjacency_index 7941 * New Adjacency Index. 7942 * Access: WO 7943 */ 7944 MLXSW_ITEM32(reg, raleu, new_adjacency_index, 0x20, 0, 24); 7945 7946 /* reg_raleu_new_ecmp_size 7947 * New ECMP Size. 7948 * Access: WO 7949 */ 7950 MLXSW_ITEM32(reg, raleu, new_ecmp_size, 0x24, 0, 13); 7951 7952 static inline void mlxsw_reg_raleu_pack(char *payload, 7953 enum mlxsw_reg_ralxx_protocol protocol, 7954 u16 virtual_router, 7955 u32 adjacency_index, u16 ecmp_size, 7956 u32 new_adjacency_index, 7957 u16 new_ecmp_size) 7958 { 7959 MLXSW_REG_ZERO(raleu, payload); 7960 mlxsw_reg_raleu_protocol_set(payload, protocol); 7961 mlxsw_reg_raleu_virtual_router_set(payload, virtual_router); 7962 mlxsw_reg_raleu_adjacency_index_set(payload, adjacency_index); 7963 mlxsw_reg_raleu_ecmp_size_set(payload, ecmp_size); 7964 mlxsw_reg_raleu_new_adjacency_index_set(payload, new_adjacency_index); 7965 mlxsw_reg_raleu_new_ecmp_size_set(payload, new_ecmp_size); 7966 } 7967 7968 /* RAUHTD - Router Algorithmic LPM Unicast Host Table Dump Register 7969 * ---------------------------------------------------------------- 7970 * The RAUHTD register allows dumping entries from the Router Unicast Host 7971 * Table. For a given session an entry is dumped no more than one time. The 7972 * first RAUHTD access after reset is a new session. A session ends when the 7973 * num_rec response is smaller than num_rec request or for IPv4 when the 7974 * num_entries is smaller than 4. The clear activity affect the current session 7975 * or the last session if a new session has not started. 7976 */ 7977 #define MLXSW_REG_RAUHTD_ID 0x8018 7978 #define MLXSW_REG_RAUHTD_BASE_LEN 0x20 7979 #define MLXSW_REG_RAUHTD_REC_LEN 0x20 7980 #define MLXSW_REG_RAUHTD_REC_MAX_NUM 32 7981 #define MLXSW_REG_RAUHTD_LEN (MLXSW_REG_RAUHTD_BASE_LEN + \ 7982 MLXSW_REG_RAUHTD_REC_MAX_NUM * MLXSW_REG_RAUHTD_REC_LEN) 7983 #define MLXSW_REG_RAUHTD_IPV4_ENT_PER_REC 4 7984 7985 MLXSW_REG_DEFINE(rauhtd, MLXSW_REG_RAUHTD_ID, MLXSW_REG_RAUHTD_LEN); 7986 7987 #define MLXSW_REG_RAUHTD_FILTER_A BIT(0) 7988 #define MLXSW_REG_RAUHTD_FILTER_RIF BIT(3) 7989 7990 /* reg_rauhtd_filter_fields 7991 * if a bit is '0' then the relevant field is ignored and dump is done 7992 * regardless of the field value 7993 * Bit0 - filter by activity: entry_a 7994 * Bit3 - filter by entry rip: entry_rif 7995 * Access: Index 7996 */ 7997 MLXSW_ITEM32(reg, rauhtd, filter_fields, 0x00, 0, 8); 7998 7999 enum mlxsw_reg_rauhtd_op { 8000 MLXSW_REG_RAUHTD_OP_DUMP, 8001 MLXSW_REG_RAUHTD_OP_DUMP_AND_CLEAR, 8002 }; 8003 8004 /* reg_rauhtd_op 8005 * Access: OP 8006 */ 8007 MLXSW_ITEM32(reg, rauhtd, op, 0x04, 24, 2); 8008 8009 /* reg_rauhtd_num_rec 8010 * At request: number of records requested 8011 * At response: number of records dumped 8012 * For IPv4, each record has 4 entries at request and up to 4 entries 8013 * at response 8014 * Range is 0..MLXSW_REG_RAUHTD_REC_MAX_NUM 8015 * Access: Index 8016 */ 8017 MLXSW_ITEM32(reg, rauhtd, num_rec, 0x04, 0, 8); 8018 8019 /* reg_rauhtd_entry_a 8020 * Dump only if activity has value of entry_a 8021 * Reserved if filter_fields bit0 is '0' 8022 * Access: Index 8023 */ 8024 MLXSW_ITEM32(reg, rauhtd, entry_a, 0x08, 16, 1); 8025 8026 enum mlxsw_reg_rauhtd_type { 8027 MLXSW_REG_RAUHTD_TYPE_IPV4, 8028 MLXSW_REG_RAUHTD_TYPE_IPV6, 8029 }; 8030 8031 /* reg_rauhtd_type 8032 * Dump only if record type is: 8033 * 0 - IPv4 8034 * 1 - IPv6 8035 * Access: Index 8036 */ 8037 MLXSW_ITEM32(reg, rauhtd, type, 0x08, 0, 4); 8038 8039 /* reg_rauhtd_entry_rif 8040 * Dump only if RIF has value of entry_rif 8041 * Reserved if filter_fields bit3 is '0' 8042 * Access: Index 8043 */ 8044 MLXSW_ITEM32(reg, rauhtd, entry_rif, 0x0C, 0, 16); 8045 8046 static inline void mlxsw_reg_rauhtd_pack(char *payload, 8047 enum mlxsw_reg_rauhtd_type type) 8048 { 8049 MLXSW_REG_ZERO(rauhtd, payload); 8050 mlxsw_reg_rauhtd_filter_fields_set(payload, MLXSW_REG_RAUHTD_FILTER_A); 8051 mlxsw_reg_rauhtd_op_set(payload, MLXSW_REG_RAUHTD_OP_DUMP_AND_CLEAR); 8052 mlxsw_reg_rauhtd_num_rec_set(payload, MLXSW_REG_RAUHTD_REC_MAX_NUM); 8053 mlxsw_reg_rauhtd_entry_a_set(payload, 1); 8054 mlxsw_reg_rauhtd_type_set(payload, type); 8055 } 8056 8057 /* reg_rauhtd_ipv4_rec_num_entries 8058 * Number of valid entries in this record: 8059 * 0 - 1 valid entry 8060 * 1 - 2 valid entries 8061 * 2 - 3 valid entries 8062 * 3 - 4 valid entries 8063 * Access: RO 8064 */ 8065 MLXSW_ITEM32_INDEXED(reg, rauhtd, ipv4_rec_num_entries, 8066 MLXSW_REG_RAUHTD_BASE_LEN, 28, 2, 8067 MLXSW_REG_RAUHTD_REC_LEN, 0x00, false); 8068 8069 /* reg_rauhtd_rec_type 8070 * Record type. 8071 * 0 - IPv4 8072 * 1 - IPv6 8073 * Access: RO 8074 */ 8075 MLXSW_ITEM32_INDEXED(reg, rauhtd, rec_type, MLXSW_REG_RAUHTD_BASE_LEN, 24, 2, 8076 MLXSW_REG_RAUHTD_REC_LEN, 0x00, false); 8077 8078 #define MLXSW_REG_RAUHTD_IPV4_ENT_LEN 0x8 8079 8080 /* reg_rauhtd_ipv4_ent_a 8081 * Activity. Set for new entries. Set if a packet lookup has hit on the 8082 * specific entry. 8083 * Access: RO 8084 */ 8085 MLXSW_ITEM32_INDEXED(reg, rauhtd, ipv4_ent_a, MLXSW_REG_RAUHTD_BASE_LEN, 16, 1, 8086 MLXSW_REG_RAUHTD_IPV4_ENT_LEN, 0x00, false); 8087 8088 /* reg_rauhtd_ipv4_ent_rif 8089 * Router interface. 8090 * Access: RO 8091 */ 8092 MLXSW_ITEM32_INDEXED(reg, rauhtd, ipv4_ent_rif, MLXSW_REG_RAUHTD_BASE_LEN, 0, 8093 16, MLXSW_REG_RAUHTD_IPV4_ENT_LEN, 0x00, false); 8094 8095 /* reg_rauhtd_ipv4_ent_dip 8096 * Destination IPv4 address. 8097 * Access: RO 8098 */ 8099 MLXSW_ITEM32_INDEXED(reg, rauhtd, ipv4_ent_dip, MLXSW_REG_RAUHTD_BASE_LEN, 0, 8100 32, MLXSW_REG_RAUHTD_IPV4_ENT_LEN, 0x04, false); 8101 8102 #define MLXSW_REG_RAUHTD_IPV6_ENT_LEN 0x20 8103 8104 /* reg_rauhtd_ipv6_ent_a 8105 * Activity. Set for new entries. Set if a packet lookup has hit on the 8106 * specific entry. 8107 * Access: RO 8108 */ 8109 MLXSW_ITEM32_INDEXED(reg, rauhtd, ipv6_ent_a, MLXSW_REG_RAUHTD_BASE_LEN, 16, 1, 8110 MLXSW_REG_RAUHTD_IPV6_ENT_LEN, 0x00, false); 8111 8112 /* reg_rauhtd_ipv6_ent_rif 8113 * Router interface. 8114 * Access: RO 8115 */ 8116 MLXSW_ITEM32_INDEXED(reg, rauhtd, ipv6_ent_rif, MLXSW_REG_RAUHTD_BASE_LEN, 0, 8117 16, MLXSW_REG_RAUHTD_IPV6_ENT_LEN, 0x00, false); 8118 8119 /* reg_rauhtd_ipv6_ent_dip 8120 * Destination IPv6 address. 8121 * Access: RO 8122 */ 8123 MLXSW_ITEM_BUF_INDEXED(reg, rauhtd, ipv6_ent_dip, MLXSW_REG_RAUHTD_BASE_LEN, 8124 16, MLXSW_REG_RAUHTD_IPV6_ENT_LEN, 0x10); 8125 8126 static inline void mlxsw_reg_rauhtd_ent_ipv4_unpack(char *payload, 8127 int ent_index, u16 *p_rif, 8128 u32 *p_dip) 8129 { 8130 *p_rif = mlxsw_reg_rauhtd_ipv4_ent_rif_get(payload, ent_index); 8131 *p_dip = mlxsw_reg_rauhtd_ipv4_ent_dip_get(payload, ent_index); 8132 } 8133 8134 static inline void mlxsw_reg_rauhtd_ent_ipv6_unpack(char *payload, 8135 int rec_index, u16 *p_rif, 8136 char *p_dip) 8137 { 8138 *p_rif = mlxsw_reg_rauhtd_ipv6_ent_rif_get(payload, rec_index); 8139 mlxsw_reg_rauhtd_ipv6_ent_dip_memcpy_from(payload, rec_index, p_dip); 8140 } 8141 8142 /* RTDP - Routing Tunnel Decap Properties Register 8143 * ----------------------------------------------- 8144 * The RTDP register is used for configuring the tunnel decap properties of NVE 8145 * and IPinIP. 8146 */ 8147 #define MLXSW_REG_RTDP_ID 0x8020 8148 #define MLXSW_REG_RTDP_LEN 0x44 8149 8150 MLXSW_REG_DEFINE(rtdp, MLXSW_REG_RTDP_ID, MLXSW_REG_RTDP_LEN); 8151 8152 enum mlxsw_reg_rtdp_type { 8153 MLXSW_REG_RTDP_TYPE_NVE, 8154 MLXSW_REG_RTDP_TYPE_IPIP, 8155 }; 8156 8157 /* reg_rtdp_type 8158 * Type of the RTDP entry as per enum mlxsw_reg_rtdp_type. 8159 * Access: RW 8160 */ 8161 MLXSW_ITEM32(reg, rtdp, type, 0x00, 28, 4); 8162 8163 /* reg_rtdp_tunnel_index 8164 * Index to the Decap entry. 8165 * For Spectrum, Index to KVD Linear. 8166 * Access: Index 8167 */ 8168 MLXSW_ITEM32(reg, rtdp, tunnel_index, 0x00, 0, 24); 8169 8170 /* reg_rtdp_egress_router_interface 8171 * Underlay egress router interface. 8172 * Valid range is from 0 to cap_max_router_interfaces - 1 8173 * Access: RW 8174 */ 8175 MLXSW_ITEM32(reg, rtdp, egress_router_interface, 0x40, 0, 16); 8176 8177 /* IPinIP */ 8178 8179 /* reg_rtdp_ipip_irif 8180 * Ingress Router Interface for the overlay router 8181 * Access: RW 8182 */ 8183 MLXSW_ITEM32(reg, rtdp, ipip_irif, 0x04, 16, 16); 8184 8185 enum mlxsw_reg_rtdp_ipip_sip_check { 8186 /* No sip checks. */ 8187 MLXSW_REG_RTDP_IPIP_SIP_CHECK_NO, 8188 /* Filter packet if underlay is not IPv4 or if underlay SIP does not 8189 * equal ipv4_usip. 8190 */ 8191 MLXSW_REG_RTDP_IPIP_SIP_CHECK_FILTER_IPV4, 8192 /* Filter packet if underlay is not IPv6 or if underlay SIP does not 8193 * equal ipv6_usip. 8194 */ 8195 MLXSW_REG_RTDP_IPIP_SIP_CHECK_FILTER_IPV6 = 3, 8196 }; 8197 8198 /* reg_rtdp_ipip_sip_check 8199 * SIP check to perform. If decapsulation failed due to these configurations 8200 * then trap_id is IPIP_DECAP_ERROR. 8201 * Access: RW 8202 */ 8203 MLXSW_ITEM32(reg, rtdp, ipip_sip_check, 0x04, 0, 3); 8204 8205 /* If set, allow decapsulation of IPinIP (without GRE). */ 8206 #define MLXSW_REG_RTDP_IPIP_TYPE_CHECK_ALLOW_IPIP BIT(0) 8207 /* If set, allow decapsulation of IPinGREinIP without a key. */ 8208 #define MLXSW_REG_RTDP_IPIP_TYPE_CHECK_ALLOW_GRE BIT(1) 8209 /* If set, allow decapsulation of IPinGREinIP with a key. */ 8210 #define MLXSW_REG_RTDP_IPIP_TYPE_CHECK_ALLOW_GRE_KEY BIT(2) 8211 8212 /* reg_rtdp_ipip_type_check 8213 * Flags as per MLXSW_REG_RTDP_IPIP_TYPE_CHECK_*. If decapsulation failed due to 8214 * these configurations then trap_id is IPIP_DECAP_ERROR. 8215 * Access: RW 8216 */ 8217 MLXSW_ITEM32(reg, rtdp, ipip_type_check, 0x08, 24, 3); 8218 8219 /* reg_rtdp_ipip_gre_key_check 8220 * Whether GRE key should be checked. When check is enabled: 8221 * - A packet received as IPinIP (without GRE) will always pass. 8222 * - A packet received as IPinGREinIP without a key will not pass the check. 8223 * - A packet received as IPinGREinIP with a key will pass the check only if the 8224 * key in the packet is equal to expected_gre_key. 8225 * If decapsulation failed due to GRE key then trap_id is IPIP_DECAP_ERROR. 8226 * Access: RW 8227 */ 8228 MLXSW_ITEM32(reg, rtdp, ipip_gre_key_check, 0x08, 23, 1); 8229 8230 /* reg_rtdp_ipip_ipv4_usip 8231 * Underlay IPv4 address for ipv4 source address check. 8232 * Reserved when sip_check is not '1'. 8233 * Access: RW 8234 */ 8235 MLXSW_ITEM32(reg, rtdp, ipip_ipv4_usip, 0x0C, 0, 32); 8236 8237 /* reg_rtdp_ipip_ipv6_usip_ptr 8238 * This field is valid when sip_check is "sipv6 check explicitly". This is a 8239 * pointer to the IPv6 DIP which is configured by RIPS. For Spectrum, the index 8240 * is to the KVD linear. 8241 * Reserved when sip_check is not MLXSW_REG_RTDP_IPIP_SIP_CHECK_FILTER_IPV6. 8242 * Access: RW 8243 */ 8244 MLXSW_ITEM32(reg, rtdp, ipip_ipv6_usip_ptr, 0x10, 0, 24); 8245 8246 /* reg_rtdp_ipip_expected_gre_key 8247 * GRE key for checking. 8248 * Reserved when gre_key_check is '0'. 8249 * Access: RW 8250 */ 8251 MLXSW_ITEM32(reg, rtdp, ipip_expected_gre_key, 0x14, 0, 32); 8252 8253 static inline void mlxsw_reg_rtdp_pack(char *payload, 8254 enum mlxsw_reg_rtdp_type type, 8255 u32 tunnel_index) 8256 { 8257 MLXSW_REG_ZERO(rtdp, payload); 8258 mlxsw_reg_rtdp_type_set(payload, type); 8259 mlxsw_reg_rtdp_tunnel_index_set(payload, tunnel_index); 8260 } 8261 8262 static inline void 8263 mlxsw_reg_rtdp_ipip_pack(char *payload, u16 irif, 8264 enum mlxsw_reg_rtdp_ipip_sip_check sip_check, 8265 unsigned int type_check, bool gre_key_check, 8266 u32 expected_gre_key) 8267 { 8268 mlxsw_reg_rtdp_ipip_irif_set(payload, irif); 8269 mlxsw_reg_rtdp_ipip_sip_check_set(payload, sip_check); 8270 mlxsw_reg_rtdp_ipip_type_check_set(payload, type_check); 8271 mlxsw_reg_rtdp_ipip_gre_key_check_set(payload, gre_key_check); 8272 mlxsw_reg_rtdp_ipip_expected_gre_key_set(payload, expected_gre_key); 8273 } 8274 8275 static inline void 8276 mlxsw_reg_rtdp_ipip4_pack(char *payload, u16 irif, 8277 enum mlxsw_reg_rtdp_ipip_sip_check sip_check, 8278 unsigned int type_check, bool gre_key_check, 8279 u32 ipv4_usip, u32 expected_gre_key) 8280 { 8281 mlxsw_reg_rtdp_ipip_pack(payload, irif, sip_check, type_check, 8282 gre_key_check, expected_gre_key); 8283 mlxsw_reg_rtdp_ipip_ipv4_usip_set(payload, ipv4_usip); 8284 } 8285 8286 static inline void 8287 mlxsw_reg_rtdp_ipip6_pack(char *payload, u16 irif, 8288 enum mlxsw_reg_rtdp_ipip_sip_check sip_check, 8289 unsigned int type_check, bool gre_key_check, 8290 u32 ipv6_usip_ptr, u32 expected_gre_key) 8291 { 8292 mlxsw_reg_rtdp_ipip_pack(payload, irif, sip_check, type_check, 8293 gre_key_check, expected_gre_key); 8294 mlxsw_reg_rtdp_ipip_ipv6_usip_ptr_set(payload, ipv6_usip_ptr); 8295 } 8296 8297 /* RIPS - Router IP version Six Register 8298 * ------------------------------------- 8299 * The RIPS register is used to store IPv6 addresses for use by the NVE and 8300 * IPinIP 8301 */ 8302 #define MLXSW_REG_RIPS_ID 0x8021 8303 #define MLXSW_REG_RIPS_LEN 0x14 8304 8305 MLXSW_REG_DEFINE(rips, MLXSW_REG_RIPS_ID, MLXSW_REG_RIPS_LEN); 8306 8307 /* reg_rips_index 8308 * Index to IPv6 address. 8309 * For Spectrum, the index is to the KVD linear. 8310 * Access: Index 8311 */ 8312 MLXSW_ITEM32(reg, rips, index, 0x00, 0, 24); 8313 8314 /* reg_rips_ipv6 8315 * IPv6 address 8316 * Access: RW 8317 */ 8318 MLXSW_ITEM_BUF(reg, rips, ipv6, 0x04, 16); 8319 8320 static inline void mlxsw_reg_rips_pack(char *payload, u32 index, 8321 const struct in6_addr *ipv6) 8322 { 8323 MLXSW_REG_ZERO(rips, payload); 8324 mlxsw_reg_rips_index_set(payload, index); 8325 mlxsw_reg_rips_ipv6_memcpy_to(payload, (const char *)ipv6); 8326 } 8327 8328 /* RATRAD - Router Adjacency Table Activity Dump Register 8329 * ------------------------------------------------------ 8330 * The RATRAD register is used to dump and optionally clear activity bits of 8331 * router adjacency table entries. 8332 */ 8333 #define MLXSW_REG_RATRAD_ID 0x8022 8334 #define MLXSW_REG_RATRAD_LEN 0x210 8335 8336 MLXSW_REG_DEFINE(ratrad, MLXSW_REG_RATRAD_ID, MLXSW_REG_RATRAD_LEN); 8337 8338 enum { 8339 /* Read activity */ 8340 MLXSW_REG_RATRAD_OP_READ_ACTIVITY, 8341 /* Read and clear activity */ 8342 MLXSW_REG_RATRAD_OP_READ_CLEAR_ACTIVITY, 8343 }; 8344 8345 /* reg_ratrad_op 8346 * Access: Operation 8347 */ 8348 MLXSW_ITEM32(reg, ratrad, op, 0x00, 30, 2); 8349 8350 /* reg_ratrad_ecmp_size 8351 * ecmp_size is the amount of sequential entries from adjacency_index. Valid 8352 * ranges: 8353 * Spectrum-1: 32-64, 512, 1024, 2048, 4096 8354 * Spectrum-2/3: 32-128, 256, 512, 1024, 2048, 4096 8355 * Access: Index 8356 */ 8357 MLXSW_ITEM32(reg, ratrad, ecmp_size, 0x00, 0, 13); 8358 8359 /* reg_ratrad_adjacency_index 8360 * Index into the adjacency table. 8361 * Access: Index 8362 */ 8363 MLXSW_ITEM32(reg, ratrad, adjacency_index, 0x04, 0, 24); 8364 8365 /* reg_ratrad_activity_vector 8366 * Activity bit per adjacency index. 8367 * Bits higher than ecmp_size are reserved. 8368 * Access: RO 8369 */ 8370 MLXSW_ITEM_BIT_ARRAY(reg, ratrad, activity_vector, 0x10, 0x200, 1); 8371 8372 static inline void mlxsw_reg_ratrad_pack(char *payload, u32 adjacency_index, 8373 u16 ecmp_size) 8374 { 8375 MLXSW_REG_ZERO(ratrad, payload); 8376 mlxsw_reg_ratrad_op_set(payload, 8377 MLXSW_REG_RATRAD_OP_READ_CLEAR_ACTIVITY); 8378 mlxsw_reg_ratrad_ecmp_size_set(payload, ecmp_size); 8379 mlxsw_reg_ratrad_adjacency_index_set(payload, adjacency_index); 8380 } 8381 8382 /* RIGR-V2 - Router Interface Group Register Version 2 8383 * --------------------------------------------------- 8384 * The RIGR_V2 register is used to add, remove and query egress interface list 8385 * of a multicast forwarding entry. 8386 */ 8387 #define MLXSW_REG_RIGR2_ID 0x8023 8388 #define MLXSW_REG_RIGR2_LEN 0xB0 8389 8390 #define MLXSW_REG_RIGR2_MAX_ERIFS 32 8391 8392 MLXSW_REG_DEFINE(rigr2, MLXSW_REG_RIGR2_ID, MLXSW_REG_RIGR2_LEN); 8393 8394 /* reg_rigr2_rigr_index 8395 * KVD Linear index. 8396 * Access: Index 8397 */ 8398 MLXSW_ITEM32(reg, rigr2, rigr_index, 0x04, 0, 24); 8399 8400 /* reg_rigr2_vnext 8401 * Next RIGR Index is valid. 8402 * Access: RW 8403 */ 8404 MLXSW_ITEM32(reg, rigr2, vnext, 0x08, 31, 1); 8405 8406 /* reg_rigr2_next_rigr_index 8407 * Next RIGR Index. The index is to the KVD linear. 8408 * Reserved when vnxet = '0'. 8409 * Access: RW 8410 */ 8411 MLXSW_ITEM32(reg, rigr2, next_rigr_index, 0x08, 0, 24); 8412 8413 /* reg_rigr2_vrmid 8414 * RMID Index is valid. 8415 * Access: RW 8416 */ 8417 MLXSW_ITEM32(reg, rigr2, vrmid, 0x20, 31, 1); 8418 8419 /* reg_rigr2_rmid_index 8420 * RMID Index. 8421 * Range 0 .. max_mid - 1 8422 * Reserved when vrmid = '0'. 8423 * The index is to the Port Group Table (PGT) 8424 * Access: RW 8425 */ 8426 MLXSW_ITEM32(reg, rigr2, rmid_index, 0x20, 0, 16); 8427 8428 /* reg_rigr2_erif_entry_v 8429 * Egress Router Interface is valid. 8430 * Note that low-entries must be set if high-entries are set. For 8431 * example: if erif_entry[2].v is set then erif_entry[1].v and 8432 * erif_entry[0].v must be set. 8433 * Index can be from 0 to cap_mc_erif_list_entries-1 8434 * Access: RW 8435 */ 8436 MLXSW_ITEM32_INDEXED(reg, rigr2, erif_entry_v, 0x24, 31, 1, 4, 0, false); 8437 8438 /* reg_rigr2_erif_entry_erif 8439 * Egress Router Interface. 8440 * Valid range is from 0 to cap_max_router_interfaces - 1 8441 * Index can be from 0 to MLXSW_REG_RIGR2_MAX_ERIFS - 1 8442 * Access: RW 8443 */ 8444 MLXSW_ITEM32_INDEXED(reg, rigr2, erif_entry_erif, 0x24, 0, 16, 4, 0, false); 8445 8446 static inline void mlxsw_reg_rigr2_pack(char *payload, u32 rigr_index, 8447 bool vnext, u32 next_rigr_index) 8448 { 8449 MLXSW_REG_ZERO(rigr2, payload); 8450 mlxsw_reg_rigr2_rigr_index_set(payload, rigr_index); 8451 mlxsw_reg_rigr2_vnext_set(payload, vnext); 8452 mlxsw_reg_rigr2_next_rigr_index_set(payload, next_rigr_index); 8453 mlxsw_reg_rigr2_vrmid_set(payload, 0); 8454 mlxsw_reg_rigr2_rmid_index_set(payload, 0); 8455 } 8456 8457 static inline void mlxsw_reg_rigr2_erif_entry_pack(char *payload, int index, 8458 bool v, u16 erif) 8459 { 8460 mlxsw_reg_rigr2_erif_entry_v_set(payload, index, v); 8461 mlxsw_reg_rigr2_erif_entry_erif_set(payload, index, erif); 8462 } 8463 8464 /* RECR-V2 - Router ECMP Configuration Version 2 Register 8465 * ------------------------------------------------------ 8466 */ 8467 #define MLXSW_REG_RECR2_ID 0x8025 8468 #define MLXSW_REG_RECR2_LEN 0x38 8469 8470 MLXSW_REG_DEFINE(recr2, MLXSW_REG_RECR2_ID, MLXSW_REG_RECR2_LEN); 8471 8472 /* reg_recr2_pp 8473 * Per-port configuration 8474 * Access: Index 8475 */ 8476 MLXSW_ITEM32(reg, recr2, pp, 0x00, 24, 1); 8477 8478 /* reg_recr2_sh 8479 * Symmetric hash 8480 * Access: RW 8481 */ 8482 MLXSW_ITEM32(reg, recr2, sh, 0x00, 8, 1); 8483 8484 /* reg_recr2_seed 8485 * Seed 8486 * Access: RW 8487 */ 8488 MLXSW_ITEM32(reg, recr2, seed, 0x08, 0, 32); 8489 8490 enum { 8491 /* Enable IPv4 fields if packet is not TCP and not UDP */ 8492 MLXSW_REG_RECR2_IPV4_EN_NOT_TCP_NOT_UDP = 3, 8493 /* Enable IPv4 fields if packet is TCP or UDP */ 8494 MLXSW_REG_RECR2_IPV4_EN_TCP_UDP = 4, 8495 /* Enable IPv6 fields if packet is not TCP and not UDP */ 8496 MLXSW_REG_RECR2_IPV6_EN_NOT_TCP_NOT_UDP = 5, 8497 /* Enable IPv6 fields if packet is TCP or UDP */ 8498 MLXSW_REG_RECR2_IPV6_EN_TCP_UDP = 6, 8499 /* Enable TCP/UDP header fields if packet is IPv4 */ 8500 MLXSW_REG_RECR2_TCP_UDP_EN_IPV4 = 7, 8501 /* Enable TCP/UDP header fields if packet is IPv6 */ 8502 MLXSW_REG_RECR2_TCP_UDP_EN_IPV6 = 8, 8503 8504 __MLXSW_REG_RECR2_HEADER_CNT, 8505 }; 8506 8507 /* reg_recr2_outer_header_enables 8508 * Bit mask where each bit enables a specific layer to be included in 8509 * the hash calculation. 8510 * Access: RW 8511 */ 8512 MLXSW_ITEM_BIT_ARRAY(reg, recr2, outer_header_enables, 0x10, 0x04, 1); 8513 8514 enum { 8515 /* IPv4 Source IP */ 8516 MLXSW_REG_RECR2_IPV4_SIP0 = 9, 8517 MLXSW_REG_RECR2_IPV4_SIP3 = 12, 8518 /* IPv4 Destination IP */ 8519 MLXSW_REG_RECR2_IPV4_DIP0 = 13, 8520 MLXSW_REG_RECR2_IPV4_DIP3 = 16, 8521 /* IP Protocol */ 8522 MLXSW_REG_RECR2_IPV4_PROTOCOL = 17, 8523 /* IPv6 Source IP */ 8524 MLXSW_REG_RECR2_IPV6_SIP0_7 = 21, 8525 MLXSW_REG_RECR2_IPV6_SIP8 = 29, 8526 MLXSW_REG_RECR2_IPV6_SIP15 = 36, 8527 /* IPv6 Destination IP */ 8528 MLXSW_REG_RECR2_IPV6_DIP0_7 = 37, 8529 MLXSW_REG_RECR2_IPV6_DIP8 = 45, 8530 MLXSW_REG_RECR2_IPV6_DIP15 = 52, 8531 /* IPv6 Next Header */ 8532 MLXSW_REG_RECR2_IPV6_NEXT_HEADER = 53, 8533 /* IPv6 Flow Label */ 8534 MLXSW_REG_RECR2_IPV6_FLOW_LABEL = 57, 8535 /* TCP/UDP Source Port */ 8536 MLXSW_REG_RECR2_TCP_UDP_SPORT = 74, 8537 /* TCP/UDP Destination Port */ 8538 MLXSW_REG_RECR2_TCP_UDP_DPORT = 75, 8539 8540 __MLXSW_REG_RECR2_FIELD_CNT, 8541 }; 8542 8543 /* reg_recr2_outer_header_fields_enable 8544 * Packet fields to enable for ECMP hash subject to outer_header_enable. 8545 * Access: RW 8546 */ 8547 MLXSW_ITEM_BIT_ARRAY(reg, recr2, outer_header_fields_enable, 0x14, 0x14, 1); 8548 8549 /* reg_recr2_inner_header_enables 8550 * Bit mask where each bit enables a specific inner layer to be included in the 8551 * hash calculation. Same values as reg_recr2_outer_header_enables. 8552 * Access: RW 8553 */ 8554 MLXSW_ITEM_BIT_ARRAY(reg, recr2, inner_header_enables, 0x2C, 0x04, 1); 8555 8556 enum { 8557 /* Inner IPv4 Source IP */ 8558 MLXSW_REG_RECR2_INNER_IPV4_SIP0 = 3, 8559 MLXSW_REG_RECR2_INNER_IPV4_SIP3 = 6, 8560 /* Inner IPv4 Destination IP */ 8561 MLXSW_REG_RECR2_INNER_IPV4_DIP0 = 7, 8562 MLXSW_REG_RECR2_INNER_IPV4_DIP3 = 10, 8563 /* Inner IP Protocol */ 8564 MLXSW_REG_RECR2_INNER_IPV4_PROTOCOL = 11, 8565 /* Inner IPv6 Source IP */ 8566 MLXSW_REG_RECR2_INNER_IPV6_SIP0_7 = 12, 8567 MLXSW_REG_RECR2_INNER_IPV6_SIP8 = 20, 8568 MLXSW_REG_RECR2_INNER_IPV6_SIP15 = 27, 8569 /* Inner IPv6 Destination IP */ 8570 MLXSW_REG_RECR2_INNER_IPV6_DIP0_7 = 28, 8571 MLXSW_REG_RECR2_INNER_IPV6_DIP8 = 36, 8572 MLXSW_REG_RECR2_INNER_IPV6_DIP15 = 43, 8573 /* Inner IPv6 Next Header */ 8574 MLXSW_REG_RECR2_INNER_IPV6_NEXT_HEADER = 44, 8575 /* Inner IPv6 Flow Label */ 8576 MLXSW_REG_RECR2_INNER_IPV6_FLOW_LABEL = 45, 8577 /* Inner TCP/UDP Source Port */ 8578 MLXSW_REG_RECR2_INNER_TCP_UDP_SPORT = 46, 8579 /* Inner TCP/UDP Destination Port */ 8580 MLXSW_REG_RECR2_INNER_TCP_UDP_DPORT = 47, 8581 8582 __MLXSW_REG_RECR2_INNER_FIELD_CNT, 8583 }; 8584 8585 /* reg_recr2_inner_header_fields_enable 8586 * Inner packet fields to enable for ECMP hash subject to inner_header_enables. 8587 * Access: RW 8588 */ 8589 MLXSW_ITEM_BIT_ARRAY(reg, recr2, inner_header_fields_enable, 0x30, 0x08, 1); 8590 8591 static inline void mlxsw_reg_recr2_pack(char *payload, u32 seed) 8592 { 8593 MLXSW_REG_ZERO(recr2, payload); 8594 mlxsw_reg_recr2_pp_set(payload, false); 8595 mlxsw_reg_recr2_sh_set(payload, true); 8596 mlxsw_reg_recr2_seed_set(payload, seed); 8597 } 8598 8599 /* RMFT-V2 - Router Multicast Forwarding Table Version 2 Register 8600 * -------------------------------------------------------------- 8601 * The RMFT_V2 register is used to configure and query the multicast table. 8602 */ 8603 #define MLXSW_REG_RMFT2_ID 0x8027 8604 #define MLXSW_REG_RMFT2_LEN 0x174 8605 8606 MLXSW_REG_DEFINE(rmft2, MLXSW_REG_RMFT2_ID, MLXSW_REG_RMFT2_LEN); 8607 8608 /* reg_rmft2_v 8609 * Valid 8610 * Access: RW 8611 */ 8612 MLXSW_ITEM32(reg, rmft2, v, 0x00, 31, 1); 8613 8614 enum mlxsw_reg_rmft2_type { 8615 MLXSW_REG_RMFT2_TYPE_IPV4, 8616 MLXSW_REG_RMFT2_TYPE_IPV6 8617 }; 8618 8619 /* reg_rmft2_type 8620 * Access: Index 8621 */ 8622 MLXSW_ITEM32(reg, rmft2, type, 0x00, 28, 2); 8623 8624 enum mlxsw_sp_reg_rmft2_op { 8625 /* For Write: 8626 * Write operation. Used to write a new entry to the table. All RW 8627 * fields are relevant for new entry. Activity bit is set for new 8628 * entries - Note write with v (Valid) 0 will delete the entry. 8629 * For Query: 8630 * Read operation 8631 */ 8632 MLXSW_REG_RMFT2_OP_READ_WRITE, 8633 }; 8634 8635 /* reg_rmft2_op 8636 * Operation. 8637 * Access: OP 8638 */ 8639 MLXSW_ITEM32(reg, rmft2, op, 0x00, 20, 2); 8640 8641 /* reg_rmft2_a 8642 * Activity. Set for new entries. Set if a packet lookup has hit on the specific 8643 * entry. 8644 * Access: RO 8645 */ 8646 MLXSW_ITEM32(reg, rmft2, a, 0x00, 16, 1); 8647 8648 /* reg_rmft2_offset 8649 * Offset within the multicast forwarding table to write to. 8650 * Access: Index 8651 */ 8652 MLXSW_ITEM32(reg, rmft2, offset, 0x00, 0, 16); 8653 8654 /* reg_rmft2_virtual_router 8655 * Virtual Router ID. Range from 0..cap_max_virtual_routers-1 8656 * Access: RW 8657 */ 8658 MLXSW_ITEM32(reg, rmft2, virtual_router, 0x04, 0, 16); 8659 8660 enum mlxsw_reg_rmft2_irif_mask { 8661 MLXSW_REG_RMFT2_IRIF_MASK_IGNORE, 8662 MLXSW_REG_RMFT2_IRIF_MASK_COMPARE 8663 }; 8664 8665 /* reg_rmft2_irif_mask 8666 * Ingress RIF mask. 8667 * Access: RW 8668 */ 8669 MLXSW_ITEM32(reg, rmft2, irif_mask, 0x08, 24, 1); 8670 8671 /* reg_rmft2_irif 8672 * Ingress RIF index. 8673 * Access: RW 8674 */ 8675 MLXSW_ITEM32(reg, rmft2, irif, 0x08, 0, 16); 8676 8677 /* reg_rmft2_dip{4,6} 8678 * Destination IPv4/6 address 8679 * Access: RW 8680 */ 8681 MLXSW_ITEM_BUF(reg, rmft2, dip6, 0x10, 16); 8682 MLXSW_ITEM32(reg, rmft2, dip4, 0x1C, 0, 32); 8683 8684 /* reg_rmft2_dip{4,6}_mask 8685 * A bit that is set directs the TCAM to compare the corresponding bit in key. A 8686 * bit that is clear directs the TCAM to ignore the corresponding bit in key. 8687 * Access: RW 8688 */ 8689 MLXSW_ITEM_BUF(reg, rmft2, dip6_mask, 0x20, 16); 8690 MLXSW_ITEM32(reg, rmft2, dip4_mask, 0x2C, 0, 32); 8691 8692 /* reg_rmft2_sip{4,6} 8693 * Source IPv4/6 address 8694 * Access: RW 8695 */ 8696 MLXSW_ITEM_BUF(reg, rmft2, sip6, 0x30, 16); 8697 MLXSW_ITEM32(reg, rmft2, sip4, 0x3C, 0, 32); 8698 8699 /* reg_rmft2_sip{4,6}_mask 8700 * A bit that is set directs the TCAM to compare the corresponding bit in key. A 8701 * bit that is clear directs the TCAM to ignore the corresponding bit in key. 8702 * Access: RW 8703 */ 8704 MLXSW_ITEM_BUF(reg, rmft2, sip6_mask, 0x40, 16); 8705 MLXSW_ITEM32(reg, rmft2, sip4_mask, 0x4C, 0, 32); 8706 8707 /* reg_rmft2_flexible_action_set 8708 * ACL action set. The only supported action types in this field and in any 8709 * action-set pointed from here are as follows: 8710 * 00h: ACTION_NULL 8711 * 01h: ACTION_MAC_TTL, only TTL configuration is supported. 8712 * 03h: ACTION_TRAP 8713 * 06h: ACTION_QOS 8714 * 08h: ACTION_POLICING_MONITORING 8715 * 10h: ACTION_ROUTER_MC 8716 * Access: RW 8717 */ 8718 MLXSW_ITEM_BUF(reg, rmft2, flexible_action_set, 0x80, 8719 MLXSW_REG_FLEX_ACTION_SET_LEN); 8720 8721 static inline void 8722 mlxsw_reg_rmft2_common_pack(char *payload, bool v, u16 offset, 8723 u16 virtual_router, 8724 enum mlxsw_reg_rmft2_irif_mask irif_mask, u16 irif, 8725 const char *flex_action_set) 8726 { 8727 MLXSW_REG_ZERO(rmft2, payload); 8728 mlxsw_reg_rmft2_v_set(payload, v); 8729 mlxsw_reg_rmft2_op_set(payload, MLXSW_REG_RMFT2_OP_READ_WRITE); 8730 mlxsw_reg_rmft2_offset_set(payload, offset); 8731 mlxsw_reg_rmft2_virtual_router_set(payload, virtual_router); 8732 mlxsw_reg_rmft2_irif_mask_set(payload, irif_mask); 8733 mlxsw_reg_rmft2_irif_set(payload, irif); 8734 if (flex_action_set) 8735 mlxsw_reg_rmft2_flexible_action_set_memcpy_to(payload, 8736 flex_action_set); 8737 } 8738 8739 static inline void 8740 mlxsw_reg_rmft2_ipv4_pack(char *payload, bool v, u16 offset, u16 virtual_router, 8741 enum mlxsw_reg_rmft2_irif_mask irif_mask, u16 irif, 8742 u32 dip4, u32 dip4_mask, u32 sip4, u32 sip4_mask, 8743 const char *flexible_action_set) 8744 { 8745 mlxsw_reg_rmft2_common_pack(payload, v, offset, virtual_router, 8746 irif_mask, irif, flexible_action_set); 8747 mlxsw_reg_rmft2_type_set(payload, MLXSW_REG_RMFT2_TYPE_IPV4); 8748 mlxsw_reg_rmft2_dip4_set(payload, dip4); 8749 mlxsw_reg_rmft2_dip4_mask_set(payload, dip4_mask); 8750 mlxsw_reg_rmft2_sip4_set(payload, sip4); 8751 mlxsw_reg_rmft2_sip4_mask_set(payload, sip4_mask); 8752 } 8753 8754 static inline void 8755 mlxsw_reg_rmft2_ipv6_pack(char *payload, bool v, u16 offset, u16 virtual_router, 8756 enum mlxsw_reg_rmft2_irif_mask irif_mask, u16 irif, 8757 struct in6_addr dip6, struct in6_addr dip6_mask, 8758 struct in6_addr sip6, struct in6_addr sip6_mask, 8759 const char *flexible_action_set) 8760 { 8761 mlxsw_reg_rmft2_common_pack(payload, v, offset, virtual_router, 8762 irif_mask, irif, flexible_action_set); 8763 mlxsw_reg_rmft2_type_set(payload, MLXSW_REG_RMFT2_TYPE_IPV6); 8764 mlxsw_reg_rmft2_dip6_memcpy_to(payload, (void *)&dip6); 8765 mlxsw_reg_rmft2_dip6_mask_memcpy_to(payload, (void *)&dip6_mask); 8766 mlxsw_reg_rmft2_sip6_memcpy_to(payload, (void *)&sip6); 8767 mlxsw_reg_rmft2_sip6_mask_memcpy_to(payload, (void *)&sip6_mask); 8768 } 8769 8770 /* RXLTE - Router XLT Enable Register 8771 * ---------------------------------- 8772 * The RXLTE enables XLT (eXtended Lookup Table) LPM lookups if a capable 8773 * XM is present on the system. 8774 */ 8775 8776 #define MLXSW_REG_RXLTE_ID 0x8050 8777 #define MLXSW_REG_RXLTE_LEN 0x0C 8778 8779 MLXSW_REG_DEFINE(rxlte, MLXSW_REG_RXLTE_ID, MLXSW_REG_RXLTE_LEN); 8780 8781 /* reg_rxlte_virtual_router 8782 * Virtual router ID associated with the router interface. 8783 * Range is 0..cap_max_virtual_routers-1 8784 * Access: Index 8785 */ 8786 MLXSW_ITEM32(reg, rxlte, virtual_router, 0x00, 0, 16); 8787 8788 enum mlxsw_reg_rxlte_protocol { 8789 MLXSW_REG_RXLTE_PROTOCOL_IPV4, 8790 MLXSW_REG_RXLTE_PROTOCOL_IPV6, 8791 }; 8792 8793 /* reg_rxlte_protocol 8794 * Access: Index 8795 */ 8796 MLXSW_ITEM32(reg, rxlte, protocol, 0x04, 0, 4); 8797 8798 /* reg_rxlte_lpm_xlt_en 8799 * Access: RW 8800 */ 8801 MLXSW_ITEM32(reg, rxlte, lpm_xlt_en, 0x08, 0, 1); 8802 8803 static inline void mlxsw_reg_rxlte_pack(char *payload, u16 virtual_router, 8804 enum mlxsw_reg_rxlte_protocol protocol, 8805 bool lpm_xlt_en) 8806 { 8807 MLXSW_REG_ZERO(rxlte, payload); 8808 mlxsw_reg_rxlte_virtual_router_set(payload, virtual_router); 8809 mlxsw_reg_rxlte_protocol_set(payload, protocol); 8810 mlxsw_reg_rxlte_lpm_xlt_en_set(payload, lpm_xlt_en); 8811 } 8812 8813 /* RXLTM - Router XLT M select Register 8814 * ------------------------------------ 8815 * The RXLTM configures and selects the M for the XM lookups. 8816 */ 8817 8818 #define MLXSW_REG_RXLTM_ID 0x8051 8819 #define MLXSW_REG_RXLTM_LEN 0x14 8820 8821 MLXSW_REG_DEFINE(rxltm, MLXSW_REG_RXLTM_ID, MLXSW_REG_RXLTM_LEN); 8822 8823 /* reg_rxltm_m0_val_v6 8824 * Global M0 value For IPv6. 8825 * Range 0..128 8826 * Access: RW 8827 */ 8828 MLXSW_ITEM32(reg, rxltm, m0_val_v6, 0x10, 16, 8); 8829 8830 /* reg_rxltm_m0_val_v4 8831 * Global M0 value For IPv4. 8832 * Range 0..32 8833 * Access: RW 8834 */ 8835 MLXSW_ITEM32(reg, rxltm, m0_val_v4, 0x10, 0, 6); 8836 8837 static inline void mlxsw_reg_rxltm_pack(char *payload, u8 m0_val_v4, u8 m0_val_v6) 8838 { 8839 MLXSW_REG_ZERO(rxltm, payload); 8840 mlxsw_reg_rxltm_m0_val_v6_set(payload, m0_val_v6); 8841 mlxsw_reg_rxltm_m0_val_v4_set(payload, m0_val_v4); 8842 } 8843 8844 /* RLCMLD - Router LPM Cache ML Delete Register 8845 * -------------------------------------------- 8846 * The RLCMLD register is used to bulk delete the XLT-LPM cache ML entries. 8847 * This can be used by SW when L is increased or decreased, thus need to 8848 * remove entries with old ML values. 8849 */ 8850 8851 #define MLXSW_REG_RLCMLD_ID 0x8055 8852 #define MLXSW_REG_RLCMLD_LEN 0x30 8853 8854 MLXSW_REG_DEFINE(rlcmld, MLXSW_REG_RLCMLD_ID, MLXSW_REG_RLCMLD_LEN); 8855 8856 enum mlxsw_reg_rlcmld_select { 8857 MLXSW_REG_RLCMLD_SELECT_ML_ENTRIES, 8858 MLXSW_REG_RLCMLD_SELECT_M_ENTRIES, 8859 MLXSW_REG_RLCMLD_SELECT_M_AND_ML_ENTRIES, 8860 }; 8861 8862 /* reg_rlcmld_select 8863 * Which entries to delete. 8864 * Access: Index 8865 */ 8866 MLXSW_ITEM32(reg, rlcmld, select, 0x00, 16, 2); 8867 8868 enum mlxsw_reg_rlcmld_filter_fields { 8869 MLXSW_REG_RLCMLD_FILTER_FIELDS_BY_PROTOCOL = 0x04, 8870 MLXSW_REG_RLCMLD_FILTER_FIELDS_BY_VIRTUAL_ROUTER = 0x08, 8871 MLXSW_REG_RLCMLD_FILTER_FIELDS_BY_DIP = 0x10, 8872 }; 8873 8874 /* reg_rlcmld_filter_fields 8875 * If a bit is '0' then the relevant field is ignored. 8876 * Access: Index 8877 */ 8878 MLXSW_ITEM32(reg, rlcmld, filter_fields, 0x00, 0, 8); 8879 8880 enum mlxsw_reg_rlcmld_protocol { 8881 MLXSW_REG_RLCMLD_PROTOCOL_UC_IPV4, 8882 MLXSW_REG_RLCMLD_PROTOCOL_UC_IPV6, 8883 }; 8884 8885 /* reg_rlcmld_protocol 8886 * Access: Index 8887 */ 8888 MLXSW_ITEM32(reg, rlcmld, protocol, 0x08, 0, 4); 8889 8890 /* reg_rlcmld_virtual_router 8891 * Virtual router ID. 8892 * Range is 0..cap_max_virtual_routers-1 8893 * Access: Index 8894 */ 8895 MLXSW_ITEM32(reg, rlcmld, virtual_router, 0x0C, 0, 16); 8896 8897 /* reg_rlcmld_dip 8898 * The prefix of the route or of the marker that the object of the LPM 8899 * is compared with. The most significant bits of the dip are the prefix. 8900 * Access: Index 8901 */ 8902 MLXSW_ITEM32(reg, rlcmld, dip4, 0x1C, 0, 32); 8903 MLXSW_ITEM_BUF(reg, rlcmld, dip6, 0x10, 16); 8904 8905 /* reg_rlcmld_dip_mask 8906 * per bit: 8907 * 0: no match 8908 * 1: match 8909 * Access: Index 8910 */ 8911 MLXSW_ITEM32(reg, rlcmld, dip_mask4, 0x2C, 0, 32); 8912 MLXSW_ITEM_BUF(reg, rlcmld, dip_mask6, 0x20, 16); 8913 8914 static inline void __mlxsw_reg_rlcmld_pack(char *payload, 8915 enum mlxsw_reg_rlcmld_select select, 8916 enum mlxsw_reg_rlcmld_protocol protocol, 8917 u16 virtual_router) 8918 { 8919 u8 filter_fields = MLXSW_REG_RLCMLD_FILTER_FIELDS_BY_PROTOCOL | 8920 MLXSW_REG_RLCMLD_FILTER_FIELDS_BY_VIRTUAL_ROUTER | 8921 MLXSW_REG_RLCMLD_FILTER_FIELDS_BY_DIP; 8922 8923 MLXSW_REG_ZERO(rlcmld, payload); 8924 mlxsw_reg_rlcmld_select_set(payload, select); 8925 mlxsw_reg_rlcmld_filter_fields_set(payload, filter_fields); 8926 mlxsw_reg_rlcmld_protocol_set(payload, protocol); 8927 mlxsw_reg_rlcmld_virtual_router_set(payload, virtual_router); 8928 } 8929 8930 static inline void mlxsw_reg_rlcmld_pack4(char *payload, 8931 enum mlxsw_reg_rlcmld_select select, 8932 u16 virtual_router, 8933 u32 dip, u32 dip_mask) 8934 { 8935 __mlxsw_reg_rlcmld_pack(payload, select, 8936 MLXSW_REG_RLCMLD_PROTOCOL_UC_IPV4, 8937 virtual_router); 8938 mlxsw_reg_rlcmld_dip4_set(payload, dip); 8939 mlxsw_reg_rlcmld_dip_mask4_set(payload, dip_mask); 8940 } 8941 8942 static inline void mlxsw_reg_rlcmld_pack6(char *payload, 8943 enum mlxsw_reg_rlcmld_select select, 8944 u16 virtual_router, 8945 const void *dip, const void *dip_mask) 8946 { 8947 __mlxsw_reg_rlcmld_pack(payload, select, 8948 MLXSW_REG_RLCMLD_PROTOCOL_UC_IPV6, 8949 virtual_router); 8950 mlxsw_reg_rlcmld_dip6_memcpy_to(payload, dip); 8951 mlxsw_reg_rlcmld_dip_mask6_memcpy_to(payload, dip_mask); 8952 } 8953 8954 /* RLPMCE - Router LPM Cache Enable Register 8955 * ----------------------------------------- 8956 * Allows disabling the LPM cache. Can be changed on the fly. 8957 */ 8958 8959 #define MLXSW_REG_RLPMCE_ID 0x8056 8960 #define MLXSW_REG_RLPMCE_LEN 0x4 8961 8962 MLXSW_REG_DEFINE(rlpmce, MLXSW_REG_RLPMCE_ID, MLXSW_REG_RLPMCE_LEN); 8963 8964 /* reg_rlpmce_flush 8965 * Flush: 8966 * 0: do not flush the cache (default) 8967 * 1: flush (clear) the cache 8968 * Access: WO 8969 */ 8970 MLXSW_ITEM32(reg, rlpmce, flush, 0x00, 4, 1); 8971 8972 /* reg_rlpmce_disable 8973 * LPM cache: 8974 * 0: enabled (default) 8975 * 1: disabled 8976 * Access: RW 8977 */ 8978 MLXSW_ITEM32(reg, rlpmce, disable, 0x00, 0, 1); 8979 8980 static inline void mlxsw_reg_rlpmce_pack(char *payload, bool flush, 8981 bool disable) 8982 { 8983 MLXSW_REG_ZERO(rlpmce, payload); 8984 mlxsw_reg_rlpmce_flush_set(payload, flush); 8985 mlxsw_reg_rlpmce_disable_set(payload, disable); 8986 } 8987 8988 /* Note that XLTQ, XMDR, XRMT and XRALXX register positions violate the rule 8989 * of ordering register definitions by the ID. However, XRALXX pack helpers are 8990 * using RALXX pack helpers, RALXX registers have higher IDs. 8991 * Also XMDR is using RALUE enums. XLRQ and XRMT are just put alongside with the 8992 * related registers. 8993 */ 8994 8995 /* XLTQ - XM Lookup Table Query Register 8996 * ------------------------------------- 8997 */ 8998 #define MLXSW_REG_XLTQ_ID 0x7802 8999 #define MLXSW_REG_XLTQ_LEN 0x2C 9000 9001 MLXSW_REG_DEFINE(xltq, MLXSW_REG_XLTQ_ID, MLXSW_REG_XLTQ_LEN); 9002 9003 enum mlxsw_reg_xltq_xm_device_id { 9004 MLXSW_REG_XLTQ_XM_DEVICE_ID_UNKNOWN, 9005 MLXSW_REG_XLTQ_XM_DEVICE_ID_XLT = 0xCF71, 9006 }; 9007 9008 /* reg_xltq_xm_device_id 9009 * XM device ID. 9010 * Access: RO 9011 */ 9012 MLXSW_ITEM32(reg, xltq, xm_device_id, 0x04, 0, 16); 9013 9014 /* reg_xltq_xlt_cap_ipv4_lpm 9015 * Access: RO 9016 */ 9017 MLXSW_ITEM32(reg, xltq, xlt_cap_ipv4_lpm, 0x10, 0, 1); 9018 9019 /* reg_xltq_xlt_cap_ipv6_lpm 9020 * Access: RO 9021 */ 9022 MLXSW_ITEM32(reg, xltq, xlt_cap_ipv6_lpm, 0x10, 1, 1); 9023 9024 /* reg_xltq_cap_xlt_entries 9025 * Number of XLT entries 9026 * Note: SW must not fill more than 80% in order to avoid overflow 9027 * Access: RO 9028 */ 9029 MLXSW_ITEM32(reg, xltq, cap_xlt_entries, 0x20, 0, 32); 9030 9031 /* reg_xltq_cap_xlt_mtable 9032 * XLT M-Table max size 9033 * Access: RO 9034 */ 9035 MLXSW_ITEM32(reg, xltq, cap_xlt_mtable, 0x24, 0, 32); 9036 9037 static inline void mlxsw_reg_xltq_pack(char *payload) 9038 { 9039 MLXSW_REG_ZERO(xltq, payload); 9040 } 9041 9042 static inline void mlxsw_reg_xltq_unpack(char *payload, u16 *xm_device_id, bool *xlt_cap_ipv4_lpm, 9043 bool *xlt_cap_ipv6_lpm, u32 *cap_xlt_entries, 9044 u32 *cap_xlt_mtable) 9045 { 9046 *xm_device_id = mlxsw_reg_xltq_xm_device_id_get(payload); 9047 *xlt_cap_ipv4_lpm = mlxsw_reg_xltq_xlt_cap_ipv4_lpm_get(payload); 9048 *xlt_cap_ipv6_lpm = mlxsw_reg_xltq_xlt_cap_ipv6_lpm_get(payload); 9049 *cap_xlt_entries = mlxsw_reg_xltq_cap_xlt_entries_get(payload); 9050 *cap_xlt_mtable = mlxsw_reg_xltq_cap_xlt_mtable_get(payload); 9051 } 9052 9053 /* XMDR - XM Direct Register 9054 * ------------------------- 9055 * The XMDR allows direct access to the XM device via the switch. 9056 * Working in synchronous mode. FW waits for response from the XLT 9057 * for each command. FW acks the XMDR accordingly. 9058 */ 9059 #define MLXSW_REG_XMDR_ID 0x7803 9060 #define MLXSW_REG_XMDR_BASE_LEN 0x20 9061 #define MLXSW_REG_XMDR_TRANS_LEN 0x80 9062 #define MLXSW_REG_XMDR_LEN (MLXSW_REG_XMDR_BASE_LEN + \ 9063 MLXSW_REG_XMDR_TRANS_LEN) 9064 9065 MLXSW_REG_DEFINE(xmdr, MLXSW_REG_XMDR_ID, MLXSW_REG_XMDR_LEN); 9066 9067 /* reg_xmdr_bulk_entry 9068 * Bulk_entry 9069 * 0: Last entry - immediate flush of XRT-cache 9070 * 1: Bulk entry - do not flush the XRT-cache 9071 * Access: OP 9072 */ 9073 MLXSW_ITEM32(reg, xmdr, bulk_entry, 0x04, 8, 1); 9074 9075 /* reg_xmdr_num_rec 9076 * Number of records for Direct access to XM 9077 * Supported: 0..4 commands (except NOP which is a filler) 9078 * 0 commands is reserved when bulk_entry = 1. 9079 * 0 commands is allowed when bulk_entry = 0 for immediate XRT-cache flush. 9080 * Access: OP 9081 */ 9082 MLXSW_ITEM32(reg, xmdr, num_rec, 0x04, 0, 4); 9083 9084 /* reg_xmdr_reply_vect 9085 * Reply Vector 9086 * Bit i for command index i+1 9087 * values per bit: 9088 * 0: failed 9089 * 1: succeeded 9090 * e.g. if commands 1, 2, 4 succeeded and command 3 failed then binary 9091 * value will be 0b1011 9092 * Access: RO 9093 */ 9094 MLXSW_ITEM_BIT_ARRAY(reg, xmdr, reply_vect, 0x08, 4, 1); 9095 9096 static inline void mlxsw_reg_xmdr_pack(char *payload, bool bulk_entry) 9097 { 9098 MLXSW_REG_ZERO(xmdr, payload); 9099 mlxsw_reg_xmdr_bulk_entry_set(payload, bulk_entry); 9100 } 9101 9102 enum mlxsw_reg_xmdr_c_cmd_id { 9103 MLXSW_REG_XMDR_C_CMD_ID_LT_ROUTE_V4 = 0x30, 9104 MLXSW_REG_XMDR_C_CMD_ID_LT_ROUTE_V6 = 0x31, 9105 }; 9106 9107 #define MLXSW_REG_XMDR_C_LT_ROUTE_V4_LEN 32 9108 #define MLXSW_REG_XMDR_C_LT_ROUTE_V6_LEN 48 9109 9110 /* reg_xmdr_c_cmd_id 9111 */ 9112 MLXSW_ITEM32(reg, xmdr_c, cmd_id, 0x00, 24, 8); 9113 9114 /* reg_xmdr_c_seq_number 9115 */ 9116 MLXSW_ITEM32(reg, xmdr_c, seq_number, 0x00, 12, 12); 9117 9118 enum mlxsw_reg_xmdr_c_ltr_op { 9119 /* Activity is set */ 9120 MLXSW_REG_XMDR_C_LTR_OP_WRITE = 0, 9121 /* There is no update mask. All fields are updated. */ 9122 MLXSW_REG_XMDR_C_LTR_OP_UPDATE = 1, 9123 MLXSW_REG_XMDR_C_LTR_OP_DELETE = 2, 9124 }; 9125 9126 /* reg_xmdr_c_ltr_op 9127 * Operation. 9128 */ 9129 MLXSW_ITEM32(reg, xmdr_c, ltr_op, 0x04, 24, 8); 9130 9131 /* reg_xmdr_c_ltr_trap_action 9132 * Trap action. 9133 * Values are defined in enum mlxsw_reg_ralue_trap_action. 9134 */ 9135 MLXSW_ITEM32(reg, xmdr_c, ltr_trap_action, 0x04, 20, 4); 9136 9137 enum mlxsw_reg_xmdr_c_ltr_trap_id_num { 9138 MLXSW_REG_XMDR_C_LTR_TRAP_ID_NUM_RTR_INGRESS0, 9139 MLXSW_REG_XMDR_C_LTR_TRAP_ID_NUM_RTR_INGRESS1, 9140 MLXSW_REG_XMDR_C_LTR_TRAP_ID_NUM_RTR_INGRESS2, 9141 MLXSW_REG_XMDR_C_LTR_TRAP_ID_NUM_RTR_INGRESS3, 9142 }; 9143 9144 /* reg_xmdr_c_ltr_trap_id_num 9145 * Trap-ID number. 9146 */ 9147 MLXSW_ITEM32(reg, xmdr_c, ltr_trap_id_num, 0x04, 16, 4); 9148 9149 /* reg_xmdr_c_ltr_virtual_router 9150 * Virtual Router ID. 9151 * Range is 0..cap_max_virtual_routers-1 9152 */ 9153 MLXSW_ITEM32(reg, xmdr_c, ltr_virtual_router, 0x04, 0, 16); 9154 9155 /* reg_xmdr_c_ltr_prefix_len 9156 * Number of bits in the prefix of the LPM route. 9157 */ 9158 MLXSW_ITEM32(reg, xmdr_c, ltr_prefix_len, 0x08, 24, 8); 9159 9160 /* reg_xmdr_c_ltr_bmp_len 9161 * The best match prefix length in the case that there is no match for 9162 * longer prefixes. 9163 * If (entry_type != MARKER_ENTRY), bmp_len must be equal to prefix_len 9164 */ 9165 MLXSW_ITEM32(reg, xmdr_c, ltr_bmp_len, 0x08, 16, 8); 9166 9167 /* reg_xmdr_c_ltr_entry_type 9168 * Entry type. 9169 * Values are defined in enum mlxsw_reg_ralue_entry_type. 9170 */ 9171 MLXSW_ITEM32(reg, xmdr_c, ltr_entry_type, 0x08, 4, 4); 9172 9173 enum mlxsw_reg_xmdr_c_ltr_action_type { 9174 MLXSW_REG_XMDR_C_LTR_ACTION_TYPE_LOCAL, 9175 MLXSW_REG_XMDR_C_LTR_ACTION_TYPE_REMOTE, 9176 MLXSW_REG_XMDR_C_LTR_ACTION_TYPE_IP2ME, 9177 }; 9178 9179 /* reg_xmdr_c_ltr_action_type 9180 * Action Type. 9181 */ 9182 MLXSW_ITEM32(reg, xmdr_c, ltr_action_type, 0x08, 0, 4); 9183 9184 /* reg_xmdr_c_ltr_erif 9185 * Egress Router Interface. 9186 * Only relevant in case of LOCAL action. 9187 */ 9188 MLXSW_ITEM32(reg, xmdr_c, ltr_erif, 0x10, 0, 16); 9189 9190 /* reg_xmdr_c_ltr_adjacency_index 9191 * Points to the first entry of the group-based ECMP. 9192 * Only relevant in case of REMOTE action. 9193 */ 9194 MLXSW_ITEM32(reg, xmdr_c, ltr_adjacency_index, 0x10, 0, 24); 9195 9196 #define MLXSW_REG_XMDR_C_LTR_POINTER_TO_TUNNEL_DISABLED_MAGIC 0xFFFFFF 9197 9198 /* reg_xmdr_c_ltr_pointer_to_tunnel 9199 * Only relevant in case of IP2ME action. 9200 */ 9201 MLXSW_ITEM32(reg, xmdr_c, ltr_pointer_to_tunnel, 0x10, 0, 24); 9202 9203 /* reg_xmdr_c_ltr_ecmp_size 9204 * Amount of sequential entries starting 9205 * from the adjacency_index (the number of ECMPs). 9206 * The valid range is 1-64, 512, 1024, 2048 and 4096. 9207 * Only relevant in case of REMOTE action. 9208 */ 9209 MLXSW_ITEM32(reg, xmdr_c, ltr_ecmp_size, 0x14, 0, 32); 9210 9211 /* reg_xmdr_c_ltr_dip* 9212 * The prefix of the route or of the marker that the object of the LPM 9213 * is compared with. The most significant bits of the dip are the prefix. 9214 * The least significant bits must be '0' if the prefix_len is smaller 9215 * than 128 for IPv6 or smaller than 32 for IPv4. 9216 */ 9217 MLXSW_ITEM32(reg, xmdr_c, ltr_dip4, 0x1C, 0, 32); 9218 MLXSW_ITEM_BUF(reg, xmdr_c, ltr_dip6, 0x1C, 16); 9219 9220 static inline void 9221 mlxsw_reg_xmdr_c_ltr_pack(char *xmdr_payload, unsigned int trans_offset, 9222 enum mlxsw_reg_xmdr_c_cmd_id cmd_id, u16 seq_number, 9223 enum mlxsw_reg_xmdr_c_ltr_op op, u16 virtual_router, 9224 u8 prefix_len) 9225 { 9226 char *payload = xmdr_payload + MLXSW_REG_XMDR_BASE_LEN + trans_offset; 9227 u8 num_rec = mlxsw_reg_xmdr_num_rec_get(xmdr_payload); 9228 9229 mlxsw_reg_xmdr_num_rec_set(xmdr_payload, num_rec + 1); 9230 9231 mlxsw_reg_xmdr_c_cmd_id_set(payload, cmd_id); 9232 mlxsw_reg_xmdr_c_seq_number_set(payload, seq_number); 9233 mlxsw_reg_xmdr_c_ltr_op_set(payload, op); 9234 mlxsw_reg_xmdr_c_ltr_virtual_router_set(payload, virtual_router); 9235 mlxsw_reg_xmdr_c_ltr_prefix_len_set(payload, prefix_len); 9236 mlxsw_reg_xmdr_c_ltr_entry_type_set(payload, 9237 MLXSW_REG_RALUE_ENTRY_TYPE_ROUTE_ENTRY); 9238 mlxsw_reg_xmdr_c_ltr_bmp_len_set(payload, prefix_len); 9239 } 9240 9241 static inline unsigned int 9242 mlxsw_reg_xmdr_c_ltr_pack4(char *xmdr_payload, unsigned int trans_offset, 9243 u16 seq_number, enum mlxsw_reg_xmdr_c_ltr_op op, 9244 u16 virtual_router, u8 prefix_len, u32 *dip) 9245 { 9246 char *payload = xmdr_payload + MLXSW_REG_XMDR_BASE_LEN + trans_offset; 9247 9248 mlxsw_reg_xmdr_c_ltr_pack(xmdr_payload, trans_offset, 9249 MLXSW_REG_XMDR_C_CMD_ID_LT_ROUTE_V4, 9250 seq_number, op, virtual_router, prefix_len); 9251 if (dip) 9252 mlxsw_reg_xmdr_c_ltr_dip4_set(payload, *dip); 9253 return MLXSW_REG_XMDR_C_LT_ROUTE_V4_LEN; 9254 } 9255 9256 static inline unsigned int 9257 mlxsw_reg_xmdr_c_ltr_pack6(char *xmdr_payload, unsigned int trans_offset, 9258 u16 seq_number, enum mlxsw_reg_xmdr_c_ltr_op op, 9259 u16 virtual_router, u8 prefix_len, const void *dip) 9260 { 9261 char *payload = xmdr_payload + MLXSW_REG_XMDR_BASE_LEN + trans_offset; 9262 9263 mlxsw_reg_xmdr_c_ltr_pack(xmdr_payload, trans_offset, 9264 MLXSW_REG_XMDR_C_CMD_ID_LT_ROUTE_V6, 9265 seq_number, op, virtual_router, prefix_len); 9266 if (dip) 9267 mlxsw_reg_xmdr_c_ltr_dip6_memcpy_to(payload, dip); 9268 return MLXSW_REG_XMDR_C_LT_ROUTE_V6_LEN; 9269 } 9270 9271 static inline void 9272 mlxsw_reg_xmdr_c_ltr_act_remote_pack(char *xmdr_payload, unsigned int trans_offset, 9273 enum mlxsw_reg_ralue_trap_action trap_action, 9274 enum mlxsw_reg_xmdr_c_ltr_trap_id_num trap_id_num, 9275 u32 adjacency_index, u16 ecmp_size) 9276 { 9277 char *payload = xmdr_payload + MLXSW_REG_XMDR_BASE_LEN + trans_offset; 9278 9279 mlxsw_reg_xmdr_c_ltr_action_type_set(payload, MLXSW_REG_XMDR_C_LTR_ACTION_TYPE_REMOTE); 9280 mlxsw_reg_xmdr_c_ltr_trap_action_set(payload, trap_action); 9281 mlxsw_reg_xmdr_c_ltr_trap_id_num_set(payload, trap_id_num); 9282 mlxsw_reg_xmdr_c_ltr_adjacency_index_set(payload, adjacency_index); 9283 mlxsw_reg_xmdr_c_ltr_ecmp_size_set(payload, ecmp_size); 9284 } 9285 9286 static inline void 9287 mlxsw_reg_xmdr_c_ltr_act_local_pack(char *xmdr_payload, unsigned int trans_offset, 9288 enum mlxsw_reg_ralue_trap_action trap_action, 9289 enum mlxsw_reg_xmdr_c_ltr_trap_id_num trap_id_num, u16 erif) 9290 { 9291 char *payload = xmdr_payload + MLXSW_REG_XMDR_BASE_LEN + trans_offset; 9292 9293 mlxsw_reg_xmdr_c_ltr_action_type_set(payload, MLXSW_REG_XMDR_C_LTR_ACTION_TYPE_LOCAL); 9294 mlxsw_reg_xmdr_c_ltr_trap_action_set(payload, trap_action); 9295 mlxsw_reg_xmdr_c_ltr_trap_id_num_set(payload, trap_id_num); 9296 mlxsw_reg_xmdr_c_ltr_erif_set(payload, erif); 9297 } 9298 9299 static inline void mlxsw_reg_xmdr_c_ltr_act_ip2me_pack(char *xmdr_payload, 9300 unsigned int trans_offset) 9301 { 9302 char *payload = xmdr_payload + MLXSW_REG_XMDR_BASE_LEN + trans_offset; 9303 9304 mlxsw_reg_xmdr_c_ltr_action_type_set(payload, MLXSW_REG_XMDR_C_LTR_ACTION_TYPE_IP2ME); 9305 mlxsw_reg_xmdr_c_ltr_pointer_to_tunnel_set(payload, 9306 MLXSW_REG_XMDR_C_LTR_POINTER_TO_TUNNEL_DISABLED_MAGIC); 9307 } 9308 9309 static inline void mlxsw_reg_xmdr_c_ltr_act_ip2me_tun_pack(char *xmdr_payload, 9310 unsigned int trans_offset, 9311 u32 pointer_to_tunnel) 9312 { 9313 char *payload = xmdr_payload + MLXSW_REG_XMDR_BASE_LEN + trans_offset; 9314 9315 mlxsw_reg_xmdr_c_ltr_action_type_set(payload, MLXSW_REG_XMDR_C_LTR_ACTION_TYPE_IP2ME); 9316 mlxsw_reg_xmdr_c_ltr_pointer_to_tunnel_set(payload, pointer_to_tunnel); 9317 } 9318 9319 /* XRMT - XM Router M Table Register 9320 * --------------------------------- 9321 * The XRMT configures the M-Table for the XLT-LPM. 9322 */ 9323 #define MLXSW_REG_XRMT_ID 0x7810 9324 #define MLXSW_REG_XRMT_LEN 0x14 9325 9326 MLXSW_REG_DEFINE(xrmt, MLXSW_REG_XRMT_ID, MLXSW_REG_XRMT_LEN); 9327 9328 /* reg_xrmt_index 9329 * Index in M-Table. 9330 * Range 0..cap_xlt_mtable-1 9331 * Access: Index 9332 */ 9333 MLXSW_ITEM32(reg, xrmt, index, 0x04, 0, 20); 9334 9335 /* reg_xrmt_l0_val 9336 * Access: RW 9337 */ 9338 MLXSW_ITEM32(reg, xrmt, l0_val, 0x10, 24, 8); 9339 9340 static inline void mlxsw_reg_xrmt_pack(char *payload, u32 index, u8 l0_val) 9341 { 9342 MLXSW_REG_ZERO(xrmt, payload); 9343 mlxsw_reg_xrmt_index_set(payload, index); 9344 mlxsw_reg_xrmt_l0_val_set(payload, l0_val); 9345 } 9346 9347 /* XRALTA - XM Router Algorithmic LPM Tree Allocation Register 9348 * ----------------------------------------------------------- 9349 * The XRALTA is used to allocate the XLT LPM trees. 9350 * 9351 * This register embeds original RALTA register. 9352 */ 9353 #define MLXSW_REG_XRALTA_ID 0x7811 9354 #define MLXSW_REG_XRALTA_LEN 0x08 9355 #define MLXSW_REG_XRALTA_RALTA_OFFSET 0x04 9356 9357 MLXSW_REG_DEFINE(xralta, MLXSW_REG_XRALTA_ID, MLXSW_REG_XRALTA_LEN); 9358 9359 static inline void mlxsw_reg_xralta_pack(char *payload, bool alloc, 9360 enum mlxsw_reg_ralxx_protocol protocol, 9361 u8 tree_id) 9362 { 9363 char *ralta_payload = payload + MLXSW_REG_XRALTA_RALTA_OFFSET; 9364 9365 MLXSW_REG_ZERO(xralta, payload); 9366 mlxsw_reg_ralta_pack(ralta_payload, alloc, protocol, tree_id); 9367 } 9368 9369 /* XRALST - XM Router Algorithmic LPM Structure Tree Register 9370 * ---------------------------------------------------------- 9371 * The XRALST is used to set and query the structure of an XLT LPM tree. 9372 * 9373 * This register embeds original RALST register. 9374 */ 9375 #define MLXSW_REG_XRALST_ID 0x7812 9376 #define MLXSW_REG_XRALST_LEN 0x108 9377 #define MLXSW_REG_XRALST_RALST_OFFSET 0x04 9378 9379 MLXSW_REG_DEFINE(xralst, MLXSW_REG_XRALST_ID, MLXSW_REG_XRALST_LEN); 9380 9381 static inline void mlxsw_reg_xralst_pack(char *payload, u8 root_bin, u8 tree_id) 9382 { 9383 char *ralst_payload = payload + MLXSW_REG_XRALST_RALST_OFFSET; 9384 9385 MLXSW_REG_ZERO(xralst, payload); 9386 mlxsw_reg_ralst_pack(ralst_payload, root_bin, tree_id); 9387 } 9388 9389 static inline void mlxsw_reg_xralst_bin_pack(char *payload, u8 bin_number, 9390 u8 left_child_bin, 9391 u8 right_child_bin) 9392 { 9393 char *ralst_payload = payload + MLXSW_REG_XRALST_RALST_OFFSET; 9394 9395 mlxsw_reg_ralst_bin_pack(ralst_payload, bin_number, left_child_bin, 9396 right_child_bin); 9397 } 9398 9399 /* XRALTB - XM Router Algorithmic LPM Tree Binding Register 9400 * -------------------------------------------------------- 9401 * The XRALTB register is used to bind virtual router and protocol 9402 * to an allocated LPM tree. 9403 * 9404 * This register embeds original RALTB register. 9405 */ 9406 #define MLXSW_REG_XRALTB_ID 0x7813 9407 #define MLXSW_REG_XRALTB_LEN 0x08 9408 #define MLXSW_REG_XRALTB_RALTB_OFFSET 0x04 9409 9410 MLXSW_REG_DEFINE(xraltb, MLXSW_REG_XRALTB_ID, MLXSW_REG_XRALTB_LEN); 9411 9412 static inline void mlxsw_reg_xraltb_pack(char *payload, u16 virtual_router, 9413 enum mlxsw_reg_ralxx_protocol protocol, 9414 u8 tree_id) 9415 { 9416 char *raltb_payload = payload + MLXSW_REG_XRALTB_RALTB_OFFSET; 9417 9418 MLXSW_REG_ZERO(xraltb, payload); 9419 mlxsw_reg_raltb_pack(raltb_payload, virtual_router, protocol, tree_id); 9420 } 9421 9422 /* MFCR - Management Fan Control Register 9423 * -------------------------------------- 9424 * This register controls the settings of the Fan Speed PWM mechanism. 9425 */ 9426 #define MLXSW_REG_MFCR_ID 0x9001 9427 #define MLXSW_REG_MFCR_LEN 0x08 9428 9429 MLXSW_REG_DEFINE(mfcr, MLXSW_REG_MFCR_ID, MLXSW_REG_MFCR_LEN); 9430 9431 enum mlxsw_reg_mfcr_pwm_frequency { 9432 MLXSW_REG_MFCR_PWM_FEQ_11HZ = 0x00, 9433 MLXSW_REG_MFCR_PWM_FEQ_14_7HZ = 0x01, 9434 MLXSW_REG_MFCR_PWM_FEQ_22_1HZ = 0x02, 9435 MLXSW_REG_MFCR_PWM_FEQ_1_4KHZ = 0x40, 9436 MLXSW_REG_MFCR_PWM_FEQ_5KHZ = 0x41, 9437 MLXSW_REG_MFCR_PWM_FEQ_20KHZ = 0x42, 9438 MLXSW_REG_MFCR_PWM_FEQ_22_5KHZ = 0x43, 9439 MLXSW_REG_MFCR_PWM_FEQ_25KHZ = 0x44, 9440 }; 9441 9442 /* reg_mfcr_pwm_frequency 9443 * Controls the frequency of the PWM signal. 9444 * Access: RW 9445 */ 9446 MLXSW_ITEM32(reg, mfcr, pwm_frequency, 0x00, 0, 7); 9447 9448 #define MLXSW_MFCR_TACHOS_MAX 10 9449 9450 /* reg_mfcr_tacho_active 9451 * Indicates which of the tachometer is active (bit per tachometer). 9452 * Access: RO 9453 */ 9454 MLXSW_ITEM32(reg, mfcr, tacho_active, 0x04, 16, MLXSW_MFCR_TACHOS_MAX); 9455 9456 #define MLXSW_MFCR_PWMS_MAX 5 9457 9458 /* reg_mfcr_pwm_active 9459 * Indicates which of the PWM control is active (bit per PWM). 9460 * Access: RO 9461 */ 9462 MLXSW_ITEM32(reg, mfcr, pwm_active, 0x04, 0, MLXSW_MFCR_PWMS_MAX); 9463 9464 static inline void 9465 mlxsw_reg_mfcr_pack(char *payload, 9466 enum mlxsw_reg_mfcr_pwm_frequency pwm_frequency) 9467 { 9468 MLXSW_REG_ZERO(mfcr, payload); 9469 mlxsw_reg_mfcr_pwm_frequency_set(payload, pwm_frequency); 9470 } 9471 9472 static inline void 9473 mlxsw_reg_mfcr_unpack(char *payload, 9474 enum mlxsw_reg_mfcr_pwm_frequency *p_pwm_frequency, 9475 u16 *p_tacho_active, u8 *p_pwm_active) 9476 { 9477 *p_pwm_frequency = mlxsw_reg_mfcr_pwm_frequency_get(payload); 9478 *p_tacho_active = mlxsw_reg_mfcr_tacho_active_get(payload); 9479 *p_pwm_active = mlxsw_reg_mfcr_pwm_active_get(payload); 9480 } 9481 9482 /* MFSC - Management Fan Speed Control Register 9483 * -------------------------------------------- 9484 * This register controls the settings of the Fan Speed PWM mechanism. 9485 */ 9486 #define MLXSW_REG_MFSC_ID 0x9002 9487 #define MLXSW_REG_MFSC_LEN 0x08 9488 9489 MLXSW_REG_DEFINE(mfsc, MLXSW_REG_MFSC_ID, MLXSW_REG_MFSC_LEN); 9490 9491 /* reg_mfsc_pwm 9492 * Fan pwm to control / monitor. 9493 * Access: Index 9494 */ 9495 MLXSW_ITEM32(reg, mfsc, pwm, 0x00, 24, 3); 9496 9497 /* reg_mfsc_pwm_duty_cycle 9498 * Controls the duty cycle of the PWM. Value range from 0..255 to 9499 * represent duty cycle of 0%...100%. 9500 * Access: RW 9501 */ 9502 MLXSW_ITEM32(reg, mfsc, pwm_duty_cycle, 0x04, 0, 8); 9503 9504 static inline void mlxsw_reg_mfsc_pack(char *payload, u8 pwm, 9505 u8 pwm_duty_cycle) 9506 { 9507 MLXSW_REG_ZERO(mfsc, payload); 9508 mlxsw_reg_mfsc_pwm_set(payload, pwm); 9509 mlxsw_reg_mfsc_pwm_duty_cycle_set(payload, pwm_duty_cycle); 9510 } 9511 9512 /* MFSM - Management Fan Speed Measurement 9513 * --------------------------------------- 9514 * This register controls the settings of the Tacho measurements and 9515 * enables reading the Tachometer measurements. 9516 */ 9517 #define MLXSW_REG_MFSM_ID 0x9003 9518 #define MLXSW_REG_MFSM_LEN 0x08 9519 9520 MLXSW_REG_DEFINE(mfsm, MLXSW_REG_MFSM_ID, MLXSW_REG_MFSM_LEN); 9521 9522 /* reg_mfsm_tacho 9523 * Fan tachometer index. 9524 * Access: Index 9525 */ 9526 MLXSW_ITEM32(reg, mfsm, tacho, 0x00, 24, 4); 9527 9528 /* reg_mfsm_rpm 9529 * Fan speed (round per minute). 9530 * Access: RO 9531 */ 9532 MLXSW_ITEM32(reg, mfsm, rpm, 0x04, 0, 16); 9533 9534 static inline void mlxsw_reg_mfsm_pack(char *payload, u8 tacho) 9535 { 9536 MLXSW_REG_ZERO(mfsm, payload); 9537 mlxsw_reg_mfsm_tacho_set(payload, tacho); 9538 } 9539 9540 /* MFSL - Management Fan Speed Limit Register 9541 * ------------------------------------------ 9542 * The Fan Speed Limit register is used to configure the fan speed 9543 * event / interrupt notification mechanism. Fan speed threshold are 9544 * defined for both under-speed and over-speed. 9545 */ 9546 #define MLXSW_REG_MFSL_ID 0x9004 9547 #define MLXSW_REG_MFSL_LEN 0x0C 9548 9549 MLXSW_REG_DEFINE(mfsl, MLXSW_REG_MFSL_ID, MLXSW_REG_MFSL_LEN); 9550 9551 /* reg_mfsl_tacho 9552 * Fan tachometer index. 9553 * Access: Index 9554 */ 9555 MLXSW_ITEM32(reg, mfsl, tacho, 0x00, 24, 4); 9556 9557 /* reg_mfsl_tach_min 9558 * Tachometer minimum value (minimum RPM). 9559 * Access: RW 9560 */ 9561 MLXSW_ITEM32(reg, mfsl, tach_min, 0x04, 0, 16); 9562 9563 /* reg_mfsl_tach_max 9564 * Tachometer maximum value (maximum RPM). 9565 * Access: RW 9566 */ 9567 MLXSW_ITEM32(reg, mfsl, tach_max, 0x08, 0, 16); 9568 9569 static inline void mlxsw_reg_mfsl_pack(char *payload, u8 tacho, 9570 u16 tach_min, u16 tach_max) 9571 { 9572 MLXSW_REG_ZERO(mfsl, payload); 9573 mlxsw_reg_mfsl_tacho_set(payload, tacho); 9574 mlxsw_reg_mfsl_tach_min_set(payload, tach_min); 9575 mlxsw_reg_mfsl_tach_max_set(payload, tach_max); 9576 } 9577 9578 static inline void mlxsw_reg_mfsl_unpack(char *payload, u8 tacho, 9579 u16 *p_tach_min, u16 *p_tach_max) 9580 { 9581 if (p_tach_min) 9582 *p_tach_min = mlxsw_reg_mfsl_tach_min_get(payload); 9583 9584 if (p_tach_max) 9585 *p_tach_max = mlxsw_reg_mfsl_tach_max_get(payload); 9586 } 9587 9588 /* FORE - Fan Out of Range Event Register 9589 * -------------------------------------- 9590 * This register reports the status of the controlled fans compared to the 9591 * range defined by the MFSL register. 9592 */ 9593 #define MLXSW_REG_FORE_ID 0x9007 9594 #define MLXSW_REG_FORE_LEN 0x0C 9595 9596 MLXSW_REG_DEFINE(fore, MLXSW_REG_FORE_ID, MLXSW_REG_FORE_LEN); 9597 9598 /* fan_under_limit 9599 * Fan speed is below the low limit defined in MFSL register. Each bit relates 9600 * to a single tachometer and indicates the specific tachometer reading is 9601 * below the threshold. 9602 * Access: RO 9603 */ 9604 MLXSW_ITEM32(reg, fore, fan_under_limit, 0x00, 16, 10); 9605 9606 static inline void mlxsw_reg_fore_unpack(char *payload, u8 tacho, 9607 bool *fault) 9608 { 9609 u16 limit; 9610 9611 if (fault) { 9612 limit = mlxsw_reg_fore_fan_under_limit_get(payload); 9613 *fault = limit & BIT(tacho); 9614 } 9615 } 9616 9617 /* MTCAP - Management Temperature Capabilities 9618 * ------------------------------------------- 9619 * This register exposes the capabilities of the device and 9620 * system temperature sensing. 9621 */ 9622 #define MLXSW_REG_MTCAP_ID 0x9009 9623 #define MLXSW_REG_MTCAP_LEN 0x08 9624 9625 MLXSW_REG_DEFINE(mtcap, MLXSW_REG_MTCAP_ID, MLXSW_REG_MTCAP_LEN); 9626 9627 /* reg_mtcap_sensor_count 9628 * Number of sensors supported by the device. 9629 * This includes the QSFP module sensors (if exists in the QSFP module). 9630 * Access: RO 9631 */ 9632 MLXSW_ITEM32(reg, mtcap, sensor_count, 0x00, 0, 7); 9633 9634 /* MTMP - Management Temperature 9635 * ----------------------------- 9636 * This register controls the settings of the temperature measurements 9637 * and enables reading the temperature measurements. Note that temperature 9638 * is in 0.125 degrees Celsius. 9639 */ 9640 #define MLXSW_REG_MTMP_ID 0x900A 9641 #define MLXSW_REG_MTMP_LEN 0x20 9642 9643 MLXSW_REG_DEFINE(mtmp, MLXSW_REG_MTMP_ID, MLXSW_REG_MTMP_LEN); 9644 9645 #define MLXSW_REG_MTMP_MODULE_INDEX_MIN 64 9646 #define MLXSW_REG_MTMP_GBOX_INDEX_MIN 256 9647 /* reg_mtmp_sensor_index 9648 * Sensors index to access. 9649 * 64-127 of sensor_index are mapped to the SFP+/QSFP modules sequentially 9650 * (module 0 is mapped to sensor_index 64). 9651 * Access: Index 9652 */ 9653 MLXSW_ITEM32(reg, mtmp, sensor_index, 0x00, 0, 12); 9654 9655 /* Convert to milli degrees Celsius */ 9656 #define MLXSW_REG_MTMP_TEMP_TO_MC(val) ({ typeof(val) v_ = (val); \ 9657 ((v_) >= 0) ? ((v_) * 125) : \ 9658 ((s16)((GENMASK(15, 0) + (v_) + 1) \ 9659 * 125)); }) 9660 9661 /* reg_mtmp_max_operational_temperature 9662 * The highest temperature in the nominal operational range. Reading is in 9663 * 0.125 Celsius degrees units. 9664 * In case of module this is SFF critical temperature threshold. 9665 * Access: RO 9666 */ 9667 MLXSW_ITEM32(reg, mtmp, max_operational_temperature, 0x04, 16, 16); 9668 9669 /* reg_mtmp_temperature 9670 * Temperature reading from the sensor. Reading is in 0.125 Celsius 9671 * degrees units. 9672 * Access: RO 9673 */ 9674 MLXSW_ITEM32(reg, mtmp, temperature, 0x04, 0, 16); 9675 9676 /* reg_mtmp_mte 9677 * Max Temperature Enable - enables measuring the max temperature on a sensor. 9678 * Access: RW 9679 */ 9680 MLXSW_ITEM32(reg, mtmp, mte, 0x08, 31, 1); 9681 9682 /* reg_mtmp_mtr 9683 * Max Temperature Reset - clears the value of the max temperature register. 9684 * Access: WO 9685 */ 9686 MLXSW_ITEM32(reg, mtmp, mtr, 0x08, 30, 1); 9687 9688 /* reg_mtmp_max_temperature 9689 * The highest measured temperature from the sensor. 9690 * When the bit mte is cleared, the field max_temperature is reserved. 9691 * Access: RO 9692 */ 9693 MLXSW_ITEM32(reg, mtmp, max_temperature, 0x08, 0, 16); 9694 9695 /* reg_mtmp_tee 9696 * Temperature Event Enable. 9697 * 0 - Do not generate event 9698 * 1 - Generate event 9699 * 2 - Generate single event 9700 * Access: RW 9701 */ 9702 9703 enum mlxsw_reg_mtmp_tee { 9704 MLXSW_REG_MTMP_TEE_NO_EVENT, 9705 MLXSW_REG_MTMP_TEE_GENERATE_EVENT, 9706 MLXSW_REG_MTMP_TEE_GENERATE_SINGLE_EVENT, 9707 }; 9708 9709 MLXSW_ITEM32(reg, mtmp, tee, 0x0C, 30, 2); 9710 9711 #define MLXSW_REG_MTMP_THRESH_HI 0x348 /* 105 Celsius */ 9712 9713 /* reg_mtmp_temperature_threshold_hi 9714 * High threshold for Temperature Warning Event. In 0.125 Celsius. 9715 * Access: RW 9716 */ 9717 MLXSW_ITEM32(reg, mtmp, temperature_threshold_hi, 0x0C, 0, 16); 9718 9719 #define MLXSW_REG_MTMP_HYSTERESIS_TEMP 0x28 /* 5 Celsius */ 9720 /* reg_mtmp_temperature_threshold_lo 9721 * Low threshold for Temperature Warning Event. In 0.125 Celsius. 9722 * Access: RW 9723 */ 9724 MLXSW_ITEM32(reg, mtmp, temperature_threshold_lo, 0x10, 0, 16); 9725 9726 #define MLXSW_REG_MTMP_SENSOR_NAME_SIZE 8 9727 9728 /* reg_mtmp_sensor_name 9729 * Sensor Name 9730 * Access: RO 9731 */ 9732 MLXSW_ITEM_BUF(reg, mtmp, sensor_name, 0x18, MLXSW_REG_MTMP_SENSOR_NAME_SIZE); 9733 9734 static inline void mlxsw_reg_mtmp_pack(char *payload, u16 sensor_index, 9735 bool max_temp_enable, 9736 bool max_temp_reset) 9737 { 9738 MLXSW_REG_ZERO(mtmp, payload); 9739 mlxsw_reg_mtmp_sensor_index_set(payload, sensor_index); 9740 mlxsw_reg_mtmp_mte_set(payload, max_temp_enable); 9741 mlxsw_reg_mtmp_mtr_set(payload, max_temp_reset); 9742 mlxsw_reg_mtmp_temperature_threshold_hi_set(payload, 9743 MLXSW_REG_MTMP_THRESH_HI); 9744 } 9745 9746 static inline void mlxsw_reg_mtmp_unpack(char *payload, int *p_temp, 9747 int *p_max_temp, int *p_temp_hi, 9748 int *p_max_oper_temp, 9749 char *sensor_name) 9750 { 9751 s16 temp; 9752 9753 if (p_temp) { 9754 temp = mlxsw_reg_mtmp_temperature_get(payload); 9755 *p_temp = MLXSW_REG_MTMP_TEMP_TO_MC(temp); 9756 } 9757 if (p_max_temp) { 9758 temp = mlxsw_reg_mtmp_max_temperature_get(payload); 9759 *p_max_temp = MLXSW_REG_MTMP_TEMP_TO_MC(temp); 9760 } 9761 if (p_temp_hi) { 9762 temp = mlxsw_reg_mtmp_temperature_threshold_hi_get(payload); 9763 *p_temp_hi = MLXSW_REG_MTMP_TEMP_TO_MC(temp); 9764 } 9765 if (p_max_oper_temp) { 9766 temp = mlxsw_reg_mtmp_max_operational_temperature_get(payload); 9767 *p_max_oper_temp = MLXSW_REG_MTMP_TEMP_TO_MC(temp); 9768 } 9769 if (sensor_name) 9770 mlxsw_reg_mtmp_sensor_name_memcpy_from(payload, sensor_name); 9771 } 9772 9773 /* MTWE - Management Temperature Warning Event 9774 * ------------------------------------------- 9775 * This register is used for over temperature warning. 9776 */ 9777 #define MLXSW_REG_MTWE_ID 0x900B 9778 #define MLXSW_REG_MTWE_LEN 0x10 9779 9780 MLXSW_REG_DEFINE(mtwe, MLXSW_REG_MTWE_ID, MLXSW_REG_MTWE_LEN); 9781 9782 /* reg_mtwe_sensor_warning 9783 * Bit vector indicating which of the sensor reading is above threshold. 9784 * Address 00h bit31 is sensor_warning[127]. 9785 * Address 0Ch bit0 is sensor_warning[0]. 9786 * Access: RO 9787 */ 9788 MLXSW_ITEM_BIT_ARRAY(reg, mtwe, sensor_warning, 0x0, 0x10, 1); 9789 9790 /* MTBR - Management Temperature Bulk Register 9791 * ------------------------------------------- 9792 * This register is used for bulk temperature reading. 9793 */ 9794 #define MLXSW_REG_MTBR_ID 0x900F 9795 #define MLXSW_REG_MTBR_BASE_LEN 0x10 /* base length, without records */ 9796 #define MLXSW_REG_MTBR_REC_LEN 0x04 /* record length */ 9797 #define MLXSW_REG_MTBR_REC_MAX_COUNT 47 /* firmware limitation */ 9798 #define MLXSW_REG_MTBR_LEN (MLXSW_REG_MTBR_BASE_LEN + \ 9799 MLXSW_REG_MTBR_REC_LEN * \ 9800 MLXSW_REG_MTBR_REC_MAX_COUNT) 9801 9802 MLXSW_REG_DEFINE(mtbr, MLXSW_REG_MTBR_ID, MLXSW_REG_MTBR_LEN); 9803 9804 /* reg_mtbr_base_sensor_index 9805 * Base sensors index to access (0 - ASIC sensor, 1-63 - ambient sensors, 9806 * 64-127 are mapped to the SFP+/QSFP modules sequentially). 9807 * Access: Index 9808 */ 9809 MLXSW_ITEM32(reg, mtbr, base_sensor_index, 0x00, 0, 12); 9810 9811 /* reg_mtbr_num_rec 9812 * Request: Number of records to read 9813 * Response: Number of records read 9814 * See above description for more details. 9815 * Range 1..255 9816 * Access: RW 9817 */ 9818 MLXSW_ITEM32(reg, mtbr, num_rec, 0x04, 0, 8); 9819 9820 /* reg_mtbr_rec_max_temp 9821 * The highest measured temperature from the sensor. 9822 * When the bit mte is cleared, the field max_temperature is reserved. 9823 * Access: RO 9824 */ 9825 MLXSW_ITEM32_INDEXED(reg, mtbr, rec_max_temp, MLXSW_REG_MTBR_BASE_LEN, 16, 9826 16, MLXSW_REG_MTBR_REC_LEN, 0x00, false); 9827 9828 /* reg_mtbr_rec_temp 9829 * Temperature reading from the sensor. Reading is in 0..125 Celsius 9830 * degrees units. 9831 * Access: RO 9832 */ 9833 MLXSW_ITEM32_INDEXED(reg, mtbr, rec_temp, MLXSW_REG_MTBR_BASE_LEN, 0, 16, 9834 MLXSW_REG_MTBR_REC_LEN, 0x00, false); 9835 9836 static inline void mlxsw_reg_mtbr_pack(char *payload, u16 base_sensor_index, 9837 u8 num_rec) 9838 { 9839 MLXSW_REG_ZERO(mtbr, payload); 9840 mlxsw_reg_mtbr_base_sensor_index_set(payload, base_sensor_index); 9841 mlxsw_reg_mtbr_num_rec_set(payload, num_rec); 9842 } 9843 9844 /* Error codes from temperatute reading */ 9845 enum mlxsw_reg_mtbr_temp_status { 9846 MLXSW_REG_MTBR_NO_CONN = 0x8000, 9847 MLXSW_REG_MTBR_NO_TEMP_SENS = 0x8001, 9848 MLXSW_REG_MTBR_INDEX_NA = 0x8002, 9849 MLXSW_REG_MTBR_BAD_SENS_INFO = 0x8003, 9850 }; 9851 9852 /* Base index for reading modules temperature */ 9853 #define MLXSW_REG_MTBR_BASE_MODULE_INDEX 64 9854 9855 static inline void mlxsw_reg_mtbr_temp_unpack(char *payload, int rec_ind, 9856 u16 *p_temp, u16 *p_max_temp) 9857 { 9858 if (p_temp) 9859 *p_temp = mlxsw_reg_mtbr_rec_temp_get(payload, rec_ind); 9860 if (p_max_temp) 9861 *p_max_temp = mlxsw_reg_mtbr_rec_max_temp_get(payload, rec_ind); 9862 } 9863 9864 /* MCIA - Management Cable Info Access 9865 * ----------------------------------- 9866 * MCIA register is used to access the SFP+ and QSFP connector's EPROM. 9867 */ 9868 9869 #define MLXSW_REG_MCIA_ID 0x9014 9870 #define MLXSW_REG_MCIA_LEN 0x40 9871 9872 MLXSW_REG_DEFINE(mcia, MLXSW_REG_MCIA_ID, MLXSW_REG_MCIA_LEN); 9873 9874 /* reg_mcia_l 9875 * Lock bit. Setting this bit will lock the access to the specific 9876 * cable. Used for updating a full page in a cable EPROM. Any access 9877 * other then subsequence writes will fail while the port is locked. 9878 * Access: RW 9879 */ 9880 MLXSW_ITEM32(reg, mcia, l, 0x00, 31, 1); 9881 9882 /* reg_mcia_module 9883 * Module number. 9884 * Access: Index 9885 */ 9886 MLXSW_ITEM32(reg, mcia, module, 0x00, 16, 8); 9887 9888 enum { 9889 MLXSW_REG_MCIA_STATUS_GOOD = 0, 9890 /* No response from module's EEPROM. */ 9891 MLXSW_REG_MCIA_STATUS_NO_EEPROM_MODULE = 1, 9892 /* Module type not supported by the device. */ 9893 MLXSW_REG_MCIA_STATUS_MODULE_NOT_SUPPORTED = 2, 9894 /* No module present indication. */ 9895 MLXSW_REG_MCIA_STATUS_MODULE_NOT_CONNECTED = 3, 9896 /* Error occurred while trying to access module's EEPROM using I2C. */ 9897 MLXSW_REG_MCIA_STATUS_I2C_ERROR = 9, 9898 /* Module is disabled. */ 9899 MLXSW_REG_MCIA_STATUS_MODULE_DISABLED = 16, 9900 }; 9901 9902 /* reg_mcia_status 9903 * Module status. 9904 * Access: RO 9905 */ 9906 MLXSW_ITEM32(reg, mcia, status, 0x00, 0, 8); 9907 9908 /* reg_mcia_i2c_device_address 9909 * I2C device address. 9910 * Access: RW 9911 */ 9912 MLXSW_ITEM32(reg, mcia, i2c_device_address, 0x04, 24, 8); 9913 9914 /* reg_mcia_page_number 9915 * Page number. 9916 * Access: RW 9917 */ 9918 MLXSW_ITEM32(reg, mcia, page_number, 0x04, 16, 8); 9919 9920 /* reg_mcia_device_address 9921 * Device address. 9922 * Access: RW 9923 */ 9924 MLXSW_ITEM32(reg, mcia, device_address, 0x04, 0, 16); 9925 9926 /* reg_mcia_bank_number 9927 * Bank number. 9928 * Access: Index 9929 */ 9930 MLXSW_ITEM32(reg, mcia, bank_number, 0x08, 16, 8); 9931 9932 /* reg_mcia_size 9933 * Number of bytes to read/write (up to 48 bytes). 9934 * Access: RW 9935 */ 9936 MLXSW_ITEM32(reg, mcia, size, 0x08, 0, 16); 9937 9938 #define MLXSW_REG_MCIA_EEPROM_PAGE_LENGTH 256 9939 #define MLXSW_REG_MCIA_EEPROM_UP_PAGE_LENGTH 128 9940 #define MLXSW_REG_MCIA_EEPROM_SIZE 48 9941 #define MLXSW_REG_MCIA_I2C_ADDR_LOW 0x50 9942 #define MLXSW_REG_MCIA_I2C_ADDR_HIGH 0x51 9943 #define MLXSW_REG_MCIA_PAGE0_LO_OFF 0xa0 9944 #define MLXSW_REG_MCIA_TH_ITEM_SIZE 2 9945 #define MLXSW_REG_MCIA_TH_PAGE_NUM 3 9946 #define MLXSW_REG_MCIA_TH_PAGE_CMIS_NUM 2 9947 #define MLXSW_REG_MCIA_PAGE0_LO 0 9948 #define MLXSW_REG_MCIA_TH_PAGE_OFF 0x80 9949 #define MLXSW_REG_MCIA_EEPROM_CMIS_FLAT_MEMORY BIT(7) 9950 9951 enum mlxsw_reg_mcia_eeprom_module_info_rev_id { 9952 MLXSW_REG_MCIA_EEPROM_MODULE_INFO_REV_ID_UNSPC = 0x00, 9953 MLXSW_REG_MCIA_EEPROM_MODULE_INFO_REV_ID_8436 = 0x01, 9954 MLXSW_REG_MCIA_EEPROM_MODULE_INFO_REV_ID_8636 = 0x03, 9955 }; 9956 9957 enum mlxsw_reg_mcia_eeprom_module_info_id { 9958 MLXSW_REG_MCIA_EEPROM_MODULE_INFO_ID_SFP = 0x03, 9959 MLXSW_REG_MCIA_EEPROM_MODULE_INFO_ID_QSFP = 0x0C, 9960 MLXSW_REG_MCIA_EEPROM_MODULE_INFO_ID_QSFP_PLUS = 0x0D, 9961 MLXSW_REG_MCIA_EEPROM_MODULE_INFO_ID_QSFP28 = 0x11, 9962 MLXSW_REG_MCIA_EEPROM_MODULE_INFO_ID_QSFP_DD = 0x18, 9963 }; 9964 9965 enum mlxsw_reg_mcia_eeprom_module_info { 9966 MLXSW_REG_MCIA_EEPROM_MODULE_INFO_ID, 9967 MLXSW_REG_MCIA_EEPROM_MODULE_INFO_REV_ID, 9968 MLXSW_REG_MCIA_EEPROM_MODULE_INFO_TYPE_ID, 9969 MLXSW_REG_MCIA_EEPROM_MODULE_INFO_SIZE, 9970 }; 9971 9972 /* reg_mcia_eeprom 9973 * Bytes to read/write. 9974 * Access: RW 9975 */ 9976 MLXSW_ITEM_BUF(reg, mcia, eeprom, 0x10, MLXSW_REG_MCIA_EEPROM_SIZE); 9977 9978 /* This is used to access the optional upper pages (1-3) in the QSFP+ 9979 * memory map. Page 1 is available on offset 256 through 383, page 2 - 9980 * on offset 384 through 511, page 3 - on offset 512 through 639. 9981 */ 9982 #define MLXSW_REG_MCIA_PAGE_GET(off) (((off) - \ 9983 MLXSW_REG_MCIA_EEPROM_PAGE_LENGTH) / \ 9984 MLXSW_REG_MCIA_EEPROM_UP_PAGE_LENGTH + 1) 9985 9986 static inline void mlxsw_reg_mcia_pack(char *payload, u8 module, u8 lock, 9987 u8 page_number, u16 device_addr, 9988 u8 size, u8 i2c_device_addr) 9989 { 9990 MLXSW_REG_ZERO(mcia, payload); 9991 mlxsw_reg_mcia_module_set(payload, module); 9992 mlxsw_reg_mcia_l_set(payload, lock); 9993 mlxsw_reg_mcia_page_number_set(payload, page_number); 9994 mlxsw_reg_mcia_device_address_set(payload, device_addr); 9995 mlxsw_reg_mcia_size_set(payload, size); 9996 mlxsw_reg_mcia_i2c_device_address_set(payload, i2c_device_addr); 9997 } 9998 9999 /* MPAT - Monitoring Port Analyzer Table 10000 * ------------------------------------- 10001 * MPAT Register is used to query and configure the Switch PortAnalyzer Table. 10002 * For an enabled analyzer, all fields except e (enable) cannot be modified. 10003 */ 10004 #define MLXSW_REG_MPAT_ID 0x901A 10005 #define MLXSW_REG_MPAT_LEN 0x78 10006 10007 MLXSW_REG_DEFINE(mpat, MLXSW_REG_MPAT_ID, MLXSW_REG_MPAT_LEN); 10008 10009 /* reg_mpat_pa_id 10010 * Port Analyzer ID. 10011 * Access: Index 10012 */ 10013 MLXSW_ITEM32(reg, mpat, pa_id, 0x00, 28, 4); 10014 10015 /* reg_mpat_session_id 10016 * Mirror Session ID. 10017 * Used for MIRROR_SESSION<i> trap. 10018 * Access: RW 10019 */ 10020 MLXSW_ITEM32(reg, mpat, session_id, 0x00, 24, 4); 10021 10022 /* reg_mpat_system_port 10023 * A unique port identifier for the final destination of the packet. 10024 * Access: RW 10025 */ 10026 MLXSW_ITEM32(reg, mpat, system_port, 0x00, 0, 16); 10027 10028 /* reg_mpat_e 10029 * Enable. Indicating the Port Analyzer is enabled. 10030 * Access: RW 10031 */ 10032 MLXSW_ITEM32(reg, mpat, e, 0x04, 31, 1); 10033 10034 /* reg_mpat_qos 10035 * Quality Of Service Mode. 10036 * 0: CONFIGURED - QoS parameters (Switch Priority, and encapsulation 10037 * PCP, DEI, DSCP or VL) are configured. 10038 * 1: MAINTAIN - QoS parameters (Switch Priority, Color) are the 10039 * same as in the original packet that has triggered the mirroring. For 10040 * SPAN also the pcp,dei are maintained. 10041 * Access: RW 10042 */ 10043 MLXSW_ITEM32(reg, mpat, qos, 0x04, 26, 1); 10044 10045 /* reg_mpat_be 10046 * Best effort mode. Indicates mirroring traffic should not cause packet 10047 * drop or back pressure, but will discard the mirrored packets. Mirrored 10048 * packets will be forwarded on a best effort manner. 10049 * 0: Do not discard mirrored packets 10050 * 1: Discard mirrored packets if causing congestion 10051 * Access: RW 10052 */ 10053 MLXSW_ITEM32(reg, mpat, be, 0x04, 25, 1); 10054 10055 enum mlxsw_reg_mpat_span_type { 10056 /* Local SPAN Ethernet. 10057 * The original packet is not encapsulated. 10058 */ 10059 MLXSW_REG_MPAT_SPAN_TYPE_LOCAL_ETH = 0x0, 10060 10061 /* Remote SPAN Ethernet VLAN. 10062 * The packet is forwarded to the monitoring port on the monitoring 10063 * VLAN. 10064 */ 10065 MLXSW_REG_MPAT_SPAN_TYPE_REMOTE_ETH = 0x1, 10066 10067 /* Encapsulated Remote SPAN Ethernet L3 GRE. 10068 * The packet is encapsulated with GRE header. 10069 */ 10070 MLXSW_REG_MPAT_SPAN_TYPE_REMOTE_ETH_L3 = 0x3, 10071 }; 10072 10073 /* reg_mpat_span_type 10074 * SPAN type. 10075 * Access: RW 10076 */ 10077 MLXSW_ITEM32(reg, mpat, span_type, 0x04, 0, 4); 10078 10079 /* reg_mpat_pide 10080 * Policer enable. 10081 * Access: RW 10082 */ 10083 MLXSW_ITEM32(reg, mpat, pide, 0x0C, 15, 1); 10084 10085 /* reg_mpat_pid 10086 * Policer ID. 10087 * Access: RW 10088 */ 10089 MLXSW_ITEM32(reg, mpat, pid, 0x0C, 0, 14); 10090 10091 /* Remote SPAN - Ethernet VLAN 10092 * - - - - - - - - - - - - - - 10093 */ 10094 10095 /* reg_mpat_eth_rspan_vid 10096 * Encapsulation header VLAN ID. 10097 * Access: RW 10098 */ 10099 MLXSW_ITEM32(reg, mpat, eth_rspan_vid, 0x18, 0, 12); 10100 10101 /* Encapsulated Remote SPAN - Ethernet L2 10102 * - - - - - - - - - - - - - - - - - - - 10103 */ 10104 10105 enum mlxsw_reg_mpat_eth_rspan_version { 10106 MLXSW_REG_MPAT_ETH_RSPAN_VERSION_NO_HEADER = 15, 10107 }; 10108 10109 /* reg_mpat_eth_rspan_version 10110 * RSPAN mirror header version. 10111 * Access: RW 10112 */ 10113 MLXSW_ITEM32(reg, mpat, eth_rspan_version, 0x10, 18, 4); 10114 10115 /* reg_mpat_eth_rspan_mac 10116 * Destination MAC address. 10117 * Access: RW 10118 */ 10119 MLXSW_ITEM_BUF(reg, mpat, eth_rspan_mac, 0x12, 6); 10120 10121 /* reg_mpat_eth_rspan_tp 10122 * Tag Packet. Indicates whether the mirroring header should be VLAN tagged. 10123 * Access: RW 10124 */ 10125 MLXSW_ITEM32(reg, mpat, eth_rspan_tp, 0x18, 16, 1); 10126 10127 /* Encapsulated Remote SPAN - Ethernet L3 10128 * - - - - - - - - - - - - - - - - - - - 10129 */ 10130 10131 enum mlxsw_reg_mpat_eth_rspan_protocol { 10132 MLXSW_REG_MPAT_ETH_RSPAN_PROTOCOL_IPV4, 10133 MLXSW_REG_MPAT_ETH_RSPAN_PROTOCOL_IPV6, 10134 }; 10135 10136 /* reg_mpat_eth_rspan_protocol 10137 * SPAN encapsulation protocol. 10138 * Access: RW 10139 */ 10140 MLXSW_ITEM32(reg, mpat, eth_rspan_protocol, 0x18, 24, 4); 10141 10142 /* reg_mpat_eth_rspan_ttl 10143 * Encapsulation header Time-to-Live/HopLimit. 10144 * Access: RW 10145 */ 10146 MLXSW_ITEM32(reg, mpat, eth_rspan_ttl, 0x1C, 4, 8); 10147 10148 /* reg_mpat_eth_rspan_smac 10149 * Source MAC address 10150 * Access: RW 10151 */ 10152 MLXSW_ITEM_BUF(reg, mpat, eth_rspan_smac, 0x22, 6); 10153 10154 /* reg_mpat_eth_rspan_dip* 10155 * Destination IP address. The IP version is configured by protocol. 10156 * Access: RW 10157 */ 10158 MLXSW_ITEM32(reg, mpat, eth_rspan_dip4, 0x4C, 0, 32); 10159 MLXSW_ITEM_BUF(reg, mpat, eth_rspan_dip6, 0x40, 16); 10160 10161 /* reg_mpat_eth_rspan_sip* 10162 * Source IP address. The IP version is configured by protocol. 10163 * Access: RW 10164 */ 10165 MLXSW_ITEM32(reg, mpat, eth_rspan_sip4, 0x5C, 0, 32); 10166 MLXSW_ITEM_BUF(reg, mpat, eth_rspan_sip6, 0x50, 16); 10167 10168 static inline void mlxsw_reg_mpat_pack(char *payload, u8 pa_id, 10169 u16 system_port, bool e, 10170 enum mlxsw_reg_mpat_span_type span_type) 10171 { 10172 MLXSW_REG_ZERO(mpat, payload); 10173 mlxsw_reg_mpat_pa_id_set(payload, pa_id); 10174 mlxsw_reg_mpat_system_port_set(payload, system_port); 10175 mlxsw_reg_mpat_e_set(payload, e); 10176 mlxsw_reg_mpat_qos_set(payload, 1); 10177 mlxsw_reg_mpat_be_set(payload, 1); 10178 mlxsw_reg_mpat_span_type_set(payload, span_type); 10179 } 10180 10181 static inline void mlxsw_reg_mpat_eth_rspan_pack(char *payload, u16 vid) 10182 { 10183 mlxsw_reg_mpat_eth_rspan_vid_set(payload, vid); 10184 } 10185 10186 static inline void 10187 mlxsw_reg_mpat_eth_rspan_l2_pack(char *payload, 10188 enum mlxsw_reg_mpat_eth_rspan_version version, 10189 const char *mac, 10190 bool tp) 10191 { 10192 mlxsw_reg_mpat_eth_rspan_version_set(payload, version); 10193 mlxsw_reg_mpat_eth_rspan_mac_memcpy_to(payload, mac); 10194 mlxsw_reg_mpat_eth_rspan_tp_set(payload, tp); 10195 } 10196 10197 static inline void 10198 mlxsw_reg_mpat_eth_rspan_l3_ipv4_pack(char *payload, u8 ttl, 10199 const char *smac, 10200 u32 sip, u32 dip) 10201 { 10202 mlxsw_reg_mpat_eth_rspan_ttl_set(payload, ttl); 10203 mlxsw_reg_mpat_eth_rspan_smac_memcpy_to(payload, smac); 10204 mlxsw_reg_mpat_eth_rspan_protocol_set(payload, 10205 MLXSW_REG_MPAT_ETH_RSPAN_PROTOCOL_IPV4); 10206 mlxsw_reg_mpat_eth_rspan_sip4_set(payload, sip); 10207 mlxsw_reg_mpat_eth_rspan_dip4_set(payload, dip); 10208 } 10209 10210 static inline void 10211 mlxsw_reg_mpat_eth_rspan_l3_ipv6_pack(char *payload, u8 ttl, 10212 const char *smac, 10213 struct in6_addr sip, struct in6_addr dip) 10214 { 10215 mlxsw_reg_mpat_eth_rspan_ttl_set(payload, ttl); 10216 mlxsw_reg_mpat_eth_rspan_smac_memcpy_to(payload, smac); 10217 mlxsw_reg_mpat_eth_rspan_protocol_set(payload, 10218 MLXSW_REG_MPAT_ETH_RSPAN_PROTOCOL_IPV6); 10219 mlxsw_reg_mpat_eth_rspan_sip6_memcpy_to(payload, (void *)&sip); 10220 mlxsw_reg_mpat_eth_rspan_dip6_memcpy_to(payload, (void *)&dip); 10221 } 10222 10223 /* MPAR - Monitoring Port Analyzer Register 10224 * ---------------------------------------- 10225 * MPAR register is used to query and configure the port analyzer port mirroring 10226 * properties. 10227 */ 10228 #define MLXSW_REG_MPAR_ID 0x901B 10229 #define MLXSW_REG_MPAR_LEN 0x0C 10230 10231 MLXSW_REG_DEFINE(mpar, MLXSW_REG_MPAR_ID, MLXSW_REG_MPAR_LEN); 10232 10233 /* reg_mpar_local_port 10234 * The local port to mirror the packets from. 10235 * Access: Index 10236 */ 10237 MLXSW_ITEM32_LP(reg, mpar, 0x00, 16, 0x00, 4); 10238 10239 enum mlxsw_reg_mpar_i_e { 10240 MLXSW_REG_MPAR_TYPE_EGRESS, 10241 MLXSW_REG_MPAR_TYPE_INGRESS, 10242 }; 10243 10244 /* reg_mpar_i_e 10245 * Ingress/Egress 10246 * Access: Index 10247 */ 10248 MLXSW_ITEM32(reg, mpar, i_e, 0x00, 0, 4); 10249 10250 /* reg_mpar_enable 10251 * Enable mirroring 10252 * By default, port mirroring is disabled for all ports. 10253 * Access: RW 10254 */ 10255 MLXSW_ITEM32(reg, mpar, enable, 0x04, 31, 1); 10256 10257 /* reg_mpar_pa_id 10258 * Port Analyzer ID. 10259 * Access: RW 10260 */ 10261 MLXSW_ITEM32(reg, mpar, pa_id, 0x04, 0, 4); 10262 10263 #define MLXSW_REG_MPAR_RATE_MAX 3500000000UL 10264 10265 /* reg_mpar_probability_rate 10266 * Sampling rate. 10267 * Valid values are: 1 to 3.5*10^9 10268 * Value of 1 means "sample all". Default is 1. 10269 * Reserved when Spectrum-1. 10270 * Access: RW 10271 */ 10272 MLXSW_ITEM32(reg, mpar, probability_rate, 0x08, 0, 32); 10273 10274 static inline void mlxsw_reg_mpar_pack(char *payload, u16 local_port, 10275 enum mlxsw_reg_mpar_i_e i_e, 10276 bool enable, u8 pa_id, 10277 u32 probability_rate) 10278 { 10279 MLXSW_REG_ZERO(mpar, payload); 10280 mlxsw_reg_mpar_local_port_set(payload, local_port); 10281 mlxsw_reg_mpar_enable_set(payload, enable); 10282 mlxsw_reg_mpar_i_e_set(payload, i_e); 10283 mlxsw_reg_mpar_pa_id_set(payload, pa_id); 10284 mlxsw_reg_mpar_probability_rate_set(payload, probability_rate); 10285 } 10286 10287 /* MGIR - Management General Information Register 10288 * ---------------------------------------------- 10289 * MGIR register allows software to query the hardware and firmware general 10290 * information. 10291 */ 10292 #define MLXSW_REG_MGIR_ID 0x9020 10293 #define MLXSW_REG_MGIR_LEN 0x9C 10294 10295 MLXSW_REG_DEFINE(mgir, MLXSW_REG_MGIR_ID, MLXSW_REG_MGIR_LEN); 10296 10297 /* reg_mgir_hw_info_device_hw_revision 10298 * Access: RO 10299 */ 10300 MLXSW_ITEM32(reg, mgir, hw_info_device_hw_revision, 0x0, 16, 16); 10301 10302 #define MLXSW_REG_MGIR_FW_INFO_PSID_SIZE 16 10303 10304 /* reg_mgir_fw_info_psid 10305 * PSID (ASCII string). 10306 * Access: RO 10307 */ 10308 MLXSW_ITEM_BUF(reg, mgir, fw_info_psid, 0x30, MLXSW_REG_MGIR_FW_INFO_PSID_SIZE); 10309 10310 /* reg_mgir_fw_info_extended_major 10311 * Access: RO 10312 */ 10313 MLXSW_ITEM32(reg, mgir, fw_info_extended_major, 0x44, 0, 32); 10314 10315 /* reg_mgir_fw_info_extended_minor 10316 * Access: RO 10317 */ 10318 MLXSW_ITEM32(reg, mgir, fw_info_extended_minor, 0x48, 0, 32); 10319 10320 /* reg_mgir_fw_info_extended_sub_minor 10321 * Access: RO 10322 */ 10323 MLXSW_ITEM32(reg, mgir, fw_info_extended_sub_minor, 0x4C, 0, 32); 10324 10325 static inline void mlxsw_reg_mgir_pack(char *payload) 10326 { 10327 MLXSW_REG_ZERO(mgir, payload); 10328 } 10329 10330 static inline void 10331 mlxsw_reg_mgir_unpack(char *payload, u32 *hw_rev, char *fw_info_psid, 10332 u32 *fw_major, u32 *fw_minor, u32 *fw_sub_minor) 10333 { 10334 *hw_rev = mlxsw_reg_mgir_hw_info_device_hw_revision_get(payload); 10335 mlxsw_reg_mgir_fw_info_psid_memcpy_from(payload, fw_info_psid); 10336 *fw_major = mlxsw_reg_mgir_fw_info_extended_major_get(payload); 10337 *fw_minor = mlxsw_reg_mgir_fw_info_extended_minor_get(payload); 10338 *fw_sub_minor = mlxsw_reg_mgir_fw_info_extended_sub_minor_get(payload); 10339 } 10340 10341 /* MRSR - Management Reset and Shutdown Register 10342 * --------------------------------------------- 10343 * MRSR register is used to reset or shutdown the switch or 10344 * the entire system (when applicable). 10345 */ 10346 #define MLXSW_REG_MRSR_ID 0x9023 10347 #define MLXSW_REG_MRSR_LEN 0x08 10348 10349 MLXSW_REG_DEFINE(mrsr, MLXSW_REG_MRSR_ID, MLXSW_REG_MRSR_LEN); 10350 10351 /* reg_mrsr_command 10352 * Reset/shutdown command 10353 * 0 - do nothing 10354 * 1 - software reset 10355 * Access: WO 10356 */ 10357 MLXSW_ITEM32(reg, mrsr, command, 0x00, 0, 4); 10358 10359 static inline void mlxsw_reg_mrsr_pack(char *payload) 10360 { 10361 MLXSW_REG_ZERO(mrsr, payload); 10362 mlxsw_reg_mrsr_command_set(payload, 1); 10363 } 10364 10365 /* MLCR - Management LED Control Register 10366 * -------------------------------------- 10367 * Controls the system LEDs. 10368 */ 10369 #define MLXSW_REG_MLCR_ID 0x902B 10370 #define MLXSW_REG_MLCR_LEN 0x0C 10371 10372 MLXSW_REG_DEFINE(mlcr, MLXSW_REG_MLCR_ID, MLXSW_REG_MLCR_LEN); 10373 10374 /* reg_mlcr_local_port 10375 * Local port number. 10376 * Access: RW 10377 */ 10378 MLXSW_ITEM32_LP(reg, mlcr, 0x00, 16, 0x00, 24); 10379 10380 #define MLXSW_REG_MLCR_DURATION_MAX 0xFFFF 10381 10382 /* reg_mlcr_beacon_duration 10383 * Duration of the beacon to be active, in seconds. 10384 * 0x0 - Will turn off the beacon. 10385 * 0xFFFF - Will turn on the beacon until explicitly turned off. 10386 * Access: RW 10387 */ 10388 MLXSW_ITEM32(reg, mlcr, beacon_duration, 0x04, 0, 16); 10389 10390 /* reg_mlcr_beacon_remain 10391 * Remaining duration of the beacon, in seconds. 10392 * 0xFFFF indicates an infinite amount of time. 10393 * Access: RO 10394 */ 10395 MLXSW_ITEM32(reg, mlcr, beacon_remain, 0x08, 0, 16); 10396 10397 static inline void mlxsw_reg_mlcr_pack(char *payload, u16 local_port, 10398 bool active) 10399 { 10400 MLXSW_REG_ZERO(mlcr, payload); 10401 mlxsw_reg_mlcr_local_port_set(payload, local_port); 10402 mlxsw_reg_mlcr_beacon_duration_set(payload, active ? 10403 MLXSW_REG_MLCR_DURATION_MAX : 0); 10404 } 10405 10406 /* MCION - Management Cable IO and Notifications Register 10407 * ------------------------------------------------------ 10408 * The MCION register is used to query transceiver modules' IO pins and other 10409 * notifications. 10410 */ 10411 #define MLXSW_REG_MCION_ID 0x9052 10412 #define MLXSW_REG_MCION_LEN 0x18 10413 10414 MLXSW_REG_DEFINE(mcion, MLXSW_REG_MCION_ID, MLXSW_REG_MCION_LEN); 10415 10416 /* reg_mcion_module 10417 * Module number. 10418 * Access: Index 10419 */ 10420 MLXSW_ITEM32(reg, mcion, module, 0x00, 16, 8); 10421 10422 enum { 10423 MLXSW_REG_MCION_MODULE_STATUS_BITS_PRESENT_MASK = BIT(0), 10424 MLXSW_REG_MCION_MODULE_STATUS_BITS_LOW_POWER_MASK = BIT(8), 10425 }; 10426 10427 /* reg_mcion_module_status_bits 10428 * Module IO status as defined by SFF. 10429 * Access: RO 10430 */ 10431 MLXSW_ITEM32(reg, mcion, module_status_bits, 0x04, 0, 16); 10432 10433 static inline void mlxsw_reg_mcion_pack(char *payload, u8 module) 10434 { 10435 MLXSW_REG_ZERO(mcion, payload); 10436 mlxsw_reg_mcion_module_set(payload, module); 10437 } 10438 10439 /* MTPPS - Management Pulse Per Second Register 10440 * -------------------------------------------- 10441 * This register provides the device PPS capabilities, configure the PPS in and 10442 * out modules and holds the PPS in time stamp. 10443 */ 10444 #define MLXSW_REG_MTPPS_ID 0x9053 10445 #define MLXSW_REG_MTPPS_LEN 0x3C 10446 10447 MLXSW_REG_DEFINE(mtpps, MLXSW_REG_MTPPS_ID, MLXSW_REG_MTPPS_LEN); 10448 10449 /* reg_mtpps_enable 10450 * Enables the PPS functionality the specific pin. 10451 * A boolean variable. 10452 * Access: RW 10453 */ 10454 MLXSW_ITEM32(reg, mtpps, enable, 0x20, 31, 1); 10455 10456 enum mlxsw_reg_mtpps_pin_mode { 10457 MLXSW_REG_MTPPS_PIN_MODE_VIRTUAL_PIN = 0x2, 10458 }; 10459 10460 /* reg_mtpps_pin_mode 10461 * Pin mode to be used. The mode must comply with the supported modes of the 10462 * requested pin. 10463 * Access: RW 10464 */ 10465 MLXSW_ITEM32(reg, mtpps, pin_mode, 0x20, 8, 4); 10466 10467 #define MLXSW_REG_MTPPS_PIN_SP_VIRTUAL_PIN 7 10468 10469 /* reg_mtpps_pin 10470 * Pin to be configured or queried out of the supported pins. 10471 * Access: Index 10472 */ 10473 MLXSW_ITEM32(reg, mtpps, pin, 0x20, 0, 8); 10474 10475 /* reg_mtpps_time_stamp 10476 * When pin_mode = pps_in, the latched device time when it was triggered from 10477 * the external GPIO pin. 10478 * When pin_mode = pps_out or virtual_pin or pps_out_and_virtual_pin, the target 10479 * time to generate next output signal. 10480 * Time is in units of device clock. 10481 * Access: RW 10482 */ 10483 MLXSW_ITEM64(reg, mtpps, time_stamp, 0x28, 0, 64); 10484 10485 static inline void 10486 mlxsw_reg_mtpps_vpin_pack(char *payload, u64 time_stamp) 10487 { 10488 MLXSW_REG_ZERO(mtpps, payload); 10489 mlxsw_reg_mtpps_pin_set(payload, MLXSW_REG_MTPPS_PIN_SP_VIRTUAL_PIN); 10490 mlxsw_reg_mtpps_pin_mode_set(payload, 10491 MLXSW_REG_MTPPS_PIN_MODE_VIRTUAL_PIN); 10492 mlxsw_reg_mtpps_enable_set(payload, true); 10493 mlxsw_reg_mtpps_time_stamp_set(payload, time_stamp); 10494 } 10495 10496 /* MTUTC - Management UTC Register 10497 * ------------------------------- 10498 * Configures the HW UTC counter. 10499 */ 10500 #define MLXSW_REG_MTUTC_ID 0x9055 10501 #define MLXSW_REG_MTUTC_LEN 0x1C 10502 10503 MLXSW_REG_DEFINE(mtutc, MLXSW_REG_MTUTC_ID, MLXSW_REG_MTUTC_LEN); 10504 10505 enum mlxsw_reg_mtutc_operation { 10506 MLXSW_REG_MTUTC_OPERATION_SET_TIME_AT_NEXT_SEC = 0, 10507 MLXSW_REG_MTUTC_OPERATION_ADJUST_FREQ = 3, 10508 }; 10509 10510 /* reg_mtutc_operation 10511 * Operation. 10512 * Access: OP 10513 */ 10514 MLXSW_ITEM32(reg, mtutc, operation, 0x00, 0, 4); 10515 10516 /* reg_mtutc_freq_adjustment 10517 * Frequency adjustment: Every PPS the HW frequency will be 10518 * adjusted by this value. Units of HW clock, where HW counts 10519 * 10^9 HW clocks for 1 HW second. 10520 * Access: RW 10521 */ 10522 MLXSW_ITEM32(reg, mtutc, freq_adjustment, 0x04, 0, 32); 10523 10524 /* reg_mtutc_utc_sec 10525 * UTC seconds. 10526 * Access: WO 10527 */ 10528 MLXSW_ITEM32(reg, mtutc, utc_sec, 0x10, 0, 32); 10529 10530 static inline void 10531 mlxsw_reg_mtutc_pack(char *payload, enum mlxsw_reg_mtutc_operation oper, 10532 u32 freq_adj, u32 utc_sec) 10533 { 10534 MLXSW_REG_ZERO(mtutc, payload); 10535 mlxsw_reg_mtutc_operation_set(payload, oper); 10536 mlxsw_reg_mtutc_freq_adjustment_set(payload, freq_adj); 10537 mlxsw_reg_mtutc_utc_sec_set(payload, utc_sec); 10538 } 10539 10540 /* MCQI - Management Component Query Information 10541 * --------------------------------------------- 10542 * This register allows querying information about firmware components. 10543 */ 10544 #define MLXSW_REG_MCQI_ID 0x9061 10545 #define MLXSW_REG_MCQI_BASE_LEN 0x18 10546 #define MLXSW_REG_MCQI_CAP_LEN 0x14 10547 #define MLXSW_REG_MCQI_LEN (MLXSW_REG_MCQI_BASE_LEN + MLXSW_REG_MCQI_CAP_LEN) 10548 10549 MLXSW_REG_DEFINE(mcqi, MLXSW_REG_MCQI_ID, MLXSW_REG_MCQI_LEN); 10550 10551 /* reg_mcqi_component_index 10552 * Index of the accessed component. 10553 * Access: Index 10554 */ 10555 MLXSW_ITEM32(reg, mcqi, component_index, 0x00, 0, 16); 10556 10557 enum mlxfw_reg_mcqi_info_type { 10558 MLXSW_REG_MCQI_INFO_TYPE_CAPABILITIES, 10559 }; 10560 10561 /* reg_mcqi_info_type 10562 * Component properties set. 10563 * Access: RW 10564 */ 10565 MLXSW_ITEM32(reg, mcqi, info_type, 0x08, 0, 5); 10566 10567 /* reg_mcqi_offset 10568 * The requested/returned data offset from the section start, given in bytes. 10569 * Must be DWORD aligned. 10570 * Access: RW 10571 */ 10572 MLXSW_ITEM32(reg, mcqi, offset, 0x10, 0, 32); 10573 10574 /* reg_mcqi_data_size 10575 * The requested/returned data size, given in bytes. If data_size is not DWORD 10576 * aligned, the last bytes are zero padded. 10577 * Access: RW 10578 */ 10579 MLXSW_ITEM32(reg, mcqi, data_size, 0x14, 0, 16); 10580 10581 /* reg_mcqi_cap_max_component_size 10582 * Maximum size for this component, given in bytes. 10583 * Access: RO 10584 */ 10585 MLXSW_ITEM32(reg, mcqi, cap_max_component_size, 0x20, 0, 32); 10586 10587 /* reg_mcqi_cap_log_mcda_word_size 10588 * Log 2 of the access word size in bytes. Read and write access must be aligned 10589 * to the word size. Write access must be done for an integer number of words. 10590 * Access: RO 10591 */ 10592 MLXSW_ITEM32(reg, mcqi, cap_log_mcda_word_size, 0x24, 28, 4); 10593 10594 /* reg_mcqi_cap_mcda_max_write_size 10595 * Maximal write size for MCDA register 10596 * Access: RO 10597 */ 10598 MLXSW_ITEM32(reg, mcqi, cap_mcda_max_write_size, 0x24, 0, 16); 10599 10600 static inline void mlxsw_reg_mcqi_pack(char *payload, u16 component_index) 10601 { 10602 MLXSW_REG_ZERO(mcqi, payload); 10603 mlxsw_reg_mcqi_component_index_set(payload, component_index); 10604 mlxsw_reg_mcqi_info_type_set(payload, 10605 MLXSW_REG_MCQI_INFO_TYPE_CAPABILITIES); 10606 mlxsw_reg_mcqi_offset_set(payload, 0); 10607 mlxsw_reg_mcqi_data_size_set(payload, MLXSW_REG_MCQI_CAP_LEN); 10608 } 10609 10610 static inline void mlxsw_reg_mcqi_unpack(char *payload, 10611 u32 *p_cap_max_component_size, 10612 u8 *p_cap_log_mcda_word_size, 10613 u16 *p_cap_mcda_max_write_size) 10614 { 10615 *p_cap_max_component_size = 10616 mlxsw_reg_mcqi_cap_max_component_size_get(payload); 10617 *p_cap_log_mcda_word_size = 10618 mlxsw_reg_mcqi_cap_log_mcda_word_size_get(payload); 10619 *p_cap_mcda_max_write_size = 10620 mlxsw_reg_mcqi_cap_mcda_max_write_size_get(payload); 10621 } 10622 10623 /* MCC - Management Component Control 10624 * ---------------------------------- 10625 * Controls the firmware component and updates the FSM. 10626 */ 10627 #define MLXSW_REG_MCC_ID 0x9062 10628 #define MLXSW_REG_MCC_LEN 0x1C 10629 10630 MLXSW_REG_DEFINE(mcc, MLXSW_REG_MCC_ID, MLXSW_REG_MCC_LEN); 10631 10632 enum mlxsw_reg_mcc_instruction { 10633 MLXSW_REG_MCC_INSTRUCTION_LOCK_UPDATE_HANDLE = 0x01, 10634 MLXSW_REG_MCC_INSTRUCTION_RELEASE_UPDATE_HANDLE = 0x02, 10635 MLXSW_REG_MCC_INSTRUCTION_UPDATE_COMPONENT = 0x03, 10636 MLXSW_REG_MCC_INSTRUCTION_VERIFY_COMPONENT = 0x04, 10637 MLXSW_REG_MCC_INSTRUCTION_ACTIVATE = 0x06, 10638 MLXSW_REG_MCC_INSTRUCTION_CANCEL = 0x08, 10639 }; 10640 10641 /* reg_mcc_instruction 10642 * Command to be executed by the FSM. 10643 * Applicable for write operation only. 10644 * Access: RW 10645 */ 10646 MLXSW_ITEM32(reg, mcc, instruction, 0x00, 0, 8); 10647 10648 /* reg_mcc_component_index 10649 * Index of the accessed component. Applicable only for commands that 10650 * refer to components. Otherwise, this field is reserved. 10651 * Access: Index 10652 */ 10653 MLXSW_ITEM32(reg, mcc, component_index, 0x04, 0, 16); 10654 10655 /* reg_mcc_update_handle 10656 * Token representing the current flow executed by the FSM. 10657 * Access: WO 10658 */ 10659 MLXSW_ITEM32(reg, mcc, update_handle, 0x08, 0, 24); 10660 10661 /* reg_mcc_error_code 10662 * Indicates the successful completion of the instruction, or the reason it 10663 * failed 10664 * Access: RO 10665 */ 10666 MLXSW_ITEM32(reg, mcc, error_code, 0x0C, 8, 8); 10667 10668 /* reg_mcc_control_state 10669 * Current FSM state 10670 * Access: RO 10671 */ 10672 MLXSW_ITEM32(reg, mcc, control_state, 0x0C, 0, 4); 10673 10674 /* reg_mcc_component_size 10675 * Component size in bytes. Valid for UPDATE_COMPONENT instruction. Specifying 10676 * the size may shorten the update time. Value 0x0 means that size is 10677 * unspecified. 10678 * Access: WO 10679 */ 10680 MLXSW_ITEM32(reg, mcc, component_size, 0x10, 0, 32); 10681 10682 static inline void mlxsw_reg_mcc_pack(char *payload, 10683 enum mlxsw_reg_mcc_instruction instr, 10684 u16 component_index, u32 update_handle, 10685 u32 component_size) 10686 { 10687 MLXSW_REG_ZERO(mcc, payload); 10688 mlxsw_reg_mcc_instruction_set(payload, instr); 10689 mlxsw_reg_mcc_component_index_set(payload, component_index); 10690 mlxsw_reg_mcc_update_handle_set(payload, update_handle); 10691 mlxsw_reg_mcc_component_size_set(payload, component_size); 10692 } 10693 10694 static inline void mlxsw_reg_mcc_unpack(char *payload, u32 *p_update_handle, 10695 u8 *p_error_code, u8 *p_control_state) 10696 { 10697 if (p_update_handle) 10698 *p_update_handle = mlxsw_reg_mcc_update_handle_get(payload); 10699 if (p_error_code) 10700 *p_error_code = mlxsw_reg_mcc_error_code_get(payload); 10701 if (p_control_state) 10702 *p_control_state = mlxsw_reg_mcc_control_state_get(payload); 10703 } 10704 10705 /* MCDA - Management Component Data Access 10706 * --------------------------------------- 10707 * This register allows reading and writing a firmware component. 10708 */ 10709 #define MLXSW_REG_MCDA_ID 0x9063 10710 #define MLXSW_REG_MCDA_BASE_LEN 0x10 10711 #define MLXSW_REG_MCDA_MAX_DATA_LEN 0x80 10712 #define MLXSW_REG_MCDA_LEN \ 10713 (MLXSW_REG_MCDA_BASE_LEN + MLXSW_REG_MCDA_MAX_DATA_LEN) 10714 10715 MLXSW_REG_DEFINE(mcda, MLXSW_REG_MCDA_ID, MLXSW_REG_MCDA_LEN); 10716 10717 /* reg_mcda_update_handle 10718 * Token representing the current flow executed by the FSM. 10719 * Access: RW 10720 */ 10721 MLXSW_ITEM32(reg, mcda, update_handle, 0x00, 0, 24); 10722 10723 /* reg_mcda_offset 10724 * Offset of accessed address relative to component start. Accesses must be in 10725 * accordance to log_mcda_word_size in MCQI reg. 10726 * Access: RW 10727 */ 10728 MLXSW_ITEM32(reg, mcda, offset, 0x04, 0, 32); 10729 10730 /* reg_mcda_size 10731 * Size of the data accessed, given in bytes. 10732 * Access: RW 10733 */ 10734 MLXSW_ITEM32(reg, mcda, size, 0x08, 0, 16); 10735 10736 /* reg_mcda_data 10737 * Data block accessed. 10738 * Access: RW 10739 */ 10740 MLXSW_ITEM32_INDEXED(reg, mcda, data, 0x10, 0, 32, 4, 0, false); 10741 10742 static inline void mlxsw_reg_mcda_pack(char *payload, u32 update_handle, 10743 u32 offset, u16 size, u8 *data) 10744 { 10745 int i; 10746 10747 MLXSW_REG_ZERO(mcda, payload); 10748 mlxsw_reg_mcda_update_handle_set(payload, update_handle); 10749 mlxsw_reg_mcda_offset_set(payload, offset); 10750 mlxsw_reg_mcda_size_set(payload, size); 10751 10752 for (i = 0; i < size / 4; i++) 10753 mlxsw_reg_mcda_data_set(payload, i, *(u32 *) &data[i * 4]); 10754 } 10755 10756 /* MPSC - Monitoring Packet Sampling Configuration Register 10757 * -------------------------------------------------------- 10758 * MPSC Register is used to configure the Packet Sampling mechanism. 10759 */ 10760 #define MLXSW_REG_MPSC_ID 0x9080 10761 #define MLXSW_REG_MPSC_LEN 0x1C 10762 10763 MLXSW_REG_DEFINE(mpsc, MLXSW_REG_MPSC_ID, MLXSW_REG_MPSC_LEN); 10764 10765 /* reg_mpsc_local_port 10766 * Local port number 10767 * Not supported for CPU port 10768 * Access: Index 10769 */ 10770 MLXSW_ITEM32_LP(reg, mpsc, 0x00, 16, 0x00, 12); 10771 10772 /* reg_mpsc_e 10773 * Enable sampling on port local_port 10774 * Access: RW 10775 */ 10776 MLXSW_ITEM32(reg, mpsc, e, 0x04, 30, 1); 10777 10778 #define MLXSW_REG_MPSC_RATE_MAX 3500000000UL 10779 10780 /* reg_mpsc_rate 10781 * Sampling rate = 1 out of rate packets (with randomization around 10782 * the point). Valid values are: 1 to MLXSW_REG_MPSC_RATE_MAX 10783 * Access: RW 10784 */ 10785 MLXSW_ITEM32(reg, mpsc, rate, 0x08, 0, 32); 10786 10787 static inline void mlxsw_reg_mpsc_pack(char *payload, u16 local_port, bool e, 10788 u32 rate) 10789 { 10790 MLXSW_REG_ZERO(mpsc, payload); 10791 mlxsw_reg_mpsc_local_port_set(payload, local_port); 10792 mlxsw_reg_mpsc_e_set(payload, e); 10793 mlxsw_reg_mpsc_rate_set(payload, rate); 10794 } 10795 10796 /* MGPC - Monitoring General Purpose Counter Set Register 10797 * The MGPC register retrieves and sets the General Purpose Counter Set. 10798 */ 10799 #define MLXSW_REG_MGPC_ID 0x9081 10800 #define MLXSW_REG_MGPC_LEN 0x18 10801 10802 MLXSW_REG_DEFINE(mgpc, MLXSW_REG_MGPC_ID, MLXSW_REG_MGPC_LEN); 10803 10804 /* reg_mgpc_counter_set_type 10805 * Counter set type. 10806 * Access: OP 10807 */ 10808 MLXSW_ITEM32(reg, mgpc, counter_set_type, 0x00, 24, 8); 10809 10810 /* reg_mgpc_counter_index 10811 * Counter index. 10812 * Access: Index 10813 */ 10814 MLXSW_ITEM32(reg, mgpc, counter_index, 0x00, 0, 24); 10815 10816 enum mlxsw_reg_mgpc_opcode { 10817 /* Nop */ 10818 MLXSW_REG_MGPC_OPCODE_NOP = 0x00, 10819 /* Clear counters */ 10820 MLXSW_REG_MGPC_OPCODE_CLEAR = 0x08, 10821 }; 10822 10823 /* reg_mgpc_opcode 10824 * Opcode. 10825 * Access: OP 10826 */ 10827 MLXSW_ITEM32(reg, mgpc, opcode, 0x04, 28, 4); 10828 10829 /* reg_mgpc_byte_counter 10830 * Byte counter value. 10831 * Access: RW 10832 */ 10833 MLXSW_ITEM64(reg, mgpc, byte_counter, 0x08, 0, 64); 10834 10835 /* reg_mgpc_packet_counter 10836 * Packet counter value. 10837 * Access: RW 10838 */ 10839 MLXSW_ITEM64(reg, mgpc, packet_counter, 0x10, 0, 64); 10840 10841 static inline void mlxsw_reg_mgpc_pack(char *payload, u32 counter_index, 10842 enum mlxsw_reg_mgpc_opcode opcode, 10843 enum mlxsw_reg_flow_counter_set_type set_type) 10844 { 10845 MLXSW_REG_ZERO(mgpc, payload); 10846 mlxsw_reg_mgpc_counter_index_set(payload, counter_index); 10847 mlxsw_reg_mgpc_counter_set_type_set(payload, set_type); 10848 mlxsw_reg_mgpc_opcode_set(payload, opcode); 10849 } 10850 10851 /* MPRS - Monitoring Parsing State Register 10852 * ---------------------------------------- 10853 * The MPRS register is used for setting up the parsing for hash, 10854 * policy-engine and routing. 10855 */ 10856 #define MLXSW_REG_MPRS_ID 0x9083 10857 #define MLXSW_REG_MPRS_LEN 0x14 10858 10859 MLXSW_REG_DEFINE(mprs, MLXSW_REG_MPRS_ID, MLXSW_REG_MPRS_LEN); 10860 10861 /* reg_mprs_parsing_depth 10862 * Minimum parsing depth. 10863 * Need to enlarge parsing depth according to L3, MPLS, tunnels, ACL 10864 * rules, traps, hash, etc. Default is 96 bytes. Reserved when SwitchX-2. 10865 * Access: RW 10866 */ 10867 MLXSW_ITEM32(reg, mprs, parsing_depth, 0x00, 0, 16); 10868 10869 /* reg_mprs_parsing_en 10870 * Parsing enable. 10871 * Bit 0 - Enable parsing of NVE of types VxLAN, VxLAN-GPE, GENEVE and 10872 * NVGRE. Default is enabled. Reserved when SwitchX-2. 10873 * Access: RW 10874 */ 10875 MLXSW_ITEM32(reg, mprs, parsing_en, 0x04, 0, 16); 10876 10877 /* reg_mprs_vxlan_udp_dport 10878 * VxLAN UDP destination port. 10879 * Used for identifying VxLAN packets and for dport field in 10880 * encapsulation. Default is 4789. 10881 * Access: RW 10882 */ 10883 MLXSW_ITEM32(reg, mprs, vxlan_udp_dport, 0x10, 0, 16); 10884 10885 static inline void mlxsw_reg_mprs_pack(char *payload, u16 parsing_depth, 10886 u16 vxlan_udp_dport) 10887 { 10888 MLXSW_REG_ZERO(mprs, payload); 10889 mlxsw_reg_mprs_parsing_depth_set(payload, parsing_depth); 10890 mlxsw_reg_mprs_parsing_en_set(payload, true); 10891 mlxsw_reg_mprs_vxlan_udp_dport_set(payload, vxlan_udp_dport); 10892 } 10893 10894 /* MOGCR - Monitoring Global Configuration Register 10895 * ------------------------------------------------ 10896 */ 10897 #define MLXSW_REG_MOGCR_ID 0x9086 10898 #define MLXSW_REG_MOGCR_LEN 0x20 10899 10900 MLXSW_REG_DEFINE(mogcr, MLXSW_REG_MOGCR_ID, MLXSW_REG_MOGCR_LEN); 10901 10902 /* reg_mogcr_ptp_iftc 10903 * PTP Ingress FIFO Trap Clear 10904 * The PTP_ING_FIFO trap provides MTPPTR with clr according 10905 * to this value. Default 0. 10906 * Reserved when IB switches and when SwitchX/-2, Spectrum-2 10907 * Access: RW 10908 */ 10909 MLXSW_ITEM32(reg, mogcr, ptp_iftc, 0x00, 1, 1); 10910 10911 /* reg_mogcr_ptp_eftc 10912 * PTP Egress FIFO Trap Clear 10913 * The PTP_EGR_FIFO trap provides MTPPTR with clr according 10914 * to this value. Default 0. 10915 * Reserved when IB switches and when SwitchX/-2, Spectrum-2 10916 * Access: RW 10917 */ 10918 MLXSW_ITEM32(reg, mogcr, ptp_eftc, 0x00, 0, 1); 10919 10920 /* reg_mogcr_mirroring_pid_base 10921 * Base policer id for mirroring policers. 10922 * Must have an even value (e.g. 1000, not 1001). 10923 * Reserved when SwitchX/-2, Switch-IB/2, Spectrum-1 and Quantum. 10924 * Access: RW 10925 */ 10926 MLXSW_ITEM32(reg, mogcr, mirroring_pid_base, 0x0C, 0, 14); 10927 10928 /* MPAGR - Monitoring Port Analyzer Global Register 10929 * ------------------------------------------------ 10930 * This register is used for global port analyzer configurations. 10931 * Note: This register is not supported by current FW versions for Spectrum-1. 10932 */ 10933 #define MLXSW_REG_MPAGR_ID 0x9089 10934 #define MLXSW_REG_MPAGR_LEN 0x0C 10935 10936 MLXSW_REG_DEFINE(mpagr, MLXSW_REG_MPAGR_ID, MLXSW_REG_MPAGR_LEN); 10937 10938 enum mlxsw_reg_mpagr_trigger { 10939 MLXSW_REG_MPAGR_TRIGGER_EGRESS, 10940 MLXSW_REG_MPAGR_TRIGGER_INGRESS, 10941 MLXSW_REG_MPAGR_TRIGGER_INGRESS_WRED, 10942 MLXSW_REG_MPAGR_TRIGGER_INGRESS_SHARED_BUFFER, 10943 MLXSW_REG_MPAGR_TRIGGER_INGRESS_ING_CONG, 10944 MLXSW_REG_MPAGR_TRIGGER_INGRESS_EGR_CONG, 10945 MLXSW_REG_MPAGR_TRIGGER_EGRESS_ECN, 10946 MLXSW_REG_MPAGR_TRIGGER_EGRESS_HIGH_LATENCY, 10947 }; 10948 10949 /* reg_mpagr_trigger 10950 * Mirror trigger. 10951 * Access: Index 10952 */ 10953 MLXSW_ITEM32(reg, mpagr, trigger, 0x00, 0, 4); 10954 10955 /* reg_mpagr_pa_id 10956 * Port analyzer ID. 10957 * Access: RW 10958 */ 10959 MLXSW_ITEM32(reg, mpagr, pa_id, 0x04, 0, 4); 10960 10961 #define MLXSW_REG_MPAGR_RATE_MAX 3500000000UL 10962 10963 /* reg_mpagr_probability_rate 10964 * Sampling rate. 10965 * Valid values are: 1 to 3.5*10^9 10966 * Value of 1 means "sample all". Default is 1. 10967 * Access: RW 10968 */ 10969 MLXSW_ITEM32(reg, mpagr, probability_rate, 0x08, 0, 32); 10970 10971 static inline void mlxsw_reg_mpagr_pack(char *payload, 10972 enum mlxsw_reg_mpagr_trigger trigger, 10973 u8 pa_id, u32 probability_rate) 10974 { 10975 MLXSW_REG_ZERO(mpagr, payload); 10976 mlxsw_reg_mpagr_trigger_set(payload, trigger); 10977 mlxsw_reg_mpagr_pa_id_set(payload, pa_id); 10978 mlxsw_reg_mpagr_probability_rate_set(payload, probability_rate); 10979 } 10980 10981 /* MOMTE - Monitoring Mirror Trigger Enable Register 10982 * ------------------------------------------------- 10983 * This register is used to configure the mirror enable for different mirror 10984 * reasons. 10985 */ 10986 #define MLXSW_REG_MOMTE_ID 0x908D 10987 #define MLXSW_REG_MOMTE_LEN 0x10 10988 10989 MLXSW_REG_DEFINE(momte, MLXSW_REG_MOMTE_ID, MLXSW_REG_MOMTE_LEN); 10990 10991 /* reg_momte_local_port 10992 * Local port number. 10993 * Access: Index 10994 */ 10995 MLXSW_ITEM32_LP(reg, momte, 0x00, 16, 0x00, 12); 10996 10997 enum mlxsw_reg_momte_type { 10998 MLXSW_REG_MOMTE_TYPE_WRED = 0x20, 10999 MLXSW_REG_MOMTE_TYPE_SHARED_BUFFER_TCLASS = 0x31, 11000 MLXSW_REG_MOMTE_TYPE_SHARED_BUFFER_TCLASS_DESCRIPTORS = 0x32, 11001 MLXSW_REG_MOMTE_TYPE_SHARED_BUFFER_EGRESS_PORT = 0x33, 11002 MLXSW_REG_MOMTE_TYPE_ING_CONG = 0x40, 11003 MLXSW_REG_MOMTE_TYPE_EGR_CONG = 0x50, 11004 MLXSW_REG_MOMTE_TYPE_ECN = 0x60, 11005 MLXSW_REG_MOMTE_TYPE_HIGH_LATENCY = 0x70, 11006 }; 11007 11008 /* reg_momte_type 11009 * Type of mirroring. 11010 * Access: Index 11011 */ 11012 MLXSW_ITEM32(reg, momte, type, 0x04, 0, 8); 11013 11014 /* reg_momte_tclass_en 11015 * TClass/PG mirror enable. Each bit represents corresponding tclass. 11016 * 0: disable (default) 11017 * 1: enable 11018 * Access: RW 11019 */ 11020 MLXSW_ITEM_BIT_ARRAY(reg, momte, tclass_en, 0x08, 0x08, 1); 11021 11022 static inline void mlxsw_reg_momte_pack(char *payload, u16 local_port, 11023 enum mlxsw_reg_momte_type type) 11024 { 11025 MLXSW_REG_ZERO(momte, payload); 11026 mlxsw_reg_momte_local_port_set(payload, local_port); 11027 mlxsw_reg_momte_type_set(payload, type); 11028 } 11029 11030 /* MTPPPC - Time Precision Packet Port Configuration 11031 * ------------------------------------------------- 11032 * This register serves for configuration of which PTP messages should be 11033 * timestamped. This is a global configuration, despite the register name. 11034 * 11035 * Reserved when Spectrum-2. 11036 */ 11037 #define MLXSW_REG_MTPPPC_ID 0x9090 11038 #define MLXSW_REG_MTPPPC_LEN 0x28 11039 11040 MLXSW_REG_DEFINE(mtpppc, MLXSW_REG_MTPPPC_ID, MLXSW_REG_MTPPPC_LEN); 11041 11042 /* reg_mtpppc_ing_timestamp_message_type 11043 * Bitwise vector of PTP message types to timestamp at ingress. 11044 * MessageType field as defined by IEEE 1588 11045 * Each bit corresponds to a value (e.g. Bit0: Sync, Bit1: Delay_Req) 11046 * Default all 0 11047 * Access: RW 11048 */ 11049 MLXSW_ITEM32(reg, mtpppc, ing_timestamp_message_type, 0x08, 0, 16); 11050 11051 /* reg_mtpppc_egr_timestamp_message_type 11052 * Bitwise vector of PTP message types to timestamp at egress. 11053 * MessageType field as defined by IEEE 1588 11054 * Each bit corresponds to a value (e.g. Bit0: Sync, Bit1: Delay_Req) 11055 * Default all 0 11056 * Access: RW 11057 */ 11058 MLXSW_ITEM32(reg, mtpppc, egr_timestamp_message_type, 0x0C, 0, 16); 11059 11060 static inline void mlxsw_reg_mtpppc_pack(char *payload, u16 ing, u16 egr) 11061 { 11062 MLXSW_REG_ZERO(mtpppc, payload); 11063 mlxsw_reg_mtpppc_ing_timestamp_message_type_set(payload, ing); 11064 mlxsw_reg_mtpppc_egr_timestamp_message_type_set(payload, egr); 11065 } 11066 11067 /* MTPPTR - Time Precision Packet Timestamping Reading 11068 * --------------------------------------------------- 11069 * The MTPPTR is used for reading the per port PTP timestamp FIFO. 11070 * There is a trap for packets which are latched to the timestamp FIFO, thus the 11071 * SW knows which FIFO to read. Note that packets enter the FIFO before been 11072 * trapped. The sequence number is used to synchronize the timestamp FIFO 11073 * entries and the trapped packets. 11074 * Reserved when Spectrum-2. 11075 */ 11076 11077 #define MLXSW_REG_MTPPTR_ID 0x9091 11078 #define MLXSW_REG_MTPPTR_BASE_LEN 0x10 /* base length, without records */ 11079 #define MLXSW_REG_MTPPTR_REC_LEN 0x10 /* record length */ 11080 #define MLXSW_REG_MTPPTR_REC_MAX_COUNT 4 11081 #define MLXSW_REG_MTPPTR_LEN (MLXSW_REG_MTPPTR_BASE_LEN + \ 11082 MLXSW_REG_MTPPTR_REC_LEN * MLXSW_REG_MTPPTR_REC_MAX_COUNT) 11083 11084 MLXSW_REG_DEFINE(mtpptr, MLXSW_REG_MTPPTR_ID, MLXSW_REG_MTPPTR_LEN); 11085 11086 /* reg_mtpptr_local_port 11087 * Not supported for CPU port. 11088 * Access: Index 11089 */ 11090 MLXSW_ITEM32_LP(reg, mtpptr, 0x00, 16, 0x00, 12); 11091 11092 enum mlxsw_reg_mtpptr_dir { 11093 MLXSW_REG_MTPPTR_DIR_INGRESS, 11094 MLXSW_REG_MTPPTR_DIR_EGRESS, 11095 }; 11096 11097 /* reg_mtpptr_dir 11098 * Direction. 11099 * Access: Index 11100 */ 11101 MLXSW_ITEM32(reg, mtpptr, dir, 0x00, 0, 1); 11102 11103 /* reg_mtpptr_clr 11104 * Clear the records. 11105 * Access: OP 11106 */ 11107 MLXSW_ITEM32(reg, mtpptr, clr, 0x04, 31, 1); 11108 11109 /* reg_mtpptr_num_rec 11110 * Number of valid records in the response 11111 * Range 0.. cap_ptp_timestamp_fifo 11112 * Access: RO 11113 */ 11114 MLXSW_ITEM32(reg, mtpptr, num_rec, 0x08, 0, 4); 11115 11116 /* reg_mtpptr_rec_message_type 11117 * MessageType field as defined by IEEE 1588 Each bit corresponds to a value 11118 * (e.g. Bit0: Sync, Bit1: Delay_Req) 11119 * Access: RO 11120 */ 11121 MLXSW_ITEM32_INDEXED(reg, mtpptr, rec_message_type, 11122 MLXSW_REG_MTPPTR_BASE_LEN, 8, 4, 11123 MLXSW_REG_MTPPTR_REC_LEN, 0, false); 11124 11125 /* reg_mtpptr_rec_domain_number 11126 * DomainNumber field as defined by IEEE 1588 11127 * Access: RO 11128 */ 11129 MLXSW_ITEM32_INDEXED(reg, mtpptr, rec_domain_number, 11130 MLXSW_REG_MTPPTR_BASE_LEN, 0, 8, 11131 MLXSW_REG_MTPPTR_REC_LEN, 0, false); 11132 11133 /* reg_mtpptr_rec_sequence_id 11134 * SequenceId field as defined by IEEE 1588 11135 * Access: RO 11136 */ 11137 MLXSW_ITEM32_INDEXED(reg, mtpptr, rec_sequence_id, 11138 MLXSW_REG_MTPPTR_BASE_LEN, 0, 16, 11139 MLXSW_REG_MTPPTR_REC_LEN, 0x4, false); 11140 11141 /* reg_mtpptr_rec_timestamp_high 11142 * Timestamp of when the PTP packet has passed through the port Units of PLL 11143 * clock time. 11144 * For Spectrum-1 the PLL clock is 156.25Mhz and PLL clock time is 6.4nSec. 11145 * Access: RO 11146 */ 11147 MLXSW_ITEM32_INDEXED(reg, mtpptr, rec_timestamp_high, 11148 MLXSW_REG_MTPPTR_BASE_LEN, 0, 32, 11149 MLXSW_REG_MTPPTR_REC_LEN, 0x8, false); 11150 11151 /* reg_mtpptr_rec_timestamp_low 11152 * See rec_timestamp_high. 11153 * Access: RO 11154 */ 11155 MLXSW_ITEM32_INDEXED(reg, mtpptr, rec_timestamp_low, 11156 MLXSW_REG_MTPPTR_BASE_LEN, 0, 32, 11157 MLXSW_REG_MTPPTR_REC_LEN, 0xC, false); 11158 11159 static inline void mlxsw_reg_mtpptr_unpack(const char *payload, 11160 unsigned int rec, 11161 u8 *p_message_type, 11162 u8 *p_domain_number, 11163 u16 *p_sequence_id, 11164 u64 *p_timestamp) 11165 { 11166 u32 timestamp_high, timestamp_low; 11167 11168 *p_message_type = mlxsw_reg_mtpptr_rec_message_type_get(payload, rec); 11169 *p_domain_number = mlxsw_reg_mtpptr_rec_domain_number_get(payload, rec); 11170 *p_sequence_id = mlxsw_reg_mtpptr_rec_sequence_id_get(payload, rec); 11171 timestamp_high = mlxsw_reg_mtpptr_rec_timestamp_high_get(payload, rec); 11172 timestamp_low = mlxsw_reg_mtpptr_rec_timestamp_low_get(payload, rec); 11173 *p_timestamp = (u64)timestamp_high << 32 | timestamp_low; 11174 } 11175 11176 /* MTPTPT - Monitoring Precision Time Protocol Trap Register 11177 * --------------------------------------------------------- 11178 * This register is used for configuring under which trap to deliver PTP 11179 * packets depending on type of the packet. 11180 */ 11181 #define MLXSW_REG_MTPTPT_ID 0x9092 11182 #define MLXSW_REG_MTPTPT_LEN 0x08 11183 11184 MLXSW_REG_DEFINE(mtptpt, MLXSW_REG_MTPTPT_ID, MLXSW_REG_MTPTPT_LEN); 11185 11186 enum mlxsw_reg_mtptpt_trap_id { 11187 MLXSW_REG_MTPTPT_TRAP_ID_PTP0, 11188 MLXSW_REG_MTPTPT_TRAP_ID_PTP1, 11189 }; 11190 11191 /* reg_mtptpt_trap_id 11192 * Trap id. 11193 * Access: Index 11194 */ 11195 MLXSW_ITEM32(reg, mtptpt, trap_id, 0x00, 0, 4); 11196 11197 /* reg_mtptpt_message_type 11198 * Bitwise vector of PTP message types to trap. This is a necessary but 11199 * non-sufficient condition since need to enable also per port. See MTPPPC. 11200 * Message types are defined by IEEE 1588 Each bit corresponds to a value (e.g. 11201 * Bit0: Sync, Bit1: Delay_Req) 11202 */ 11203 MLXSW_ITEM32(reg, mtptpt, message_type, 0x04, 0, 16); 11204 11205 static inline void mlxsw_reg_mtptptp_pack(char *payload, 11206 enum mlxsw_reg_mtptpt_trap_id trap_id, 11207 u16 message_type) 11208 { 11209 MLXSW_REG_ZERO(mtptpt, payload); 11210 mlxsw_reg_mtptpt_trap_id_set(payload, trap_id); 11211 mlxsw_reg_mtptpt_message_type_set(payload, message_type); 11212 } 11213 11214 /* MFGD - Monitoring FW General Debug Register 11215 * ------------------------------------------- 11216 */ 11217 #define MLXSW_REG_MFGD_ID 0x90F0 11218 #define MLXSW_REG_MFGD_LEN 0x0C 11219 11220 MLXSW_REG_DEFINE(mfgd, MLXSW_REG_MFGD_ID, MLXSW_REG_MFGD_LEN); 11221 11222 /* reg_mfgd_fw_fatal_event_mode 11223 * 0 - don't check FW fatal (default) 11224 * 1 - check FW fatal - enable MFDE trap 11225 * Access: RW 11226 */ 11227 MLXSW_ITEM32(reg, mfgd, fatal_event_mode, 0x00, 9, 2); 11228 11229 /* reg_mfgd_trigger_test 11230 * Access: WO 11231 */ 11232 MLXSW_ITEM32(reg, mfgd, trigger_test, 0x00, 11, 1); 11233 11234 /* MGPIR - Management General Peripheral Information Register 11235 * ---------------------------------------------------------- 11236 * MGPIR register allows software to query the hardware and 11237 * firmware general information of peripheral entities. 11238 */ 11239 #define MLXSW_REG_MGPIR_ID 0x9100 11240 #define MLXSW_REG_MGPIR_LEN 0xA0 11241 11242 MLXSW_REG_DEFINE(mgpir, MLXSW_REG_MGPIR_ID, MLXSW_REG_MGPIR_LEN); 11243 11244 enum mlxsw_reg_mgpir_device_type { 11245 MLXSW_REG_MGPIR_DEVICE_TYPE_NONE, 11246 MLXSW_REG_MGPIR_DEVICE_TYPE_GEARBOX_DIE, 11247 }; 11248 11249 /* device_type 11250 * Access: RO 11251 */ 11252 MLXSW_ITEM32(reg, mgpir, device_type, 0x00, 24, 4); 11253 11254 /* devices_per_flash 11255 * Number of devices of device_type per flash (can be shared by few devices). 11256 * Access: RO 11257 */ 11258 MLXSW_ITEM32(reg, mgpir, devices_per_flash, 0x00, 16, 8); 11259 11260 /* num_of_devices 11261 * Number of devices of device_type. 11262 * Access: RO 11263 */ 11264 MLXSW_ITEM32(reg, mgpir, num_of_devices, 0x00, 0, 8); 11265 11266 /* num_of_modules 11267 * Number of modules. 11268 * Access: RO 11269 */ 11270 MLXSW_ITEM32(reg, mgpir, num_of_modules, 0x04, 0, 8); 11271 11272 static inline void mlxsw_reg_mgpir_pack(char *payload) 11273 { 11274 MLXSW_REG_ZERO(mgpir, payload); 11275 } 11276 11277 static inline void 11278 mlxsw_reg_mgpir_unpack(char *payload, u8 *num_of_devices, 11279 enum mlxsw_reg_mgpir_device_type *device_type, 11280 u8 *devices_per_flash, u8 *num_of_modules) 11281 { 11282 if (num_of_devices) 11283 *num_of_devices = mlxsw_reg_mgpir_num_of_devices_get(payload); 11284 if (device_type) 11285 *device_type = mlxsw_reg_mgpir_device_type_get(payload); 11286 if (devices_per_flash) 11287 *devices_per_flash = 11288 mlxsw_reg_mgpir_devices_per_flash_get(payload); 11289 if (num_of_modules) 11290 *num_of_modules = mlxsw_reg_mgpir_num_of_modules_get(payload); 11291 } 11292 11293 /* MFDE - Monitoring FW Debug Register 11294 * ----------------------------------- 11295 */ 11296 #define MLXSW_REG_MFDE_ID 0x9200 11297 #define MLXSW_REG_MFDE_LEN 0x18 11298 11299 MLXSW_REG_DEFINE(mfde, MLXSW_REG_MFDE_ID, MLXSW_REG_MFDE_LEN); 11300 11301 /* reg_mfde_irisc_id 11302 * Which irisc triggered the event 11303 * Access: RO 11304 */ 11305 MLXSW_ITEM32(reg, mfde, irisc_id, 0x00, 24, 8); 11306 11307 enum mlxsw_reg_mfde_event_id { 11308 MLXSW_REG_MFDE_EVENT_ID_CRSPACE_TO = 1, 11309 /* KVD insertion machine stopped */ 11310 MLXSW_REG_MFDE_EVENT_ID_KVD_IM_STOP, 11311 }; 11312 11313 /* reg_mfde_event_id 11314 * Access: RO 11315 */ 11316 MLXSW_ITEM32(reg, mfde, event_id, 0x00, 0, 16); 11317 11318 enum mlxsw_reg_mfde_method { 11319 MLXSW_REG_MFDE_METHOD_QUERY, 11320 MLXSW_REG_MFDE_METHOD_WRITE, 11321 }; 11322 11323 /* reg_mfde_method 11324 * Access: RO 11325 */ 11326 MLXSW_ITEM32(reg, mfde, method, 0x04, 29, 1); 11327 11328 /* reg_mfde_long_process 11329 * Indicates if the command is in long_process mode. 11330 * Access: RO 11331 */ 11332 MLXSW_ITEM32(reg, mfde, long_process, 0x04, 28, 1); 11333 11334 enum mlxsw_reg_mfde_command_type { 11335 MLXSW_REG_MFDE_COMMAND_TYPE_MAD, 11336 MLXSW_REG_MFDE_COMMAND_TYPE_EMAD, 11337 MLXSW_REG_MFDE_COMMAND_TYPE_CMDIF, 11338 }; 11339 11340 /* reg_mfde_command_type 11341 * Access: RO 11342 */ 11343 MLXSW_ITEM32(reg, mfde, command_type, 0x04, 24, 2); 11344 11345 /* reg_mfde_reg_attr_id 11346 * EMAD - register id, MAD - attibute id 11347 * Access: RO 11348 */ 11349 MLXSW_ITEM32(reg, mfde, reg_attr_id, 0x04, 0, 16); 11350 11351 /* reg_mfde_log_address 11352 * crspace address accessed, which resulted in timeout. 11353 * Valid in case event_id == MLXSW_REG_MFDE_EVENT_ID_CRSPACE_TO 11354 * Access: RO 11355 */ 11356 MLXSW_ITEM32(reg, mfde, log_address, 0x10, 0, 32); 11357 11358 /* reg_mfde_log_id 11359 * Which irisc triggered the timeout. 11360 * Valid in case event_id == MLXSW_REG_MFDE_EVENT_ID_CRSPACE_TO 11361 * Access: RO 11362 */ 11363 MLXSW_ITEM32(reg, mfde, log_id, 0x14, 0, 4); 11364 11365 /* reg_mfde_log_ip 11366 * IP (instruction pointer) that triggered the timeout. 11367 * Valid in case event_id == MLXSW_REG_MFDE_EVENT_ID_CRSPACE_TO 11368 * Access: RO 11369 */ 11370 MLXSW_ITEM64(reg, mfde, log_ip, 0x18, 0, 64); 11371 11372 /* reg_mfde_pipes_mask 11373 * Bit per kvh pipe. 11374 * Access: RO 11375 */ 11376 MLXSW_ITEM32(reg, mfde, pipes_mask, 0x10, 0, 16); 11377 11378 /* TNGCR - Tunneling NVE General Configuration Register 11379 * ---------------------------------------------------- 11380 * The TNGCR register is used for setting up the NVE Tunneling configuration. 11381 */ 11382 #define MLXSW_REG_TNGCR_ID 0xA001 11383 #define MLXSW_REG_TNGCR_LEN 0x44 11384 11385 MLXSW_REG_DEFINE(tngcr, MLXSW_REG_TNGCR_ID, MLXSW_REG_TNGCR_LEN); 11386 11387 enum mlxsw_reg_tngcr_type { 11388 MLXSW_REG_TNGCR_TYPE_VXLAN, 11389 MLXSW_REG_TNGCR_TYPE_VXLAN_GPE, 11390 MLXSW_REG_TNGCR_TYPE_GENEVE, 11391 MLXSW_REG_TNGCR_TYPE_NVGRE, 11392 }; 11393 11394 /* reg_tngcr_type 11395 * Tunnel type for encapsulation and decapsulation. The types are mutually 11396 * exclusive. 11397 * Note: For Spectrum the NVE parsing must be enabled in MPRS. 11398 * Access: RW 11399 */ 11400 MLXSW_ITEM32(reg, tngcr, type, 0x00, 0, 4); 11401 11402 /* reg_tngcr_nve_valid 11403 * The VTEP is valid. Allows adding FDB entries for tunnel encapsulation. 11404 * Access: RW 11405 */ 11406 MLXSW_ITEM32(reg, tngcr, nve_valid, 0x04, 31, 1); 11407 11408 /* reg_tngcr_nve_ttl_uc 11409 * The TTL for NVE tunnel encapsulation underlay unicast packets. 11410 * Access: RW 11411 */ 11412 MLXSW_ITEM32(reg, tngcr, nve_ttl_uc, 0x04, 0, 8); 11413 11414 /* reg_tngcr_nve_ttl_mc 11415 * The TTL for NVE tunnel encapsulation underlay multicast packets. 11416 * Access: RW 11417 */ 11418 MLXSW_ITEM32(reg, tngcr, nve_ttl_mc, 0x08, 0, 8); 11419 11420 enum { 11421 /* Do not copy flow label. Calculate flow label using nve_flh. */ 11422 MLXSW_REG_TNGCR_FL_NO_COPY, 11423 /* Copy flow label from inner packet if packet is IPv6 and 11424 * encapsulation is by IPv6. Otherwise, calculate flow label using 11425 * nve_flh. 11426 */ 11427 MLXSW_REG_TNGCR_FL_COPY, 11428 }; 11429 11430 /* reg_tngcr_nve_flc 11431 * For NVE tunnel encapsulation: Flow label copy from inner packet. 11432 * Access: RW 11433 */ 11434 MLXSW_ITEM32(reg, tngcr, nve_flc, 0x0C, 25, 1); 11435 11436 enum { 11437 /* Flow label is static. In Spectrum this means '0'. Spectrum-2 11438 * uses {nve_fl_prefix, nve_fl_suffix}. 11439 */ 11440 MLXSW_REG_TNGCR_FL_NO_HASH, 11441 /* 8 LSBs of the flow label are calculated from ECMP hash of the 11442 * inner packet. 12 MSBs are configured by nve_fl_prefix. 11443 */ 11444 MLXSW_REG_TNGCR_FL_HASH, 11445 }; 11446 11447 /* reg_tngcr_nve_flh 11448 * NVE flow label hash. 11449 * Access: RW 11450 */ 11451 MLXSW_ITEM32(reg, tngcr, nve_flh, 0x0C, 24, 1); 11452 11453 /* reg_tngcr_nve_fl_prefix 11454 * NVE flow label prefix. Constant 12 MSBs of the flow label. 11455 * Access: RW 11456 */ 11457 MLXSW_ITEM32(reg, tngcr, nve_fl_prefix, 0x0C, 8, 12); 11458 11459 /* reg_tngcr_nve_fl_suffix 11460 * NVE flow label suffix. Constant 8 LSBs of the flow label. 11461 * Reserved when nve_flh=1 and for Spectrum. 11462 * Access: RW 11463 */ 11464 MLXSW_ITEM32(reg, tngcr, nve_fl_suffix, 0x0C, 0, 8); 11465 11466 enum { 11467 /* Source UDP port is fixed (default '0') */ 11468 MLXSW_REG_TNGCR_UDP_SPORT_NO_HASH, 11469 /* Source UDP port is calculated based on hash */ 11470 MLXSW_REG_TNGCR_UDP_SPORT_HASH, 11471 }; 11472 11473 /* reg_tngcr_nve_udp_sport_type 11474 * NVE UDP source port type. 11475 * Spectrum uses LAG hash (SLCRv2). Spectrum-2 uses ECMP hash (RECRv2). 11476 * When the source UDP port is calculated based on hash, then the 8 LSBs 11477 * are calculated from hash the 8 MSBs are configured by 11478 * nve_udp_sport_prefix. 11479 * Access: RW 11480 */ 11481 MLXSW_ITEM32(reg, tngcr, nve_udp_sport_type, 0x10, 24, 1); 11482 11483 /* reg_tngcr_nve_udp_sport_prefix 11484 * NVE UDP source port prefix. Constant 8 MSBs of the UDP source port. 11485 * Reserved when NVE type is NVGRE. 11486 * Access: RW 11487 */ 11488 MLXSW_ITEM32(reg, tngcr, nve_udp_sport_prefix, 0x10, 8, 8); 11489 11490 /* reg_tngcr_nve_group_size_mc 11491 * The amount of sequential linked lists of MC entries. The first linked 11492 * list is configured by SFD.underlay_mc_ptr. 11493 * Valid values: 1, 2, 4, 8, 16, 32, 64 11494 * The linked list are configured by TNUMT. 11495 * The hash is set by LAG hash. 11496 * Access: RW 11497 */ 11498 MLXSW_ITEM32(reg, tngcr, nve_group_size_mc, 0x18, 0, 8); 11499 11500 /* reg_tngcr_nve_group_size_flood 11501 * The amount of sequential linked lists of flooding entries. The first 11502 * linked list is configured by SFMR.nve_tunnel_flood_ptr 11503 * Valid values: 1, 2, 4, 8, 16, 32, 64 11504 * The linked list are configured by TNUMT. 11505 * The hash is set by LAG hash. 11506 * Access: RW 11507 */ 11508 MLXSW_ITEM32(reg, tngcr, nve_group_size_flood, 0x1C, 0, 8); 11509 11510 /* reg_tngcr_learn_enable 11511 * During decapsulation, whether to learn from NVE port. 11512 * Reserved when Spectrum-2. See TNPC. 11513 * Access: RW 11514 */ 11515 MLXSW_ITEM32(reg, tngcr, learn_enable, 0x20, 31, 1); 11516 11517 /* reg_tngcr_underlay_virtual_router 11518 * Underlay virtual router. 11519 * Reserved when Spectrum-2. 11520 * Access: RW 11521 */ 11522 MLXSW_ITEM32(reg, tngcr, underlay_virtual_router, 0x20, 0, 16); 11523 11524 /* reg_tngcr_underlay_rif 11525 * Underlay ingress router interface. RIF type should be loopback generic. 11526 * Reserved when Spectrum. 11527 * Access: RW 11528 */ 11529 MLXSW_ITEM32(reg, tngcr, underlay_rif, 0x24, 0, 16); 11530 11531 /* reg_tngcr_usipv4 11532 * Underlay source IPv4 address of the NVE. 11533 * Access: RW 11534 */ 11535 MLXSW_ITEM32(reg, tngcr, usipv4, 0x28, 0, 32); 11536 11537 /* reg_tngcr_usipv6 11538 * Underlay source IPv6 address of the NVE. For Spectrum, must not be 11539 * modified under traffic of NVE tunneling encapsulation. 11540 * Access: RW 11541 */ 11542 MLXSW_ITEM_BUF(reg, tngcr, usipv6, 0x30, 16); 11543 11544 static inline void mlxsw_reg_tngcr_pack(char *payload, 11545 enum mlxsw_reg_tngcr_type type, 11546 bool valid, u8 ttl) 11547 { 11548 MLXSW_REG_ZERO(tngcr, payload); 11549 mlxsw_reg_tngcr_type_set(payload, type); 11550 mlxsw_reg_tngcr_nve_valid_set(payload, valid); 11551 mlxsw_reg_tngcr_nve_ttl_uc_set(payload, ttl); 11552 mlxsw_reg_tngcr_nve_ttl_mc_set(payload, ttl); 11553 mlxsw_reg_tngcr_nve_flc_set(payload, MLXSW_REG_TNGCR_FL_NO_COPY); 11554 mlxsw_reg_tngcr_nve_flh_set(payload, 0); 11555 mlxsw_reg_tngcr_nve_udp_sport_type_set(payload, 11556 MLXSW_REG_TNGCR_UDP_SPORT_HASH); 11557 mlxsw_reg_tngcr_nve_udp_sport_prefix_set(payload, 0); 11558 mlxsw_reg_tngcr_nve_group_size_mc_set(payload, 1); 11559 mlxsw_reg_tngcr_nve_group_size_flood_set(payload, 1); 11560 } 11561 11562 /* TNUMT - Tunneling NVE Underlay Multicast Table Register 11563 * ------------------------------------------------------- 11564 * The TNUMT register is for building the underlay MC table. It is used 11565 * for MC, flooding and BC traffic into the NVE tunnel. 11566 */ 11567 #define MLXSW_REG_TNUMT_ID 0xA003 11568 #define MLXSW_REG_TNUMT_LEN 0x20 11569 11570 MLXSW_REG_DEFINE(tnumt, MLXSW_REG_TNUMT_ID, MLXSW_REG_TNUMT_LEN); 11571 11572 enum mlxsw_reg_tnumt_record_type { 11573 MLXSW_REG_TNUMT_RECORD_TYPE_IPV4, 11574 MLXSW_REG_TNUMT_RECORD_TYPE_IPV6, 11575 MLXSW_REG_TNUMT_RECORD_TYPE_LABEL, 11576 }; 11577 11578 /* reg_tnumt_record_type 11579 * Record type. 11580 * Access: RW 11581 */ 11582 MLXSW_ITEM32(reg, tnumt, record_type, 0x00, 28, 4); 11583 11584 /* reg_tnumt_tunnel_port 11585 * Tunnel port. 11586 * Access: RW 11587 */ 11588 MLXSW_ITEM32(reg, tnumt, tunnel_port, 0x00, 24, 4); 11589 11590 /* reg_tnumt_underlay_mc_ptr 11591 * Index to the underlay multicast table. 11592 * For Spectrum the index is to the KVD linear. 11593 * Access: Index 11594 */ 11595 MLXSW_ITEM32(reg, tnumt, underlay_mc_ptr, 0x00, 0, 24); 11596 11597 /* reg_tnumt_vnext 11598 * The next_underlay_mc_ptr is valid. 11599 * Access: RW 11600 */ 11601 MLXSW_ITEM32(reg, tnumt, vnext, 0x04, 31, 1); 11602 11603 /* reg_tnumt_next_underlay_mc_ptr 11604 * The next index to the underlay multicast table. 11605 * Access: RW 11606 */ 11607 MLXSW_ITEM32(reg, tnumt, next_underlay_mc_ptr, 0x04, 0, 24); 11608 11609 /* reg_tnumt_record_size 11610 * Number of IP addresses in the record. 11611 * Range is 1..cap_max_nve_mc_entries_ipv{4,6} 11612 * Access: RW 11613 */ 11614 MLXSW_ITEM32(reg, tnumt, record_size, 0x08, 0, 3); 11615 11616 /* reg_tnumt_udip 11617 * The underlay IPv4 addresses. udip[i] is reserved if i >= size 11618 * Access: RW 11619 */ 11620 MLXSW_ITEM32_INDEXED(reg, tnumt, udip, 0x0C, 0, 32, 0x04, 0x00, false); 11621 11622 /* reg_tnumt_udip_ptr 11623 * The pointer to the underlay IPv6 addresses. udip_ptr[i] is reserved if 11624 * i >= size. The IPv6 addresses are configured by RIPS. 11625 * Access: RW 11626 */ 11627 MLXSW_ITEM32_INDEXED(reg, tnumt, udip_ptr, 0x0C, 0, 24, 0x04, 0x00, false); 11628 11629 static inline void mlxsw_reg_tnumt_pack(char *payload, 11630 enum mlxsw_reg_tnumt_record_type type, 11631 enum mlxsw_reg_tunnel_port tport, 11632 u32 underlay_mc_ptr, bool vnext, 11633 u32 next_underlay_mc_ptr, 11634 u8 record_size) 11635 { 11636 MLXSW_REG_ZERO(tnumt, payload); 11637 mlxsw_reg_tnumt_record_type_set(payload, type); 11638 mlxsw_reg_tnumt_tunnel_port_set(payload, tport); 11639 mlxsw_reg_tnumt_underlay_mc_ptr_set(payload, underlay_mc_ptr); 11640 mlxsw_reg_tnumt_vnext_set(payload, vnext); 11641 mlxsw_reg_tnumt_next_underlay_mc_ptr_set(payload, next_underlay_mc_ptr); 11642 mlxsw_reg_tnumt_record_size_set(payload, record_size); 11643 } 11644 11645 /* TNQCR - Tunneling NVE QoS Configuration Register 11646 * ------------------------------------------------ 11647 * The TNQCR register configures how QoS is set in encapsulation into the 11648 * underlay network. 11649 */ 11650 #define MLXSW_REG_TNQCR_ID 0xA010 11651 #define MLXSW_REG_TNQCR_LEN 0x0C 11652 11653 MLXSW_REG_DEFINE(tnqcr, MLXSW_REG_TNQCR_ID, MLXSW_REG_TNQCR_LEN); 11654 11655 /* reg_tnqcr_enc_set_dscp 11656 * For encapsulation: How to set DSCP field: 11657 * 0 - Copy the DSCP from the overlay (inner) IP header to the underlay 11658 * (outer) IP header. If there is no IP header, use TNQDR.dscp 11659 * 1 - Set the DSCP field as TNQDR.dscp 11660 * Access: RW 11661 */ 11662 MLXSW_ITEM32(reg, tnqcr, enc_set_dscp, 0x04, 28, 1); 11663 11664 static inline void mlxsw_reg_tnqcr_pack(char *payload) 11665 { 11666 MLXSW_REG_ZERO(tnqcr, payload); 11667 mlxsw_reg_tnqcr_enc_set_dscp_set(payload, 0); 11668 } 11669 11670 /* TNQDR - Tunneling NVE QoS Default Register 11671 * ------------------------------------------ 11672 * The TNQDR register configures the default QoS settings for NVE 11673 * encapsulation. 11674 */ 11675 #define MLXSW_REG_TNQDR_ID 0xA011 11676 #define MLXSW_REG_TNQDR_LEN 0x08 11677 11678 MLXSW_REG_DEFINE(tnqdr, MLXSW_REG_TNQDR_ID, MLXSW_REG_TNQDR_LEN); 11679 11680 /* reg_tnqdr_local_port 11681 * Local port number (receive port). CPU port is supported. 11682 * Access: Index 11683 */ 11684 MLXSW_ITEM32_LP(reg, tnqdr, 0x00, 16, 0x00, 12); 11685 11686 /* reg_tnqdr_dscp 11687 * For encapsulation, the default DSCP. 11688 * Access: RW 11689 */ 11690 MLXSW_ITEM32(reg, tnqdr, dscp, 0x04, 0, 6); 11691 11692 static inline void mlxsw_reg_tnqdr_pack(char *payload, u16 local_port) 11693 { 11694 MLXSW_REG_ZERO(tnqdr, payload); 11695 mlxsw_reg_tnqdr_local_port_set(payload, local_port); 11696 mlxsw_reg_tnqdr_dscp_set(payload, 0); 11697 } 11698 11699 /* TNEEM - Tunneling NVE Encapsulation ECN Mapping Register 11700 * -------------------------------------------------------- 11701 * The TNEEM register maps ECN of the IP header at the ingress to the 11702 * encapsulation to the ECN of the underlay network. 11703 */ 11704 #define MLXSW_REG_TNEEM_ID 0xA012 11705 #define MLXSW_REG_TNEEM_LEN 0x0C 11706 11707 MLXSW_REG_DEFINE(tneem, MLXSW_REG_TNEEM_ID, MLXSW_REG_TNEEM_LEN); 11708 11709 /* reg_tneem_overlay_ecn 11710 * ECN of the IP header in the overlay network. 11711 * Access: Index 11712 */ 11713 MLXSW_ITEM32(reg, tneem, overlay_ecn, 0x04, 24, 2); 11714 11715 /* reg_tneem_underlay_ecn 11716 * ECN of the IP header in the underlay network. 11717 * Access: RW 11718 */ 11719 MLXSW_ITEM32(reg, tneem, underlay_ecn, 0x04, 16, 2); 11720 11721 static inline void mlxsw_reg_tneem_pack(char *payload, u8 overlay_ecn, 11722 u8 underlay_ecn) 11723 { 11724 MLXSW_REG_ZERO(tneem, payload); 11725 mlxsw_reg_tneem_overlay_ecn_set(payload, overlay_ecn); 11726 mlxsw_reg_tneem_underlay_ecn_set(payload, underlay_ecn); 11727 } 11728 11729 /* TNDEM - Tunneling NVE Decapsulation ECN Mapping Register 11730 * -------------------------------------------------------- 11731 * The TNDEM register configures the actions that are done in the 11732 * decapsulation. 11733 */ 11734 #define MLXSW_REG_TNDEM_ID 0xA013 11735 #define MLXSW_REG_TNDEM_LEN 0x0C 11736 11737 MLXSW_REG_DEFINE(tndem, MLXSW_REG_TNDEM_ID, MLXSW_REG_TNDEM_LEN); 11738 11739 /* reg_tndem_underlay_ecn 11740 * ECN field of the IP header in the underlay network. 11741 * Access: Index 11742 */ 11743 MLXSW_ITEM32(reg, tndem, underlay_ecn, 0x04, 24, 2); 11744 11745 /* reg_tndem_overlay_ecn 11746 * ECN field of the IP header in the overlay network. 11747 * Access: Index 11748 */ 11749 MLXSW_ITEM32(reg, tndem, overlay_ecn, 0x04, 16, 2); 11750 11751 /* reg_tndem_eip_ecn 11752 * Egress IP ECN. ECN field of the IP header of the packet which goes out 11753 * from the decapsulation. 11754 * Access: RW 11755 */ 11756 MLXSW_ITEM32(reg, tndem, eip_ecn, 0x04, 8, 2); 11757 11758 /* reg_tndem_trap_en 11759 * Trap enable: 11760 * 0 - No trap due to decap ECN 11761 * 1 - Trap enable with trap_id 11762 * Access: RW 11763 */ 11764 MLXSW_ITEM32(reg, tndem, trap_en, 0x08, 28, 4); 11765 11766 /* reg_tndem_trap_id 11767 * Trap ID. Either DECAP_ECN0 or DECAP_ECN1. 11768 * Reserved when trap_en is '0'. 11769 * Access: RW 11770 */ 11771 MLXSW_ITEM32(reg, tndem, trap_id, 0x08, 0, 9); 11772 11773 static inline void mlxsw_reg_tndem_pack(char *payload, u8 underlay_ecn, 11774 u8 overlay_ecn, u8 ecn, bool trap_en, 11775 u16 trap_id) 11776 { 11777 MLXSW_REG_ZERO(tndem, payload); 11778 mlxsw_reg_tndem_underlay_ecn_set(payload, underlay_ecn); 11779 mlxsw_reg_tndem_overlay_ecn_set(payload, overlay_ecn); 11780 mlxsw_reg_tndem_eip_ecn_set(payload, ecn); 11781 mlxsw_reg_tndem_trap_en_set(payload, trap_en); 11782 mlxsw_reg_tndem_trap_id_set(payload, trap_id); 11783 } 11784 11785 /* TNPC - Tunnel Port Configuration Register 11786 * ----------------------------------------- 11787 * The TNPC register is used for tunnel port configuration. 11788 * Reserved when Spectrum. 11789 */ 11790 #define MLXSW_REG_TNPC_ID 0xA020 11791 #define MLXSW_REG_TNPC_LEN 0x18 11792 11793 MLXSW_REG_DEFINE(tnpc, MLXSW_REG_TNPC_ID, MLXSW_REG_TNPC_LEN); 11794 11795 /* reg_tnpc_tunnel_port 11796 * Tunnel port. 11797 * Access: Index 11798 */ 11799 MLXSW_ITEM32(reg, tnpc, tunnel_port, 0x00, 0, 4); 11800 11801 /* reg_tnpc_learn_enable_v6 11802 * During IPv6 underlay decapsulation, whether to learn from tunnel port. 11803 * Access: RW 11804 */ 11805 MLXSW_ITEM32(reg, tnpc, learn_enable_v6, 0x04, 1, 1); 11806 11807 /* reg_tnpc_learn_enable_v4 11808 * During IPv4 underlay decapsulation, whether to learn from tunnel port. 11809 * Access: RW 11810 */ 11811 MLXSW_ITEM32(reg, tnpc, learn_enable_v4, 0x04, 0, 1); 11812 11813 static inline void mlxsw_reg_tnpc_pack(char *payload, 11814 enum mlxsw_reg_tunnel_port tport, 11815 bool learn_enable) 11816 { 11817 MLXSW_REG_ZERO(tnpc, payload); 11818 mlxsw_reg_tnpc_tunnel_port_set(payload, tport); 11819 mlxsw_reg_tnpc_learn_enable_v4_set(payload, learn_enable); 11820 mlxsw_reg_tnpc_learn_enable_v6_set(payload, learn_enable); 11821 } 11822 11823 /* TIGCR - Tunneling IPinIP General Configuration Register 11824 * ------------------------------------------------------- 11825 * The TIGCR register is used for setting up the IPinIP Tunnel configuration. 11826 */ 11827 #define MLXSW_REG_TIGCR_ID 0xA801 11828 #define MLXSW_REG_TIGCR_LEN 0x10 11829 11830 MLXSW_REG_DEFINE(tigcr, MLXSW_REG_TIGCR_ID, MLXSW_REG_TIGCR_LEN); 11831 11832 /* reg_tigcr_ipip_ttlc 11833 * For IPinIP Tunnel encapsulation: whether to copy the ttl from the packet 11834 * header. 11835 * Access: RW 11836 */ 11837 MLXSW_ITEM32(reg, tigcr, ttlc, 0x04, 8, 1); 11838 11839 /* reg_tigcr_ipip_ttl_uc 11840 * The TTL for IPinIP Tunnel encapsulation of unicast packets if 11841 * reg_tigcr_ipip_ttlc is unset. 11842 * Access: RW 11843 */ 11844 MLXSW_ITEM32(reg, tigcr, ttl_uc, 0x04, 0, 8); 11845 11846 static inline void mlxsw_reg_tigcr_pack(char *payload, bool ttlc, u8 ttl_uc) 11847 { 11848 MLXSW_REG_ZERO(tigcr, payload); 11849 mlxsw_reg_tigcr_ttlc_set(payload, ttlc); 11850 mlxsw_reg_tigcr_ttl_uc_set(payload, ttl_uc); 11851 } 11852 11853 /* TIEEM - Tunneling IPinIP Encapsulation ECN Mapping Register 11854 * ----------------------------------------------------------- 11855 * The TIEEM register maps ECN of the IP header at the ingress to the 11856 * encapsulation to the ECN of the underlay network. 11857 */ 11858 #define MLXSW_REG_TIEEM_ID 0xA812 11859 #define MLXSW_REG_TIEEM_LEN 0x0C 11860 11861 MLXSW_REG_DEFINE(tieem, MLXSW_REG_TIEEM_ID, MLXSW_REG_TIEEM_LEN); 11862 11863 /* reg_tieem_overlay_ecn 11864 * ECN of the IP header in the overlay network. 11865 * Access: Index 11866 */ 11867 MLXSW_ITEM32(reg, tieem, overlay_ecn, 0x04, 24, 2); 11868 11869 /* reg_tineem_underlay_ecn 11870 * ECN of the IP header in the underlay network. 11871 * Access: RW 11872 */ 11873 MLXSW_ITEM32(reg, tieem, underlay_ecn, 0x04, 16, 2); 11874 11875 static inline void mlxsw_reg_tieem_pack(char *payload, u8 overlay_ecn, 11876 u8 underlay_ecn) 11877 { 11878 MLXSW_REG_ZERO(tieem, payload); 11879 mlxsw_reg_tieem_overlay_ecn_set(payload, overlay_ecn); 11880 mlxsw_reg_tieem_underlay_ecn_set(payload, underlay_ecn); 11881 } 11882 11883 /* TIDEM - Tunneling IPinIP Decapsulation ECN Mapping Register 11884 * ----------------------------------------------------------- 11885 * The TIDEM register configures the actions that are done in the 11886 * decapsulation. 11887 */ 11888 #define MLXSW_REG_TIDEM_ID 0xA813 11889 #define MLXSW_REG_TIDEM_LEN 0x0C 11890 11891 MLXSW_REG_DEFINE(tidem, MLXSW_REG_TIDEM_ID, MLXSW_REG_TIDEM_LEN); 11892 11893 /* reg_tidem_underlay_ecn 11894 * ECN field of the IP header in the underlay network. 11895 * Access: Index 11896 */ 11897 MLXSW_ITEM32(reg, tidem, underlay_ecn, 0x04, 24, 2); 11898 11899 /* reg_tidem_overlay_ecn 11900 * ECN field of the IP header in the overlay network. 11901 * Access: Index 11902 */ 11903 MLXSW_ITEM32(reg, tidem, overlay_ecn, 0x04, 16, 2); 11904 11905 /* reg_tidem_eip_ecn 11906 * Egress IP ECN. ECN field of the IP header of the packet which goes out 11907 * from the decapsulation. 11908 * Access: RW 11909 */ 11910 MLXSW_ITEM32(reg, tidem, eip_ecn, 0x04, 8, 2); 11911 11912 /* reg_tidem_trap_en 11913 * Trap enable: 11914 * 0 - No trap due to decap ECN 11915 * 1 - Trap enable with trap_id 11916 * Access: RW 11917 */ 11918 MLXSW_ITEM32(reg, tidem, trap_en, 0x08, 28, 4); 11919 11920 /* reg_tidem_trap_id 11921 * Trap ID. Either DECAP_ECN0 or DECAP_ECN1. 11922 * Reserved when trap_en is '0'. 11923 * Access: RW 11924 */ 11925 MLXSW_ITEM32(reg, tidem, trap_id, 0x08, 0, 9); 11926 11927 static inline void mlxsw_reg_tidem_pack(char *payload, u8 underlay_ecn, 11928 u8 overlay_ecn, u8 eip_ecn, 11929 bool trap_en, u16 trap_id) 11930 { 11931 MLXSW_REG_ZERO(tidem, payload); 11932 mlxsw_reg_tidem_underlay_ecn_set(payload, underlay_ecn); 11933 mlxsw_reg_tidem_overlay_ecn_set(payload, overlay_ecn); 11934 mlxsw_reg_tidem_eip_ecn_set(payload, eip_ecn); 11935 mlxsw_reg_tidem_trap_en_set(payload, trap_en); 11936 mlxsw_reg_tidem_trap_id_set(payload, trap_id); 11937 } 11938 11939 /* SBPR - Shared Buffer Pools Register 11940 * ----------------------------------- 11941 * The SBPR configures and retrieves the shared buffer pools and configuration. 11942 */ 11943 #define MLXSW_REG_SBPR_ID 0xB001 11944 #define MLXSW_REG_SBPR_LEN 0x14 11945 11946 MLXSW_REG_DEFINE(sbpr, MLXSW_REG_SBPR_ID, MLXSW_REG_SBPR_LEN); 11947 11948 /* shared direstion enum for SBPR, SBCM, SBPM */ 11949 enum mlxsw_reg_sbxx_dir { 11950 MLXSW_REG_SBXX_DIR_INGRESS, 11951 MLXSW_REG_SBXX_DIR_EGRESS, 11952 }; 11953 11954 /* reg_sbpr_dir 11955 * Direction. 11956 * Access: Index 11957 */ 11958 MLXSW_ITEM32(reg, sbpr, dir, 0x00, 24, 2); 11959 11960 /* reg_sbpr_pool 11961 * Pool index. 11962 * Access: Index 11963 */ 11964 MLXSW_ITEM32(reg, sbpr, pool, 0x00, 0, 4); 11965 11966 /* reg_sbpr_infi_size 11967 * Size is infinite. 11968 * Access: RW 11969 */ 11970 MLXSW_ITEM32(reg, sbpr, infi_size, 0x04, 31, 1); 11971 11972 /* reg_sbpr_size 11973 * Pool size in buffer cells. 11974 * Reserved when infi_size = 1. 11975 * Access: RW 11976 */ 11977 MLXSW_ITEM32(reg, sbpr, size, 0x04, 0, 24); 11978 11979 enum mlxsw_reg_sbpr_mode { 11980 MLXSW_REG_SBPR_MODE_STATIC, 11981 MLXSW_REG_SBPR_MODE_DYNAMIC, 11982 }; 11983 11984 /* reg_sbpr_mode 11985 * Pool quota calculation mode. 11986 * Access: RW 11987 */ 11988 MLXSW_ITEM32(reg, sbpr, mode, 0x08, 0, 4); 11989 11990 static inline void mlxsw_reg_sbpr_pack(char *payload, u8 pool, 11991 enum mlxsw_reg_sbxx_dir dir, 11992 enum mlxsw_reg_sbpr_mode mode, u32 size, 11993 bool infi_size) 11994 { 11995 MLXSW_REG_ZERO(sbpr, payload); 11996 mlxsw_reg_sbpr_pool_set(payload, pool); 11997 mlxsw_reg_sbpr_dir_set(payload, dir); 11998 mlxsw_reg_sbpr_mode_set(payload, mode); 11999 mlxsw_reg_sbpr_size_set(payload, size); 12000 mlxsw_reg_sbpr_infi_size_set(payload, infi_size); 12001 } 12002 12003 /* SBCM - Shared Buffer Class Management Register 12004 * ---------------------------------------------- 12005 * The SBCM register configures and retrieves the shared buffer allocation 12006 * and configuration according to Port-PG, including the binding to pool 12007 * and definition of the associated quota. 12008 */ 12009 #define MLXSW_REG_SBCM_ID 0xB002 12010 #define MLXSW_REG_SBCM_LEN 0x28 12011 12012 MLXSW_REG_DEFINE(sbcm, MLXSW_REG_SBCM_ID, MLXSW_REG_SBCM_LEN); 12013 12014 /* reg_sbcm_local_port 12015 * Local port number. 12016 * For Ingress: excludes CPU port and Router port 12017 * For Egress: excludes IP Router 12018 * Access: Index 12019 */ 12020 MLXSW_ITEM32_LP(reg, sbcm, 0x00, 16, 0x00, 4); 12021 12022 /* reg_sbcm_pg_buff 12023 * PG buffer - Port PG (dir=ingress) / traffic class (dir=egress) 12024 * For PG buffer: range is 0..cap_max_pg_buffers - 1 12025 * For traffic class: range is 0..cap_max_tclass - 1 12026 * Note that when traffic class is in MC aware mode then the traffic 12027 * classes which are MC aware cannot be configured. 12028 * Access: Index 12029 */ 12030 MLXSW_ITEM32(reg, sbcm, pg_buff, 0x00, 8, 6); 12031 12032 /* reg_sbcm_dir 12033 * Direction. 12034 * Access: Index 12035 */ 12036 MLXSW_ITEM32(reg, sbcm, dir, 0x00, 0, 2); 12037 12038 /* reg_sbcm_min_buff 12039 * Minimum buffer size for the limiter, in cells. 12040 * Access: RW 12041 */ 12042 MLXSW_ITEM32(reg, sbcm, min_buff, 0x18, 0, 24); 12043 12044 /* shared max_buff limits for dynamic threshold for SBCM, SBPM */ 12045 #define MLXSW_REG_SBXX_DYN_MAX_BUFF_MIN 1 12046 #define MLXSW_REG_SBXX_DYN_MAX_BUFF_MAX 14 12047 12048 /* reg_sbcm_infi_max 12049 * Max buffer is infinite. 12050 * Access: RW 12051 */ 12052 MLXSW_ITEM32(reg, sbcm, infi_max, 0x1C, 31, 1); 12053 12054 /* reg_sbcm_max_buff 12055 * When the pool associated to the port-pg/tclass is configured to 12056 * static, Maximum buffer size for the limiter configured in cells. 12057 * When the pool associated to the port-pg/tclass is configured to 12058 * dynamic, the max_buff holds the "alpha" parameter, supporting 12059 * the following values: 12060 * 0: 0 12061 * i: (1/128)*2^(i-1), for i=1..14 12062 * 0xFF: Infinity 12063 * Reserved when infi_max = 1. 12064 * Access: RW 12065 */ 12066 MLXSW_ITEM32(reg, sbcm, max_buff, 0x1C, 0, 24); 12067 12068 /* reg_sbcm_pool 12069 * Association of the port-priority to a pool. 12070 * Access: RW 12071 */ 12072 MLXSW_ITEM32(reg, sbcm, pool, 0x24, 0, 4); 12073 12074 static inline void mlxsw_reg_sbcm_pack(char *payload, u16 local_port, u8 pg_buff, 12075 enum mlxsw_reg_sbxx_dir dir, 12076 u32 min_buff, u32 max_buff, 12077 bool infi_max, u8 pool) 12078 { 12079 MLXSW_REG_ZERO(sbcm, payload); 12080 mlxsw_reg_sbcm_local_port_set(payload, local_port); 12081 mlxsw_reg_sbcm_pg_buff_set(payload, pg_buff); 12082 mlxsw_reg_sbcm_dir_set(payload, dir); 12083 mlxsw_reg_sbcm_min_buff_set(payload, min_buff); 12084 mlxsw_reg_sbcm_max_buff_set(payload, max_buff); 12085 mlxsw_reg_sbcm_infi_max_set(payload, infi_max); 12086 mlxsw_reg_sbcm_pool_set(payload, pool); 12087 } 12088 12089 /* SBPM - Shared Buffer Port Management Register 12090 * --------------------------------------------- 12091 * The SBPM register configures and retrieves the shared buffer allocation 12092 * and configuration according to Port-Pool, including the definition 12093 * of the associated quota. 12094 */ 12095 #define MLXSW_REG_SBPM_ID 0xB003 12096 #define MLXSW_REG_SBPM_LEN 0x28 12097 12098 MLXSW_REG_DEFINE(sbpm, MLXSW_REG_SBPM_ID, MLXSW_REG_SBPM_LEN); 12099 12100 /* reg_sbpm_local_port 12101 * Local port number. 12102 * For Ingress: excludes CPU port and Router port 12103 * For Egress: excludes IP Router 12104 * Access: Index 12105 */ 12106 MLXSW_ITEM32_LP(reg, sbpm, 0x00, 16, 0x00, 12); 12107 12108 /* reg_sbpm_pool 12109 * The pool associated to quota counting on the local_port. 12110 * Access: Index 12111 */ 12112 MLXSW_ITEM32(reg, sbpm, pool, 0x00, 8, 4); 12113 12114 /* reg_sbpm_dir 12115 * Direction. 12116 * Access: Index 12117 */ 12118 MLXSW_ITEM32(reg, sbpm, dir, 0x00, 0, 2); 12119 12120 /* reg_sbpm_buff_occupancy 12121 * Current buffer occupancy in cells. 12122 * Access: RO 12123 */ 12124 MLXSW_ITEM32(reg, sbpm, buff_occupancy, 0x10, 0, 24); 12125 12126 /* reg_sbpm_clr 12127 * Clear Max Buffer Occupancy 12128 * When this bit is set, max_buff_occupancy field is cleared (and a 12129 * new max value is tracked from the time the clear was performed). 12130 * Access: OP 12131 */ 12132 MLXSW_ITEM32(reg, sbpm, clr, 0x14, 31, 1); 12133 12134 /* reg_sbpm_max_buff_occupancy 12135 * Maximum value of buffer occupancy in cells monitored. Cleared by 12136 * writing to the clr field. 12137 * Access: RO 12138 */ 12139 MLXSW_ITEM32(reg, sbpm, max_buff_occupancy, 0x14, 0, 24); 12140 12141 /* reg_sbpm_min_buff 12142 * Minimum buffer size for the limiter, in cells. 12143 * Access: RW 12144 */ 12145 MLXSW_ITEM32(reg, sbpm, min_buff, 0x18, 0, 24); 12146 12147 /* reg_sbpm_max_buff 12148 * When the pool associated to the port-pg/tclass is configured to 12149 * static, Maximum buffer size for the limiter configured in cells. 12150 * When the pool associated to the port-pg/tclass is configured to 12151 * dynamic, the max_buff holds the "alpha" parameter, supporting 12152 * the following values: 12153 * 0: 0 12154 * i: (1/128)*2^(i-1), for i=1..14 12155 * 0xFF: Infinity 12156 * Access: RW 12157 */ 12158 MLXSW_ITEM32(reg, sbpm, max_buff, 0x1C, 0, 24); 12159 12160 static inline void mlxsw_reg_sbpm_pack(char *payload, u16 local_port, u8 pool, 12161 enum mlxsw_reg_sbxx_dir dir, bool clr, 12162 u32 min_buff, u32 max_buff) 12163 { 12164 MLXSW_REG_ZERO(sbpm, payload); 12165 mlxsw_reg_sbpm_local_port_set(payload, local_port); 12166 mlxsw_reg_sbpm_pool_set(payload, pool); 12167 mlxsw_reg_sbpm_dir_set(payload, dir); 12168 mlxsw_reg_sbpm_clr_set(payload, clr); 12169 mlxsw_reg_sbpm_min_buff_set(payload, min_buff); 12170 mlxsw_reg_sbpm_max_buff_set(payload, max_buff); 12171 } 12172 12173 static inline void mlxsw_reg_sbpm_unpack(char *payload, u32 *p_buff_occupancy, 12174 u32 *p_max_buff_occupancy) 12175 { 12176 *p_buff_occupancy = mlxsw_reg_sbpm_buff_occupancy_get(payload); 12177 *p_max_buff_occupancy = mlxsw_reg_sbpm_max_buff_occupancy_get(payload); 12178 } 12179 12180 /* SBMM - Shared Buffer Multicast Management Register 12181 * -------------------------------------------------- 12182 * The SBMM register configures and retrieves the shared buffer allocation 12183 * and configuration for MC packets according to Switch-Priority, including 12184 * the binding to pool and definition of the associated quota. 12185 */ 12186 #define MLXSW_REG_SBMM_ID 0xB004 12187 #define MLXSW_REG_SBMM_LEN 0x28 12188 12189 MLXSW_REG_DEFINE(sbmm, MLXSW_REG_SBMM_ID, MLXSW_REG_SBMM_LEN); 12190 12191 /* reg_sbmm_prio 12192 * Switch Priority. 12193 * Access: Index 12194 */ 12195 MLXSW_ITEM32(reg, sbmm, prio, 0x00, 8, 4); 12196 12197 /* reg_sbmm_min_buff 12198 * Minimum buffer size for the limiter, in cells. 12199 * Access: RW 12200 */ 12201 MLXSW_ITEM32(reg, sbmm, min_buff, 0x18, 0, 24); 12202 12203 /* reg_sbmm_max_buff 12204 * When the pool associated to the port-pg/tclass is configured to 12205 * static, Maximum buffer size for the limiter configured in cells. 12206 * When the pool associated to the port-pg/tclass is configured to 12207 * dynamic, the max_buff holds the "alpha" parameter, supporting 12208 * the following values: 12209 * 0: 0 12210 * i: (1/128)*2^(i-1), for i=1..14 12211 * 0xFF: Infinity 12212 * Access: RW 12213 */ 12214 MLXSW_ITEM32(reg, sbmm, max_buff, 0x1C, 0, 24); 12215 12216 /* reg_sbmm_pool 12217 * Association of the port-priority to a pool. 12218 * Access: RW 12219 */ 12220 MLXSW_ITEM32(reg, sbmm, pool, 0x24, 0, 4); 12221 12222 static inline void mlxsw_reg_sbmm_pack(char *payload, u8 prio, u32 min_buff, 12223 u32 max_buff, u8 pool) 12224 { 12225 MLXSW_REG_ZERO(sbmm, payload); 12226 mlxsw_reg_sbmm_prio_set(payload, prio); 12227 mlxsw_reg_sbmm_min_buff_set(payload, min_buff); 12228 mlxsw_reg_sbmm_max_buff_set(payload, max_buff); 12229 mlxsw_reg_sbmm_pool_set(payload, pool); 12230 } 12231 12232 /* SBSR - Shared Buffer Status Register 12233 * ------------------------------------ 12234 * The SBSR register retrieves the shared buffer occupancy according to 12235 * Port-Pool. Note that this register enables reading a large amount of data. 12236 * It is the user's responsibility to limit the amount of data to ensure the 12237 * response can match the maximum transfer unit. In case the response exceeds 12238 * the maximum transport unit, it will be truncated with no special notice. 12239 */ 12240 #define MLXSW_REG_SBSR_ID 0xB005 12241 #define MLXSW_REG_SBSR_BASE_LEN 0x5C /* base length, without records */ 12242 #define MLXSW_REG_SBSR_REC_LEN 0x8 /* record length */ 12243 #define MLXSW_REG_SBSR_REC_MAX_COUNT 120 12244 #define MLXSW_REG_SBSR_LEN (MLXSW_REG_SBSR_BASE_LEN + \ 12245 MLXSW_REG_SBSR_REC_LEN * \ 12246 MLXSW_REG_SBSR_REC_MAX_COUNT) 12247 12248 MLXSW_REG_DEFINE(sbsr, MLXSW_REG_SBSR_ID, MLXSW_REG_SBSR_LEN); 12249 12250 /* reg_sbsr_clr 12251 * Clear Max Buffer Occupancy. When this bit is set, the max_buff_occupancy 12252 * field is cleared (and a new max value is tracked from the time the clear 12253 * was performed). 12254 * Access: OP 12255 */ 12256 MLXSW_ITEM32(reg, sbsr, clr, 0x00, 31, 1); 12257 12258 #define MLXSW_REG_SBSR_NUM_PORTS_IN_PAGE 256 12259 12260 /* reg_sbsr_port_page 12261 * Determines the range of the ports specified in the 'ingress_port_mask' 12262 * and 'egress_port_mask' bit masks. 12263 * {ingress,egress}_port_mask[x] is (256 * port_page) + x 12264 * Access: Index 12265 */ 12266 MLXSW_ITEM32(reg, sbsr, port_page, 0x04, 0, 4); 12267 12268 /* reg_sbsr_ingress_port_mask 12269 * Bit vector for all ingress network ports. 12270 * Indicates which of the ports (for which the relevant bit is set) 12271 * are affected by the set operation. Configuration of any other port 12272 * does not change. 12273 * Access: Index 12274 */ 12275 MLXSW_ITEM_BIT_ARRAY(reg, sbsr, ingress_port_mask, 0x10, 0x20, 1); 12276 12277 /* reg_sbsr_pg_buff_mask 12278 * Bit vector for all switch priority groups. 12279 * Indicates which of the priorities (for which the relevant bit is set) 12280 * are affected by the set operation. Configuration of any other priority 12281 * does not change. 12282 * Range is 0..cap_max_pg_buffers - 1 12283 * Access: Index 12284 */ 12285 MLXSW_ITEM_BIT_ARRAY(reg, sbsr, pg_buff_mask, 0x30, 0x4, 1); 12286 12287 /* reg_sbsr_egress_port_mask 12288 * Bit vector for all egress network ports. 12289 * Indicates which of the ports (for which the relevant bit is set) 12290 * are affected by the set operation. Configuration of any other port 12291 * does not change. 12292 * Access: Index 12293 */ 12294 MLXSW_ITEM_BIT_ARRAY(reg, sbsr, egress_port_mask, 0x34, 0x20, 1); 12295 12296 /* reg_sbsr_tclass_mask 12297 * Bit vector for all traffic classes. 12298 * Indicates which of the traffic classes (for which the relevant bit is 12299 * set) are affected by the set operation. Configuration of any other 12300 * traffic class does not change. 12301 * Range is 0..cap_max_tclass - 1 12302 * Access: Index 12303 */ 12304 MLXSW_ITEM_BIT_ARRAY(reg, sbsr, tclass_mask, 0x54, 0x8, 1); 12305 12306 static inline void mlxsw_reg_sbsr_pack(char *payload, bool clr) 12307 { 12308 MLXSW_REG_ZERO(sbsr, payload); 12309 mlxsw_reg_sbsr_clr_set(payload, clr); 12310 } 12311 12312 /* reg_sbsr_rec_buff_occupancy 12313 * Current buffer occupancy in cells. 12314 * Access: RO 12315 */ 12316 MLXSW_ITEM32_INDEXED(reg, sbsr, rec_buff_occupancy, MLXSW_REG_SBSR_BASE_LEN, 12317 0, 24, MLXSW_REG_SBSR_REC_LEN, 0x00, false); 12318 12319 /* reg_sbsr_rec_max_buff_occupancy 12320 * Maximum value of buffer occupancy in cells monitored. Cleared by 12321 * writing to the clr field. 12322 * Access: RO 12323 */ 12324 MLXSW_ITEM32_INDEXED(reg, sbsr, rec_max_buff_occupancy, MLXSW_REG_SBSR_BASE_LEN, 12325 0, 24, MLXSW_REG_SBSR_REC_LEN, 0x04, false); 12326 12327 static inline void mlxsw_reg_sbsr_rec_unpack(char *payload, int rec_index, 12328 u32 *p_buff_occupancy, 12329 u32 *p_max_buff_occupancy) 12330 { 12331 *p_buff_occupancy = 12332 mlxsw_reg_sbsr_rec_buff_occupancy_get(payload, rec_index); 12333 *p_max_buff_occupancy = 12334 mlxsw_reg_sbsr_rec_max_buff_occupancy_get(payload, rec_index); 12335 } 12336 12337 /* SBIB - Shared Buffer Internal Buffer Register 12338 * --------------------------------------------- 12339 * The SBIB register configures per port buffers for internal use. The internal 12340 * buffers consume memory on the port buffers (note that the port buffers are 12341 * used also by PBMC). 12342 * 12343 * For Spectrum this is used for egress mirroring. 12344 */ 12345 #define MLXSW_REG_SBIB_ID 0xB006 12346 #define MLXSW_REG_SBIB_LEN 0x10 12347 12348 MLXSW_REG_DEFINE(sbib, MLXSW_REG_SBIB_ID, MLXSW_REG_SBIB_LEN); 12349 12350 /* reg_sbib_local_port 12351 * Local port number 12352 * Not supported for CPU port and router port 12353 * Access: Index 12354 */ 12355 MLXSW_ITEM32_LP(reg, sbib, 0x00, 16, 0x00, 12); 12356 12357 /* reg_sbib_buff_size 12358 * Units represented in cells 12359 * Allowed range is 0 to (cap_max_headroom_size - 1) 12360 * Default is 0 12361 * Access: RW 12362 */ 12363 MLXSW_ITEM32(reg, sbib, buff_size, 0x08, 0, 24); 12364 12365 static inline void mlxsw_reg_sbib_pack(char *payload, u16 local_port, 12366 u32 buff_size) 12367 { 12368 MLXSW_REG_ZERO(sbib, payload); 12369 mlxsw_reg_sbib_local_port_set(payload, local_port); 12370 mlxsw_reg_sbib_buff_size_set(payload, buff_size); 12371 } 12372 12373 static const struct mlxsw_reg_info *mlxsw_reg_infos[] = { 12374 MLXSW_REG(sgcr), 12375 MLXSW_REG(spad), 12376 MLXSW_REG(sspr), 12377 MLXSW_REG(sfdat), 12378 MLXSW_REG(sfd), 12379 MLXSW_REG(sfn), 12380 MLXSW_REG(spms), 12381 MLXSW_REG(spvid), 12382 MLXSW_REG(spvm), 12383 MLXSW_REG(spaft), 12384 MLXSW_REG(sfgc), 12385 MLXSW_REG(sfdf), 12386 MLXSW_REG(sldr), 12387 MLXSW_REG(slcr), 12388 MLXSW_REG(slcor), 12389 MLXSW_REG(spmlr), 12390 MLXSW_REG(svfa), 12391 MLXSW_REG(spvtr), 12392 MLXSW_REG(svpe), 12393 MLXSW_REG(sfmr), 12394 MLXSW_REG(spvmlr), 12395 MLXSW_REG(spvc), 12396 MLXSW_REG(spevet), 12397 MLXSW_REG(sftr2), 12398 MLXSW_REG(smid2), 12399 MLXSW_REG(cwtp), 12400 MLXSW_REG(cwtpm), 12401 MLXSW_REG(pgcr), 12402 MLXSW_REG(ppbt), 12403 MLXSW_REG(pacl), 12404 MLXSW_REG(pagt), 12405 MLXSW_REG(ptar), 12406 MLXSW_REG(ppbs), 12407 MLXSW_REG(prcr), 12408 MLXSW_REG(pefa), 12409 MLXSW_REG(pemrbt), 12410 MLXSW_REG(ptce2), 12411 MLXSW_REG(perpt), 12412 MLXSW_REG(peabfe), 12413 MLXSW_REG(perar), 12414 MLXSW_REG(ptce3), 12415 MLXSW_REG(percr), 12416 MLXSW_REG(pererp), 12417 MLXSW_REG(iedr), 12418 MLXSW_REG(qpts), 12419 MLXSW_REG(qpcr), 12420 MLXSW_REG(qtct), 12421 MLXSW_REG(qeec), 12422 MLXSW_REG(qrwe), 12423 MLXSW_REG(qpdsm), 12424 MLXSW_REG(qpdp), 12425 MLXSW_REG(qpdpm), 12426 MLXSW_REG(qtctm), 12427 MLXSW_REG(qpsc), 12428 MLXSW_REG(pmlp), 12429 MLXSW_REG(pmtu), 12430 MLXSW_REG(ptys), 12431 MLXSW_REG(ppad), 12432 MLXSW_REG(paos), 12433 MLXSW_REG(pfcc), 12434 MLXSW_REG(ppcnt), 12435 MLXSW_REG(plib), 12436 MLXSW_REG(pptb), 12437 MLXSW_REG(pbmc), 12438 MLXSW_REG(pspa), 12439 MLXSW_REG(pmaos), 12440 MLXSW_REG(pplr), 12441 MLXSW_REG(pmtdb), 12442 MLXSW_REG(pmpe), 12443 MLXSW_REG(pddr), 12444 MLXSW_REG(pmmp), 12445 MLXSW_REG(pllp), 12446 MLXSW_REG(htgt), 12447 MLXSW_REG(hpkt), 12448 MLXSW_REG(rgcr), 12449 MLXSW_REG(ritr), 12450 MLXSW_REG(rtar), 12451 MLXSW_REG(ratr), 12452 MLXSW_REG(rtdp), 12453 MLXSW_REG(rips), 12454 MLXSW_REG(ratrad), 12455 MLXSW_REG(rdpm), 12456 MLXSW_REG(ricnt), 12457 MLXSW_REG(rrcr), 12458 MLXSW_REG(ralta), 12459 MLXSW_REG(ralst), 12460 MLXSW_REG(raltb), 12461 MLXSW_REG(ralue), 12462 MLXSW_REG(rauht), 12463 MLXSW_REG(raleu), 12464 MLXSW_REG(rauhtd), 12465 MLXSW_REG(rigr2), 12466 MLXSW_REG(recr2), 12467 MLXSW_REG(rmft2), 12468 MLXSW_REG(rxlte), 12469 MLXSW_REG(rxltm), 12470 MLXSW_REG(rlcmld), 12471 MLXSW_REG(rlpmce), 12472 MLXSW_REG(xltq), 12473 MLXSW_REG(xmdr), 12474 MLXSW_REG(xrmt), 12475 MLXSW_REG(xralta), 12476 MLXSW_REG(xralst), 12477 MLXSW_REG(xraltb), 12478 MLXSW_REG(mfcr), 12479 MLXSW_REG(mfsc), 12480 MLXSW_REG(mfsm), 12481 MLXSW_REG(mfsl), 12482 MLXSW_REG(fore), 12483 MLXSW_REG(mtcap), 12484 MLXSW_REG(mtmp), 12485 MLXSW_REG(mtwe), 12486 MLXSW_REG(mtbr), 12487 MLXSW_REG(mcia), 12488 MLXSW_REG(mpat), 12489 MLXSW_REG(mpar), 12490 MLXSW_REG(mgir), 12491 MLXSW_REG(mrsr), 12492 MLXSW_REG(mlcr), 12493 MLXSW_REG(mcion), 12494 MLXSW_REG(mtpps), 12495 MLXSW_REG(mtutc), 12496 MLXSW_REG(mpsc), 12497 MLXSW_REG(mcqi), 12498 MLXSW_REG(mcc), 12499 MLXSW_REG(mcda), 12500 MLXSW_REG(mgpc), 12501 MLXSW_REG(mprs), 12502 MLXSW_REG(mogcr), 12503 MLXSW_REG(mpagr), 12504 MLXSW_REG(momte), 12505 MLXSW_REG(mtpppc), 12506 MLXSW_REG(mtpptr), 12507 MLXSW_REG(mtptpt), 12508 MLXSW_REG(mfgd), 12509 MLXSW_REG(mgpir), 12510 MLXSW_REG(mfde), 12511 MLXSW_REG(tngcr), 12512 MLXSW_REG(tnumt), 12513 MLXSW_REG(tnqcr), 12514 MLXSW_REG(tnqdr), 12515 MLXSW_REG(tneem), 12516 MLXSW_REG(tndem), 12517 MLXSW_REG(tnpc), 12518 MLXSW_REG(tigcr), 12519 MLXSW_REG(tieem), 12520 MLXSW_REG(tidem), 12521 MLXSW_REG(sbpr), 12522 MLXSW_REG(sbcm), 12523 MLXSW_REG(sbpm), 12524 MLXSW_REG(sbmm), 12525 MLXSW_REG(sbsr), 12526 MLXSW_REG(sbib), 12527 }; 12528 12529 static inline const char *mlxsw_reg_id_str(u16 reg_id) 12530 { 12531 const struct mlxsw_reg_info *reg_info; 12532 int i; 12533 12534 for (i = 0; i < ARRAY_SIZE(mlxsw_reg_infos); i++) { 12535 reg_info = mlxsw_reg_infos[i]; 12536 if (reg_info->id == reg_id) 12537 return reg_info->name; 12538 } 12539 return "*UNKNOWN*"; 12540 } 12541 12542 /* PUDE - Port Up / Down Event 12543 * --------------------------- 12544 * Reports the operational state change of a port. 12545 */ 12546 #define MLXSW_REG_PUDE_LEN 0x10 12547 12548 /* reg_pude_swid 12549 * Switch partition ID with which to associate the port. 12550 * Access: Index 12551 */ 12552 MLXSW_ITEM32(reg, pude, swid, 0x00, 24, 8); 12553 12554 /* reg_pude_local_port 12555 * Local port number. 12556 * Access: Index 12557 */ 12558 MLXSW_ITEM32_LP(reg, pude, 0x00, 16, 0x00, 12); 12559 12560 /* reg_pude_admin_status 12561 * Port administrative state (the desired state). 12562 * 1 - Up. 12563 * 2 - Down. 12564 * 3 - Up once. This means that in case of link failure, the port won't go 12565 * into polling mode, but will wait to be re-enabled by software. 12566 * 4 - Disabled by system. Can only be set by hardware. 12567 * Access: RO 12568 */ 12569 MLXSW_ITEM32(reg, pude, admin_status, 0x00, 8, 4); 12570 12571 /* reg_pude_oper_status 12572 * Port operatioanl state. 12573 * 1 - Up. 12574 * 2 - Down. 12575 * 3 - Down by port failure. This means that the device will not let the 12576 * port up again until explicitly specified by software. 12577 * Access: RO 12578 */ 12579 MLXSW_ITEM32(reg, pude, oper_status, 0x00, 0, 4); 12580 12581 #endif 12582