| .. | .. |
|---|
| 1 | | -/* |
|---|
| 2 | | - * aQuantia Corporation Network Driver |
|---|
| 3 | | - * Copyright (C) 2014-2017 aQuantia Corporation. All rights reserved |
|---|
| 1 | +/* SPDX-License-Identifier: GPL-2.0-only */ |
|---|
| 2 | +/* Atlantic Network Driver |
|---|
| 4 | 3 | * |
|---|
| 5 | | - * This program is free software; you can redistribute it and/or modify it |
|---|
| 6 | | - * under the terms and conditions of the GNU General Public License, |
|---|
| 7 | | - * version 2, as published by the Free Software Foundation. |
|---|
| 4 | + * Copyright (C) 2014-2019 aQuantia Corporation |
|---|
| 5 | + * Copyright (C) 2019-2020 Marvell International Ltd. |
|---|
| 8 | 6 | */ |
|---|
| 9 | 7 | |
|---|
| 10 | 8 | /* File aq_hw.h: Declaration of abstract interface for NIC hardware specific |
|---|
| .. | .. |
|---|
| 17 | 15 | #include "aq_common.h" |
|---|
| 18 | 16 | #include "aq_rss.h" |
|---|
| 19 | 17 | #include "hw_atl/hw_atl_utils.h" |
|---|
| 18 | + |
|---|
| 19 | +#define AQ_HW_MAC_COUNTER_HZ 312500000ll |
|---|
| 20 | +#define AQ_HW_PHY_COUNTER_HZ 160000000ll |
|---|
| 21 | + |
|---|
| 22 | +enum aq_tc_mode { |
|---|
| 23 | + AQ_TC_MODE_INVALID = -1, |
|---|
| 24 | + AQ_TC_MODE_8TCS, |
|---|
| 25 | + AQ_TC_MODE_4TCS, |
|---|
| 26 | +}; |
|---|
| 27 | + |
|---|
| 28 | +#define AQ_RX_FIRST_LOC_FVLANID 0U |
|---|
| 29 | +#define AQ_RX_LAST_LOC_FVLANID 15U |
|---|
| 30 | +#define AQ_RX_FIRST_LOC_FETHERT 16U |
|---|
| 31 | +#define AQ_RX_LAST_LOC_FETHERT 31U |
|---|
| 32 | +#define AQ_RX_FIRST_LOC_FL3L4 32U |
|---|
| 33 | +#define AQ_RX_LAST_LOC_FL3L4 39U |
|---|
| 34 | +#define AQ_RX_MAX_RXNFC_LOC AQ_RX_LAST_LOC_FL3L4 |
|---|
| 35 | +#define AQ_VLAN_MAX_FILTERS \ |
|---|
| 36 | + (AQ_RX_LAST_LOC_FVLANID - AQ_RX_FIRST_LOC_FVLANID + 1U) |
|---|
| 37 | +#define AQ_RX_QUEUE_NOT_ASSIGNED 0xFFU |
|---|
| 38 | + |
|---|
| 39 | +#define AQ_FRAC_PER_NS 0x100000000LL |
|---|
| 40 | + |
|---|
| 41 | +/* Used for rate to Mbps conversion */ |
|---|
| 42 | +#define AQ_MBPS_DIVISOR 125000 /* 1000000 / 8 */ |
|---|
| 20 | 43 | |
|---|
| 21 | 44 | /* NIC H/W capabilities */ |
|---|
| 22 | 45 | struct aq_hw_caps_s { |
|---|
| .. | .. |
|---|
| 35 | 58 | u32 mac_regs_count; |
|---|
| 36 | 59 | u32 hw_alive_check_addr; |
|---|
| 37 | 60 | u8 msix_irqs; |
|---|
| 38 | | - u8 tcs; |
|---|
| 61 | + u8 tcs_max; |
|---|
| 39 | 62 | u8 rxd_alignment; |
|---|
| 40 | 63 | u8 rxd_size; |
|---|
| 41 | 64 | u8 txd_alignment; |
|---|
| .. | .. |
|---|
| 44 | 67 | u8 rx_rings; |
|---|
| 45 | 68 | bool flow_control; |
|---|
| 46 | 69 | bool is_64_dma; |
|---|
| 70 | + bool op64bit; |
|---|
| 71 | + u32 quirks; |
|---|
| 72 | + u32 priv_data_len; |
|---|
| 47 | 73 | }; |
|---|
| 48 | 74 | |
|---|
| 49 | 75 | struct aq_hw_link_status_s { |
|---|
| 50 | 76 | unsigned int mbps; |
|---|
| 77 | + bool full_duplex; |
|---|
| 78 | + u32 lp_link_speed_msk; |
|---|
| 79 | + u32 lp_flow_control; |
|---|
| 51 | 80 | }; |
|---|
| 52 | 81 | |
|---|
| 53 | 82 | struct aq_stats_s { |
|---|
| 83 | + u64 brc; |
|---|
| 84 | + u64 btc; |
|---|
| 54 | 85 | u64 uprc; |
|---|
| 55 | 86 | u64 mprc; |
|---|
| 56 | 87 | u64 bprc; |
|---|
| .. | .. |
|---|
| 77 | 108 | #define AQ_HW_IRQ_MSI 2U |
|---|
| 78 | 109 | #define AQ_HW_IRQ_MSIX 3U |
|---|
| 79 | 110 | |
|---|
| 111 | +#define AQ_HW_SERVICE_IRQS 1U |
|---|
| 112 | + |
|---|
| 80 | 113 | #define AQ_HW_POWER_STATE_D0 0U |
|---|
| 81 | 114 | #define AQ_HW_POWER_STATE_D3 3U |
|---|
| 82 | 115 | |
|---|
| .. | .. |
|---|
| 84 | 117 | #define AQ_HW_FLAG_STOPPING 0x00000008U |
|---|
| 85 | 118 | #define AQ_HW_FLAG_RESETTING 0x00000010U |
|---|
| 86 | 119 | #define AQ_HW_FLAG_CLOSING 0x00000020U |
|---|
| 120 | +#define AQ_HW_PTP_AVAILABLE 0x01000000U |
|---|
| 87 | 121 | #define AQ_HW_LINK_DOWN 0x04000000U |
|---|
| 88 | 122 | #define AQ_HW_FLAG_ERR_UNPLUG 0x40000000U |
|---|
| 89 | 123 | #define AQ_HW_FLAG_ERR_HW 0x80000000U |
|---|
| .. | .. |
|---|
| 103 | 137 | #define AQ_HW_TXD_MULTIPLE 8U |
|---|
| 104 | 138 | #define AQ_HW_RXD_MULTIPLE 8U |
|---|
| 105 | 139 | |
|---|
| 140 | +#define AQ_HW_QUEUES_MAX 32U |
|---|
| 106 | 141 | #define AQ_HW_MULTICAST_ADDRESS_MAX 32U |
|---|
| 142 | + |
|---|
| 143 | +#define AQ_HW_PTP_TC 2U |
|---|
| 144 | + |
|---|
| 145 | +#define AQ_HW_LED_BLINK 0x2U |
|---|
| 146 | +#define AQ_HW_LED_DEFAULT 0x0U |
|---|
| 147 | + |
|---|
| 148 | +#define AQ_HW_MEDIA_DETECT_CNT 6000 |
|---|
| 149 | + |
|---|
| 150 | +enum aq_priv_flags { |
|---|
| 151 | + AQ_HW_LOOPBACK_DMA_SYS, |
|---|
| 152 | + AQ_HW_LOOPBACK_PKT_SYS, |
|---|
| 153 | + AQ_HW_LOOPBACK_DMA_NET, |
|---|
| 154 | + AQ_HW_LOOPBACK_PHYINT_SYS, |
|---|
| 155 | + AQ_HW_LOOPBACK_PHYEXT_SYS, |
|---|
| 156 | +}; |
|---|
| 157 | + |
|---|
| 158 | +#define AQ_HW_LOOPBACK_MASK (BIT(AQ_HW_LOOPBACK_DMA_SYS) |\ |
|---|
| 159 | + BIT(AQ_HW_LOOPBACK_PKT_SYS) |\ |
|---|
| 160 | + BIT(AQ_HW_LOOPBACK_DMA_NET) |\ |
|---|
| 161 | + BIT(AQ_HW_LOOPBACK_PHYINT_SYS) |\ |
|---|
| 162 | + BIT(AQ_HW_LOOPBACK_PHYEXT_SYS)) |
|---|
| 163 | + |
|---|
| 164 | +#define ATL_HW_CHIP_MIPS 0x00000001U |
|---|
| 165 | +#define ATL_HW_CHIP_TPO2 0x00000002U |
|---|
| 166 | +#define ATL_HW_CHIP_RPF2 0x00000004U |
|---|
| 167 | +#define ATL_HW_CHIP_MPI_AQ 0x00000010U |
|---|
| 168 | +#define ATL_HW_CHIP_ATLANTIC 0x00800000U |
|---|
| 169 | +#define ATL_HW_CHIP_REVISION_A0 0x01000000U |
|---|
| 170 | +#define ATL_HW_CHIP_REVISION_B0 0x02000000U |
|---|
| 171 | +#define ATL_HW_CHIP_REVISION_B1 0x04000000U |
|---|
| 172 | +#define ATL_HW_CHIP_ANTIGUA 0x08000000U |
|---|
| 173 | + |
|---|
| 174 | +#define ATL_HW_IS_CHIP_FEATURE(_HW_, _F_) (!!(ATL_HW_CHIP_##_F_ & \ |
|---|
| 175 | + (_HW_)->chip_features)) |
|---|
| 107 | 176 | |
|---|
| 108 | 177 | struct aq_hw_s { |
|---|
| 109 | 178 | atomic_t flags; |
|---|
| .. | .. |
|---|
| 112 | 181 | const struct aq_fw_ops *aq_fw_ops; |
|---|
| 113 | 182 | void __iomem *mmio; |
|---|
| 114 | 183 | struct aq_hw_link_status_s aq_link_status; |
|---|
| 115 | | - struct hw_aq_atl_utils_mbox mbox; |
|---|
| 184 | + struct hw_atl_utils_mbox mbox; |
|---|
| 116 | 185 | struct hw_atl_stats_s last_stats; |
|---|
| 117 | 186 | struct aq_stats_s curr_stats; |
|---|
| 118 | 187 | u64 speed; |
|---|
| .. | .. |
|---|
| 123 | 192 | atomic_t dpc; |
|---|
| 124 | 193 | u32 mbox_addr; |
|---|
| 125 | 194 | u32 rpc_addr; |
|---|
| 195 | + u32 settings_addr; |
|---|
| 126 | 196 | u32 rpc_tid; |
|---|
| 127 | | - struct hw_aq_atl_utils_fw_rpc rpc; |
|---|
| 197 | + struct hw_atl_utils_fw_rpc rpc; |
|---|
| 198 | + s64 ptp_clk_offset; |
|---|
| 199 | + u16 phy_id; |
|---|
| 200 | + void *priv; |
|---|
| 128 | 201 | }; |
|---|
| 129 | 202 | |
|---|
| 130 | 203 | struct aq_ring_s; |
|---|
| 131 | 204 | struct aq_ring_param_s; |
|---|
| 132 | 205 | struct sk_buff; |
|---|
| 206 | +struct aq_rx_filter_l3l4; |
|---|
| 133 | 207 | |
|---|
| 134 | 208 | struct aq_hw_ops { |
|---|
| 135 | 209 | |
|---|
| .. | .. |
|---|
| 146 | 220 | struct aq_ring_s *aq_ring); |
|---|
| 147 | 221 | |
|---|
| 148 | 222 | int (*hw_set_mac_address)(struct aq_hw_s *self, u8 *mac_addr); |
|---|
| 223 | + |
|---|
| 224 | + int (*hw_soft_reset)(struct aq_hw_s *self); |
|---|
| 225 | + |
|---|
| 226 | + int (*hw_prepare)(struct aq_hw_s *self, |
|---|
| 227 | + const struct aq_fw_ops **fw_ops); |
|---|
| 149 | 228 | |
|---|
| 150 | 229 | int (*hw_reset)(struct aq_hw_s *self); |
|---|
| 151 | 230 | |
|---|
| .. | .. |
|---|
| 183 | 262 | int (*hw_packet_filter_set)(struct aq_hw_s *self, |
|---|
| 184 | 263 | unsigned int packet_filter); |
|---|
| 185 | 264 | |
|---|
| 265 | + int (*hw_filter_l3l4_set)(struct aq_hw_s *self, |
|---|
| 266 | + struct aq_rx_filter_l3l4 *data); |
|---|
| 267 | + |
|---|
| 268 | + int (*hw_filter_l3l4_clear)(struct aq_hw_s *self, |
|---|
| 269 | + struct aq_rx_filter_l3l4 *data); |
|---|
| 270 | + |
|---|
| 271 | + int (*hw_filter_l2_set)(struct aq_hw_s *self, |
|---|
| 272 | + struct aq_rx_filter_l2 *data); |
|---|
| 273 | + |
|---|
| 274 | + int (*hw_filter_l2_clear)(struct aq_hw_s *self, |
|---|
| 275 | + struct aq_rx_filter_l2 *data); |
|---|
| 276 | + |
|---|
| 277 | + int (*hw_filter_vlan_set)(struct aq_hw_s *self, |
|---|
| 278 | + struct aq_rx_filter_vlan *aq_vlans); |
|---|
| 279 | + |
|---|
| 280 | + int (*hw_filter_vlan_ctrl)(struct aq_hw_s *self, bool enable); |
|---|
| 281 | + |
|---|
| 186 | 282 | int (*hw_multicast_list_set)(struct aq_hw_s *self, |
|---|
| 187 | 283 | u8 ar_mac[AQ_HW_MULTICAST_ADDRESS_MAX] |
|---|
| 188 | 284 | [ETH_ALEN], |
|---|
| .. | .. |
|---|
| 196 | 292 | int (*hw_rss_hash_set)(struct aq_hw_s *self, |
|---|
| 197 | 293 | struct aq_rss_parameters *rss_params); |
|---|
| 198 | 294 | |
|---|
| 295 | + int (*hw_tc_rate_limit_set)(struct aq_hw_s *self); |
|---|
| 296 | + |
|---|
| 199 | 297 | int (*hw_get_regs)(struct aq_hw_s *self, |
|---|
| 200 | 298 | const struct aq_hw_caps_s *aq_hw_caps, |
|---|
| 201 | 299 | u32 *regs_buff); |
|---|
| 202 | 300 | |
|---|
| 203 | 301 | struct aq_stats_s *(*hw_get_hw_stats)(struct aq_hw_s *self); |
|---|
| 204 | 302 | |
|---|
| 205 | | - int (*hw_get_fw_version)(struct aq_hw_s *self, u32 *fw_version); |
|---|
| 303 | + u32 (*hw_get_fw_version)(struct aq_hw_s *self); |
|---|
| 206 | 304 | |
|---|
| 207 | | - int (*hw_set_power)(struct aq_hw_s *self, unsigned int power_state); |
|---|
| 305 | + int (*hw_set_offload)(struct aq_hw_s *self, |
|---|
| 306 | + struct aq_nic_cfg_s *aq_nic_cfg); |
|---|
| 307 | + |
|---|
| 308 | + int (*hw_ring_hwts_rx_fill)(struct aq_hw_s *self, |
|---|
| 309 | + struct aq_ring_s *aq_ring); |
|---|
| 310 | + |
|---|
| 311 | + int (*hw_ring_hwts_rx_receive)(struct aq_hw_s *self, |
|---|
| 312 | + struct aq_ring_s *ring); |
|---|
| 313 | + |
|---|
| 314 | + void (*hw_get_ptp_ts)(struct aq_hw_s *self, u64 *stamp); |
|---|
| 315 | + |
|---|
| 316 | + int (*hw_adj_clock_freq)(struct aq_hw_s *self, s32 delta); |
|---|
| 317 | + |
|---|
| 318 | + int (*hw_adj_sys_clock)(struct aq_hw_s *self, s64 delta); |
|---|
| 319 | + |
|---|
| 320 | + int (*hw_set_sys_clock)(struct aq_hw_s *self, u64 time, u64 ts); |
|---|
| 321 | + |
|---|
| 322 | + int (*hw_ts_to_sys_clock)(struct aq_hw_s *self, u64 ts, u64 *time); |
|---|
| 323 | + |
|---|
| 324 | + int (*hw_gpio_pulse)(struct aq_hw_s *self, u32 index, u64 start, |
|---|
| 325 | + u32 period); |
|---|
| 326 | + |
|---|
| 327 | + int (*hw_extts_gpio_enable)(struct aq_hw_s *self, u32 index, |
|---|
| 328 | + u32 enable); |
|---|
| 329 | + |
|---|
| 330 | + int (*hw_get_sync_ts)(struct aq_hw_s *self, u64 *ts); |
|---|
| 331 | + |
|---|
| 332 | + u16 (*rx_extract_ts)(struct aq_hw_s *self, u8 *p, unsigned int len, |
|---|
| 333 | + u64 *timestamp); |
|---|
| 334 | + |
|---|
| 335 | + int (*extract_hwts)(struct aq_hw_s *self, u8 *p, unsigned int len, |
|---|
| 336 | + u64 *timestamp); |
|---|
| 337 | + |
|---|
| 338 | + int (*hw_set_fc)(struct aq_hw_s *self, u32 fc, u32 tc); |
|---|
| 339 | + |
|---|
| 340 | + int (*hw_set_loopback)(struct aq_hw_s *self, u32 mode, bool enable); |
|---|
| 341 | + |
|---|
| 342 | + int (*hw_get_mac_temp)(struct aq_hw_s *self, u32 *temp); |
|---|
| 208 | 343 | }; |
|---|
| 209 | 344 | |
|---|
| 210 | 345 | struct aq_fw_ops { |
|---|
| .. | .. |
|---|
| 227 | 362 | |
|---|
| 228 | 363 | int (*update_stats)(struct aq_hw_s *self); |
|---|
| 229 | 364 | |
|---|
| 365 | + int (*get_mac_temp)(struct aq_hw_s *self, int *temp); |
|---|
| 366 | + |
|---|
| 367 | + int (*get_phy_temp)(struct aq_hw_s *self, int *temp); |
|---|
| 368 | + |
|---|
| 369 | + u32 (*get_flow_control)(struct aq_hw_s *self, u32 *fcmode); |
|---|
| 370 | + |
|---|
| 230 | 371 | int (*set_flow_control)(struct aq_hw_s *self); |
|---|
| 372 | + |
|---|
| 373 | + int (*led_control)(struct aq_hw_s *self, u32 mode); |
|---|
| 374 | + |
|---|
| 375 | + int (*set_phyloopback)(struct aq_hw_s *self, u32 mode, bool enable); |
|---|
| 376 | + |
|---|
| 377 | + int (*set_power)(struct aq_hw_s *self, unsigned int power_state, |
|---|
| 378 | + u8 *mac); |
|---|
| 379 | + |
|---|
| 380 | + int (*send_fw_request)(struct aq_hw_s *self, |
|---|
| 381 | + const struct hw_fw_request_iface *fw_req, |
|---|
| 382 | + size_t size); |
|---|
| 383 | + |
|---|
| 384 | + void (*enable_ptp)(struct aq_hw_s *self, int enable); |
|---|
| 385 | + |
|---|
| 386 | + void (*adjust_ptp)(struct aq_hw_s *self, uint64_t adj); |
|---|
| 387 | + |
|---|
| 388 | + int (*set_eee_rate)(struct aq_hw_s *self, u32 speed); |
|---|
| 389 | + |
|---|
| 390 | + int (*get_eee_rate)(struct aq_hw_s *self, u32 *rate, |
|---|
| 391 | + u32 *supported_rates); |
|---|
| 392 | + |
|---|
| 393 | + int (*set_downshift)(struct aq_hw_s *self, u32 counter); |
|---|
| 394 | + |
|---|
| 395 | + int (*set_media_detect)(struct aq_hw_s *self, bool enable); |
|---|
| 396 | + |
|---|
| 397 | + u32 (*get_link_capabilities)(struct aq_hw_s *self); |
|---|
| 398 | + |
|---|
| 399 | + int (*send_macsec_req)(struct aq_hw_s *self, |
|---|
| 400 | + struct macsec_msg_fw_request *msg, |
|---|
| 401 | + struct macsec_msg_fw_response *resp); |
|---|
| 231 | 402 | }; |
|---|
| 232 | 403 | |
|---|
| 233 | 404 | #endif /* AQ_HW_H */ |
|---|