hw_atl2_utils.h (10705B)
1/* SPDX-License-Identifier: GPL-2.0-only */ 2/* Atlantic Network Driver 3 * Copyright (C) 2020 Marvell International Ltd. 4 */ 5 6#ifndef HW_ATL2_UTILS_H 7#define HW_ATL2_UTILS_H 8 9#include "aq_hw.h" 10 11/* F W A P I */ 12 13struct link_options_s { 14 u8 link_up:1; 15 u8 link_renegotiate:1; 16 u8 minimal_link_speed:1; 17 u8 internal_loopback:1; 18 u8 external_loopback:1; 19 u8 rate_10M_hd:1; 20 u8 rate_100M_hd:1; 21 u8 rate_1G_hd:1; 22 23 u8 rate_10M:1; 24 u8 rate_100M:1; 25 u8 rate_1G:1; 26 u8 rate_2P5G:1; 27 u8 rate_N2P5G:1; 28 u8 rate_5G:1; 29 u8 rate_N5G:1; 30 u8 rate_10G:1; 31 32 u8 eee_100M:1; 33 u8 eee_1G:1; 34 u8 eee_2P5G:1; 35 u8 eee_5G:1; 36 u8 eee_10G:1; 37 u8 rsvd3:3; 38 39 u8 pause_rx:1; 40 u8 pause_tx:1; 41 u8 rsvd4:1; 42 u8 downshift:1; 43 u8 downshift_retry:4; 44}; 45 46struct link_control_s { 47 u8 mode:4; 48 u8 disable_crc_corruption:1; 49 u8 discard_short_frames:1; 50 u8 flow_control_mode:1; 51 u8 disable_length_check:1; 52 53 u8 discard_errored_frames:1; 54 u8 control_frame_enable:1; 55 u8 enable_tx_padding:1; 56 u8 enable_crc_forwarding:1; 57 u8 enable_frame_padding_removal_rx: 1; 58 u8 promiscuous_mode: 1; 59 u8 rsvd:2; 60 61 u16 rsvd2; 62}; 63 64struct thermal_shutdown_s { 65 u8 enable:1; 66 u8 warning_enable:1; 67 u8 rsvd:6; 68 69 u8 shutdown_temperature; 70 u8 cold_temperature; 71 u8 warning_temperature; 72}; 73 74struct mac_address_s { 75 u8 mac_address[6]; 76}; 77 78struct mac_address_aligned_s { 79 struct mac_address_s aligned; 80 u16 rsvd; 81}; 82 83struct sleep_proxy_s { 84 struct wake_on_lan_s { 85 u8 wake_on_magic_packet:1; 86 u8 wake_on_pattern:1; 87 u8 wake_on_link_up:1; 88 u8 wake_on_link_down:1; 89 u8 wake_on_ping:1; 90 u8 wake_on_timer:1; 91 u8 rsvd:2; 92 93 u8 rsvd2; 94 u16 rsvd3; 95 96 u32 link_up_timeout; 97 u32 link_down_timeout; 98 u32 timer; 99 } wake_on_lan; 100 101 struct { 102 u32 mask[4]; 103 u32 crc32; 104 } wake_up_pattern[8]; 105 106 struct __packed { 107 u8 arp_responder:1; 108 u8 echo_responder:1; 109 u8 igmp_client:1; 110 u8 echo_truncate:1; 111 u8 address_guard:1; 112 u8 ignore_fragmented:1; 113 u8 rsvd:2; 114 115 u16 echo_max_len; 116 u8 rsvd2; 117 } ipv4_offload; 118 119 u32 ipv4_offload_addr[8]; 120 u32 reserved[8]; 121 122 struct __packed { 123 u8 ns_responder:1; 124 u8 echo_responder:1; 125 u8 mld_client:1; 126 u8 echo_truncate:1; 127 u8 address_guard:1; 128 u8 rsvd:3; 129 130 u16 echo_max_len; 131 u8 rsvd2; 132 } ipv6_offload; 133 134 u32 ipv6_offload_addr[16][4]; 135 136 struct { 137 u16 port[16]; 138 } tcp_port_offload; 139 140 struct { 141 u16 port[16]; 142 } udp_port_offload; 143 144 struct { 145 u32 retry_count; 146 u32 retry_interval; 147 } ka4_offload; 148 149 struct { 150 u32 timeout; 151 u16 local_port; 152 u16 remote_port; 153 u8 remote_mac_addr[6]; 154 u16 rsvd; 155 u32 rsvd2; 156 u32 rsvd3; 157 u16 rsvd4; 158 u16 win_size; 159 u32 seq_num; 160 u32 ack_num; 161 u32 local_ip; 162 u32 remote_ip; 163 } ka4_connection[16]; 164 165 struct { 166 u32 retry_count; 167 u32 retry_interval; 168 } ka6_offload; 169 170 struct { 171 u32 timeout; 172 u16 local_port; 173 u16 remote_port; 174 u8 remote_mac_addr[6]; 175 u16 rsvd; 176 u32 rsvd2; 177 u32 rsvd3; 178 u16 rsvd4; 179 u16 win_size; 180 u32 seq_num; 181 u32 ack_num; 182 u32 local_ip[4]; 183 u32 remote_ip[4]; 184 } ka6_connection[16]; 185 186 struct { 187 u32 rr_count; 188 u32 rr_buf_len; 189 u32 idx_offset; 190 u32 rr__offset; 191 } mdns_offload; 192}; 193 194struct pause_quanta_s { 195 u16 quanta_10M; 196 u16 threshold_10M; 197 u16 quanta_100M; 198 u16 threshold_100M; 199 u16 quanta_1G; 200 u16 threshold_1G; 201 u16 quanta_2P5G; 202 u16 threshold_2P5G; 203 u16 quanta_5G; 204 u16 threshold_5G; 205 u16 quanta_10G; 206 u16 threshold_10G; 207}; 208 209struct data_buffer_status_s { 210 u32 data_offset; 211 u32 data_length; 212}; 213 214struct device_caps_s { 215 u8 finite_flashless:1; 216 u8 cable_diag:1; 217 u8 ncsi:1; 218 u8 avb:1; 219 u8 rsvd:4; 220 221 u8 rsvd2; 222 u16 rsvd3; 223 u32 rsvd4; 224}; 225 226struct version_s { 227 struct bundle_version_t { 228 u8 major; 229 u8 minor; 230 u16 build; 231 } bundle; 232 struct mac_version_t { 233 u8 major; 234 u8 minor; 235 u16 build; 236 } mac; 237 struct phy_version_t { 238 u8 major; 239 u8 minor; 240 u16 build; 241 } phy; 242 u32 drv_iface_ver:4; 243 u32 rsvd:28; 244}; 245 246struct link_status_s { 247 u8 link_state:4; 248 u8 link_rate:4; 249 250 u8 pause_tx:1; 251 u8 pause_rx:1; 252 u8 eee:1; 253 u8 duplex:1; 254 u8 rsvd:4; 255 256 u16 rsvd2; 257}; 258 259struct wol_status_s { 260 u8 wake_count; 261 u8 wake_reason; 262 263 u16 wake_up_packet_length :12; 264 u16 wake_up_pattern_number :3; 265 u16 rsvd:1; 266 267 u32 wake_up_packet[379]; 268}; 269 270struct mac_health_monitor_s { 271 u8 mac_ready:1; 272 u8 mac_fault:1; 273 u8 mac_flashless_finished:1; 274 u8 rsvd:5; 275 276 u8 mac_temperature; 277 u16 mac_heart_beat; 278 u16 mac_fault_code; 279 u16 rsvd2; 280}; 281 282struct phy_health_monitor_s { 283 u8 phy_ready:1; 284 u8 phy_fault:1; 285 u8 phy_hot_warning:1; 286 u8 rsvd:5; 287 288 u8 phy_temperature; 289 u16 phy_heart_beat; 290 u16 phy_fault_code; 291 u16 rsvd2; 292}; 293 294struct device_link_caps_s { 295 u8 rsvd:3; 296 u8 internal_loopback:1; 297 u8 external_loopback:1; 298 u8 rate_10M_hd:1; 299 u8 rate_100M_hd:1; 300 u8 rate_1G_hd:1; 301 302 u8 rate_10M:1; 303 u8 rate_100M:1; 304 u8 rate_1G:1; 305 u8 rate_2P5G:1; 306 u8 rate_N2P5G:1; 307 u8 rate_5G:1; 308 u8 rate_N5G:1; 309 u8 rate_10G:1; 310 311 u8 rsvd3:1; 312 u8 eee_100M:1; 313 u8 eee_1G:1; 314 u8 eee_2P5G:1; 315 u8 rsvd4:1; 316 u8 eee_5G:1; 317 u8 rsvd5:1; 318 u8 eee_10G:1; 319 320 u8 pause_rx:1; 321 u8 pause_tx:1; 322 u8 pfc:1; 323 u8 downshift:1; 324 u8 downshift_retry:4; 325}; 326 327struct sleep_proxy_caps_s { 328 u8 ipv4_offload:1; 329 u8 ipv6_offload:1; 330 u8 tcp_port_offload:1; 331 u8 udp_port_offload:1; 332 u8 ka4_offload:1; 333 u8 ka6_offload:1; 334 u8 mdns_offload:1; 335 u8 wake_on_ping:1; 336 337 u8 wake_on_magic_packet:1; 338 u8 wake_on_pattern:1; 339 u8 wake_on_timer:1; 340 u8 wake_on_link:1; 341 u8 wake_patterns_count:4; 342 343 u8 ipv4_count; 344 u8 ipv6_count; 345 346 u8 tcp_port_offload_count; 347 u8 udp_port_offload_count; 348 349 u8 tcp4_ka_count; 350 u8 tcp6_ka_count; 351 352 u8 igmp_offload:1; 353 u8 mld_offload:1; 354 u8 rsvd:6; 355 356 u8 rsvd2; 357 u16 rsvd3; 358}; 359 360struct lkp_link_caps_s { 361 u8 rsvd:5; 362 u8 rate_10M_hd:1; 363 u8 rate_100M_hd:1; 364 u8 rate_1G_hd:1; 365 366 u8 rate_10M:1; 367 u8 rate_100M:1; 368 u8 rate_1G:1; 369 u8 rate_2P5G:1; 370 u8 rate_N2P5G:1; 371 u8 rate_5G:1; 372 u8 rate_N5G:1; 373 u8 rate_10G:1; 374 375 u8 rsvd2:1; 376 u8 eee_100M:1; 377 u8 eee_1G:1; 378 u8 eee_2P5G:1; 379 u8 rsvd3:1; 380 u8 eee_5G:1; 381 u8 rsvd4:1; 382 u8 eee_10G:1; 383 384 u8 pause_rx:1; 385 u8 pause_tx:1; 386 u8 rsvd5:6; 387}; 388 389struct core_dump_s { 390 u32 reg0; 391 u32 reg1; 392 u32 reg2; 393 394 u32 hi; 395 u32 lo; 396 397 u32 regs[32]; 398}; 399 400struct trace_s { 401 u32 sync_counter; 402 u32 mem_buffer[0x1ff]; 403}; 404 405struct cable_diag_control_s { 406 u8 toggle :1; 407 u8 rsvd:7; 408 409 u8 wait_timeout_sec; 410 u16 rsvd2; 411}; 412 413struct cable_diag_lane_data_s { 414 u8 result_code; 415 u8 dist; 416 u8 far_dist; 417 u8 rsvd; 418}; 419 420struct cable_diag_status_s { 421 struct cable_diag_lane_data_s lane_data[4]; 422 u8 transact_id; 423 u8 status:4; 424 u8 rsvd:4; 425 u16 rsvd2; 426}; 427 428struct statistics_a0_s { 429 struct { 430 u32 link_up; 431 u32 link_down; 432 } link; 433 434 struct { 435 u64 tx_unicast_octets; 436 u64 tx_multicast_octets; 437 u64 tx_broadcast_octets; 438 u64 rx_unicast_octets; 439 u64 rx_multicast_octets; 440 u64 rx_broadcast_octets; 441 442 u32 tx_unicast_frames; 443 u32 tx_multicast_frames; 444 u32 tx_broadcast_frames; 445 u32 tx_errors; 446 447 u32 rx_unicast_frames; 448 u32 rx_multicast_frames; 449 u32 rx_broadcast_frames; 450 u32 rx_dropped_frames; 451 u32 rx_error_frames; 452 453 u32 tx_good_frames; 454 u32 rx_good_frames; 455 u32 reserve_fw_gap; 456 } msm; 457 u32 main_loop_cycles; 458 u32 reserve_fw_gap; 459}; 460 461struct __packed statistics_b0_s { 462 u64 rx_good_octets; 463 u64 rx_pause_frames; 464 u64 rx_good_frames; 465 u64 rx_errors; 466 u64 rx_unicast_frames; 467 u64 rx_multicast_frames; 468 u64 rx_broadcast_frames; 469 470 u64 tx_good_octets; 471 u64 tx_pause_frames; 472 u64 tx_good_frames; 473 u64 tx_errors; 474 u64 tx_unicast_frames; 475 u64 tx_multicast_frames; 476 u64 tx_broadcast_frames; 477 478 u32 main_loop_cycles; 479}; 480 481struct __packed statistics_s { 482 union __packed { 483 struct statistics_a0_s a0; 484 struct statistics_b0_s b0; 485 }; 486}; 487 488struct filter_caps_s { 489 u8 l2_filters_base_index:6; 490 u8 flexible_filter_mask:2; 491 u8 l2_filter_count; 492 u8 ethertype_filter_base_index; 493 u8 ethertype_filter_count; 494 495 u8 vlan_filter_base_index; 496 u8 vlan_filter_count; 497 u8 l3_ip4_filter_base_index:4; 498 u8 l3_ip4_filter_count:4; 499 u8 l3_ip6_filter_base_index:4; 500 u8 l3_ip6_filter_count:4; 501 502 u8 l4_filter_base_index:4; 503 u8 l4_filter_count:4; 504 u8 l4_flex_filter_base_index:4; 505 u8 l4_flex_filter_count:4; 506 u8 rslv_tbl_base_index; 507 u8 rslv_tbl_count; 508}; 509 510struct request_policy_s { 511 struct { 512 u8 all:1; 513 u8 mcast:1; 514 u8 rx_queue_tc_index:5; 515 u8 queue_or_tc:1; 516 } promisc; 517 518 struct { 519 u8 accept:1; 520 u8 rsvd:1; 521 u8 rx_queue_tc_index:5; 522 u8 queue_or_tc:1; 523 } bcast; 524 525 struct { 526 u8 accept:1; 527 u8 rsvd:1; 528 u8 rx_queue_tc_index:5; 529 u8 queue_or_tc:1; 530 } mcast; 531 532 u8 rsvd:8; 533}; 534 535struct fw_interface_in { 536 u32 mtu; 537 u32 rsvd1; 538 struct mac_address_aligned_s mac_address; 539 struct link_control_s link_control; 540 u32 rsvd2; 541 struct link_options_s link_options; 542 u32 rsvd3; 543 struct thermal_shutdown_s thermal_shutdown; 544 u32 rsvd4; 545 struct sleep_proxy_s sleep_proxy; 546 u32 rsvd5; 547 struct pause_quanta_s pause_quanta[8]; 548 struct cable_diag_control_s cable_diag_control; 549 u32 rsvd6; 550 struct data_buffer_status_s data_buffer_status; 551 u32 rsvd7; 552 struct request_policy_s request_policy; 553}; 554 555struct transaction_counter_s { 556 u16 transaction_cnt_a; 557 u16 transaction_cnt_b; 558}; 559 560struct management_status_s { 561 struct mac_address_s mac_address; 562 u16 vlan; 563 564 struct{ 565 u32 enable : 1; 566 u32 rsvd:31; 567 } flags; 568 569 u32 rsvd1; 570 u32 rsvd2; 571 u32 rsvd3; 572 u32 rsvd4; 573 u32 rsvd5; 574}; 575 576struct __packed fw_interface_out { 577 struct transaction_counter_s transaction_id; 578 struct version_s version; 579 struct link_status_s link_status; 580 struct wol_status_s wol_status; 581 u32 rsvd; 582 u32 rsvd2; 583 struct mac_health_monitor_s mac_health_monitor; 584 u32 rsvd3; 585 u32 rsvd4; 586 struct phy_health_monitor_s phy_health_monitor; 587 u32 rsvd5; 588 u32 rsvd6; 589 struct cable_diag_status_s cable_diag_status; 590 u32 rsvd7; 591 struct device_link_caps_s device_link_caps; 592 u32 rsvd8; 593 struct sleep_proxy_caps_s sleep_proxy_caps; 594 u32 rsvd9; 595 struct lkp_link_caps_s lkp_link_caps; 596 u32 rsvd10; 597 struct core_dump_s core_dump; 598 u32 rsvd11; 599 struct statistics_s stats; 600 struct filter_caps_s filter_caps; 601 struct device_caps_s device_caps; 602 u32 rsvd13; 603 struct management_status_s management_status; 604 u32 reserve[21]; 605 struct trace_s trace; 606}; 607 608#define AQ_A2_FW_LINK_RATE_INVALID 0 609#define AQ_A2_FW_LINK_RATE_10M 1 610#define AQ_A2_FW_LINK_RATE_100M 2 611#define AQ_A2_FW_LINK_RATE_1G 3 612#define AQ_A2_FW_LINK_RATE_2G5 4 613#define AQ_A2_FW_LINK_RATE_5G 5 614#define AQ_A2_FW_LINK_RATE_10G 6 615 616#define AQ_HOST_MODE_INVALID 0U 617#define AQ_HOST_MODE_ACTIVE 1U 618#define AQ_HOST_MODE_SLEEP_PROXY 2U 619#define AQ_HOST_MODE_LOW_POWER 3U 620#define AQ_HOST_MODE_SHUTDOWN 4U 621 622#define AQ_A2_FW_INTERFACE_A0 0 623#define AQ_A2_FW_INTERFACE_B0 1 624 625int hw_atl2_utils_initfw(struct aq_hw_s *self, const struct aq_fw_ops **fw_ops); 626 627int hw_atl2_utils_soft_reset(struct aq_hw_s *self); 628 629u32 hw_atl2_utils_get_fw_version(struct aq_hw_s *self); 630 631int hw_atl2_utils_get_action_resolve_table_caps(struct aq_hw_s *self, 632 u8 *base_index, u8 *count); 633 634extern const struct aq_fw_ops aq_a2_fw_ops; 635 636#endif /* HW_ATL2_UTILS_H */