ixl_pf.h (86803260) | ixl_pf.h (61ae650d) |
---|---|
1/****************************************************************************** 2 | 1/****************************************************************************** 2 |
3 Copyright (c) 2013-2018, Intel Corporation | 3 Copyright (c) 2013-2014, Intel Corporation |
4 All rights reserved. 5 6 Redistribution and use in source and binary forms, with or without 7 modification, are permitted provided that the following conditions are met: 8 9 1. Redistributions of source code must retain the above copyright notice, 10 this list of conditions and the following disclaimer. 11 --- 19 unchanged lines hidden (view full) --- 31 32******************************************************************************/ 33/*$FreeBSD$*/ 34 35 36#ifndef _IXL_PF_H_ 37#define _IXL_PF_H_ 38 | 4 All rights reserved. 5 6 Redistribution and use in source and binary forms, with or without 7 modification, are permitted provided that the following conditions are met: 8 9 1. Redistributions of source code must retain the above copyright notice, 10 this list of conditions and the following disclaimer. 11 --- 19 unchanged lines hidden (view full) --- 31 32******************************************************************************/ 33/*$FreeBSD$*/ 34 35 36#ifndef _IXL_PF_H_ 37#define _IXL_PF_H_ 38 |
39#include "i40e_dcb.h" 40 41#include "ixl.h" 42#include "ixl_pf_qmgr.h" 43 44#define VF_FLAG_ENABLED 0x01 45#define VF_FLAG_SET_MAC_CAP 0x02 46#define VF_FLAG_VLAN_CAP 0x04 47#define VF_FLAG_PROMISC_CAP 0x08 48#define VF_FLAG_MAC_ANTI_SPOOF 0x10 49 50#define IXL_ICR0_CRIT_ERR_MASK \ 51 (I40E_PFINT_ICR0_PCI_EXCEPTION_MASK | \ 52 I40E_PFINT_ICR0_ECC_ERR_MASK | \ 53 I40E_PFINT_ICR0_PE_CRITERR_MASK) 54 55/* VF Interrupts */ 56#define IXL_VPINT_LNKLSTN_REG(hw, vector, vf_num) \ 57 I40E_VPINT_LNKLSTN(((vector) - 1) + \ 58 (((hw)->func_caps.num_msix_vectors_vf - 1) * (vf_num))) 59 60#define IXL_VFINT_DYN_CTLN_REG(hw, vector, vf_num) \ 61 I40E_VFINT_DYN_CTLN(((vector) - 1) + \ 62 (((hw)->func_caps.num_msix_vectors_vf - 1) * (vf_num))) 63 64enum ixl_fw_mode { 65 IXL_FW_MODE_NORMAL, 66 IXL_FW_MODE_RECOVERY, 67 IXL_FW_MODE_UEMPR 68}; 69 70enum ixl_i2c_access_method_t { 71 IXL_I2C_ACCESS_METHOD_BEST_AVAILABLE = 0, 72 IXL_I2C_ACCESS_METHOD_BIT_BANG_I2CPARAMS = 1, 73 IXL_I2C_ACCESS_METHOD_REGISTER_I2CCMD = 2, 74 IXL_I2C_ACCESS_METHOD_AQ = 3, 75 IXL_I2C_ACCESS_METHOD_TYPE_LENGTH = 4 76}; 77 78/* Used in struct ixl_pf's state field */ 79enum ixl_pf_state { 80 IXL_PF_STATE_RECOVERY_MODE = (1 << 0), 81 IXL_PF_STATE_RESETTING = (1 << 1), 82 IXL_PF_STATE_MDD_PENDING = (1 << 2), 83 IXL_PF_STATE_PF_RESET_REQ = (1 << 3), 84 IXL_PF_STATE_VF_RESET_REQ = (1 << 4), 85 IXL_PF_STATE_PF_CRIT_ERR = (1 << 5), 86 IXL_PF_STATE_CORE_RESET_REQ = (1 << 6), 87 IXL_PF_STATE_GLOB_RESET_REQ = (1 << 7), 88 IXL_PF_STATE_EMP_RESET_REQ = (1 << 8), 89 IXL_PF_STATE_FW_LLDP_DISABLED = (1 << 9), 90 IXL_PF_STATE_EEE_ENABLED = (1 << 10), 91 IXL_PF_STATE_LINK_ACTIVE_ON_DOWN = (1 << 11), 92}; 93 94#define IXL_PF_IN_RECOVERY_MODE(pf) \ 95 ((atomic_load_acq_32(&pf->state) & IXL_PF_STATE_RECOVERY_MODE) != 0) 96 97#define IXL_PF_IS_RESETTING(pf) \ 98 ((atomic_load_acq_32(&pf->state) & IXL_PF_STATE_RESETTING) != 0) 99 100struct ixl_vf { 101 struct ixl_vsi vsi; 102 u32 vf_flags; 103 u32 num_mdd_events; 104 105 u8 mac[ETHER_ADDR_LEN]; 106 u16 vf_num; 107 struct virtchnl_version_info version; 108 109 struct ixl_pf_qtag qtag; 110}; 111 | |
112/* Physical controller structure */ 113struct ixl_pf { | 39/* Physical controller structure */ 40struct ixl_pf { |
114 struct ixl_vsi vsi; 115 | |
116 struct i40e_hw hw; 117 struct i40e_osdep osdep; | 41 struct i40e_hw hw; 42 struct i40e_osdep osdep; |
118 device_t dev; | 43 struct device *dev; |
119 120 struct resource *pci_mem; | 44 45 struct resource *pci_mem; |
46 struct resource *msix_mem; |
|
121 | 47 |
122#ifdef IXL_IW 123 int iw_msix; 124 bool iw_enabled; 125#endif 126 u32 state; 127 u8 supported_speeds; | 48 /* 49 * Interrupt resources: this set is 50 * either used for legacy, or for Link 51 * when doing MSIX 52 */ 53 void *tag; 54 struct resource *res; |
128 | 55 |
129 struct ixl_pf_qmgr qmgr; 130 struct ixl_pf_qtag qtag; | 56 struct callout timer; 57 int msix; 58 int if_flags; |
131 | 59 |
132 char admin_mtx_name[16]; /* name of the admin mutex */ 133 struct mtx admin_mtx; /* mutex to protect the admin timer */ 134 struct callout admin_timer; /* timer to trigger admin task */ | 60 struct mtx pf_mtx; |
135 | 61 |
136 /* Tunable values */ 137#ifdef IXL_DEBUG_FC 138 bool enable_tx_fc_filter; 139#endif 140#ifdef IXL_DEBUG 141 bool recovery_mode; 142#endif 143 int dynamic_rx_itr; 144 int dynamic_tx_itr; 145 int tx_itr; 146 int rx_itr; 147 int enable_vf_loopback; | 62 u32 qbase; 63 u32 admvec; 64 struct task adminq; 65 struct taskqueue *tq; |
148 | 66 |
149 bool link_up; | |
150 int advertised_speed; | 67 int advertised_speed; |
151 int fc; /* link flow ctrl setting */ 152 enum ixl_dbg_mask dbg_mask; 153 bool has_i2c; | |
154 | 68 |
69 /* 70 ** VSI - Stations: 71 ** These are the traffic class holders, and 72 ** will have a stack interface and queues 73 ** associated with them. 74 ** NOTE: for now using just one, so embed it. 75 */ 76 struct ixl_vsi vsi; 77 |
|
155 /* Misc stats maintained by the driver */ | 78 /* Misc stats maintained by the driver */ |
79 u64 watchdog_events; |
|
156 u64 admin_irq; 157 158 /* Statistics from hw */ 159 struct i40e_hw_port_stats stats; 160 struct i40e_hw_port_stats stats_offsets; 161 bool stat_offsets_loaded; | 80 u64 admin_irq; 81 82 /* Statistics from hw */ 83 struct i40e_hw_port_stats stats; 84 struct i40e_hw_port_stats stats_offsets; 85 bool stat_offsets_loaded; |
162 163 /* I2C access methods */ 164 enum ixl_i2c_access_method_t i2c_access_method; 165 s32 (*read_i2c_byte)(struct ixl_pf *pf, u8 byte_offset, 166 u8 dev_addr, u8 *data); 167 s32 (*write_i2c_byte)(struct ixl_pf *pf, u8 byte_offset, 168 u8 dev_addr, u8 data); 169 170 /* SR-IOV */ 171 struct ixl_vf *vfs; 172 int num_vfs; 173 uint16_t veb_seid; 174 int vc_debug_lvl; | |
175}; 176 | 86}; 87 |
177/* 178 * Defines used for NVM update ioctls. 179 * This value is used in the Solaris tool, too. 180 */ 181#define I40E_NVM_ACCESS \ 182 (((((((('E' << 4) + '1') << 4) + 'K') << 4) + 'G') << 4) | 5) | |
183 | 88 |
184#define IXL_DEFAULT_PHY_INT_MASK \ 185 ((~(I40E_AQ_EVENT_LINK_UPDOWN | I40E_AQ_EVENT_MODULE_QUAL_FAIL \ 186 | I40E_AQ_EVENT_MEDIA_NA)) & 0x3FF) | 89#define IXL_PF_LOCK_INIT(_sc, _name) \ 90 mtx_init(&(_sc)->pf_mtx, _name, "IXL PF Lock", MTX_DEF) 91#define IXL_PF_LOCK(_sc) mtx_lock(&(_sc)->pf_mtx) 92#define IXL_PF_UNLOCK(_sc) mtx_unlock(&(_sc)->pf_mtx) 93#define IXL_PF_LOCK_DESTROY(_sc) mtx_destroy(&(_sc)->pf_mtx) 94#define IXL_PF_LOCK_ASSERT(_sc) mtx_assert(&(_sc)->pf_mtx, MA_OWNED) |
187 | 95 |
188/*** Sysctl help messages; displayed with "sysctl -d" ***/ 189 190#define IXL_SYSCTL_HELP_SET_ADVERTISE \ 191"\nControl advertised link speed.\n" \ 192"Flags:\n" \ 193"\t 0x1 - advertise 100M\n" \ 194"\t 0x2 - advertise 1G\n" \ 195"\t 0x4 - advertise 10G\n" \ 196"\t 0x8 - advertise 20G\n" \ 197"\t0x10 - advertise 25G\n" \ 198"\t0x20 - advertise 40G\n" \ 199"\t0x40 - advertise 2.5G\n" \ 200"\t0x80 - advertise 5G\n\n" \ 201"Set to 0 to disable link.\n" \ 202"Use \"sysctl -x\" to view flags properly." 203 204#define IXL_SYSCTL_HELP_SUPPORTED_SPEED \ 205"\nSupported link speeds.\n" \ 206"Flags:\n" \ 207"\t 0x1 - 100M\n" \ 208"\t 0x2 - 1G\n" \ 209"\t 0x4 - 10G\n" \ 210"\t 0x8 - 20G\n" \ 211"\t0x10 - 25G\n" \ 212"\t0x20 - 40G\n" \ 213"\t0x40 - 2.5G\n" \ 214"\t0x80 - 5G\n\n" \ 215"Use \"sysctl -x\" to view flags properly." 216 217#define IXL_SYSCTL_HELP_FC \ 218"\nSet flow control mode using the values below.\n" \ 219"\t0 - off\n" \ 220"\t1 - rx pause\n" \ 221"\t2 - tx pause\n" \ 222"\t3 - tx and rx pause" 223 224#define IXL_SYSCTL_HELP_LINK_STATUS \ 225"\nExecutes a \"Get Link Status\" command on the Admin Queue, and displays" \ 226" the response." 227 228#define IXL_SYSCTL_HELP_FW_LLDP \ 229"\nFW LLDP engine:\n" \ 230"\t0 - disable\n" \ 231"\t1 - enable\n" 232 233#define IXL_SYSCTL_HELP_SET_LINK_ACTIVE \ 234"\nKeep link active after setting interface down:\n" \ 235"\t0 - disable\n" \ 236"\t1 - enable\n" 237 238#define IXL_SYSCTL_HELP_READ_I2C \ 239"\nRead a byte from I2C bus\n" \ 240"Input: 32-bit value\n" \ 241"\tbits 0-7: device address (0xA0 or 0xA2)\n" \ 242"\tbits 8-15: offset (0-255)\n" \ 243"\tbits 16-31: unused\n" \ 244"Output: 8-bit value read" 245 246#define IXL_SYSCTL_HELP_WRITE_I2C \ 247"\nWrite a byte to the I2C bus\n" \ 248"Input: 32-bit value\n" \ 249"\tbits 0-7: device address (0xA0 or 0xA2)\n" \ 250"\tbits 8-15: offset (0-255)\n" \ 251"\tbits 16-23: value to write\n" \ 252"\tbits 24-31: unused\n" \ 253"Output: 8-bit value written" 254 255#define IXL_SYSCTL_HELP_I2C_METHOD \ 256"\nI2C access method that driver will use:\n" \ 257"\t0 - best available method\n" \ 258"\t1 - bit bang via I2CPARAMS register\n" \ 259"\t2 - register read/write via I2CCMD register\n" \ 260"\t3 - Use Admin Queue command (best)\n" \ 261"Using the Admin Queue is only supported on 710 devices with FW version 1.7 or higher" 262 263#define IXL_SYSCTL_HELP_VF_LOOPBACK \ 264"\nDetermines mode that embedded device switch will use when SR-IOV is initialized:\n" \ 265"\t0 - Disable (VEPA)\n" \ 266"\t1 - Enable (VEB)\n" \ 267"Enabling this will allow VFs in separate VMs to communicate over the hardware bridge." 268 269/*** Functions / Macros ***/ 270/* Adjust the level here to 10 or over to print stats messages */ 271#define I40E_VC_DEBUG(p, level, ...) \ 272 do { \ 273 if (level < 10) \ 274 ixl_dbg(p, IXL_DBG_IOV_VC, ##__VA_ARGS__); \ 275 } while (0) 276 277#define i40e_send_vf_nack(pf, vf, op, st) \ 278 ixl_send_vf_nack_msg((pf), (vf), (op), (st), __FILE__, __LINE__) 279 280/* Debug printing */ 281#define ixl_dbg(pf, m, s, ...) ixl_debug_core((pf)->dev, (pf)->dbg_mask, m, s, ##__VA_ARGS__) 282#define ixl_dbg_info(pf, s, ...) ixl_debug_core((pf)->dev, (pf)->dbg_mask, IXL_DBG_INFO, s, ##__VA_ARGS__) 283#define ixl_dbg_filter(pf, s, ...) ixl_debug_core((pf)->dev, (pf)->dbg_mask, IXL_DBG_FILTER, s, ##__VA_ARGS__) 284#define ixl_dbg_iov(pf, s, ...) ixl_debug_core((pf)->dev, (pf)->dbg_mask, IXL_DBG_IOV, s, ##__VA_ARGS__) 285 286/* PF-only function declarations */ 287int ixl_setup_interface(device_t, struct ixl_pf *); 288void ixl_print_nvm_cmd(device_t, struct i40e_nvm_access *); 289 290void ixl_handle_que(void *context, int pending); 291 292void ixl_init(void *); 293void ixl_register_vlan(void *, if_t, u16); 294void ixl_unregister_vlan(void *, if_t, u16); 295int ixl_intr(void *); 296int ixl_msix_que(void *); 297int ixl_msix_adminq(void *); 298void ixl_do_adminq(void *, int); 299 300int ixl_res_alloc_cmp(const void *, const void *); 301const char * ixl_switch_res_type_string(u8); 302void ixl_add_sysctls_mac_stats(struct sysctl_ctx_list *, 303 struct sysctl_oid_list *, struct i40e_hw_port_stats *); 304 305void ixl_media_status(if_t, struct ifmediareq *); 306int ixl_media_change(if_t); 307int ixl_ioctl(if_t, u_long, caddr_t); 308 309void ixl_enable_queue(struct i40e_hw *, int); 310void ixl_disable_queue(struct i40e_hw *, int); 311void ixl_enable_intr0(struct i40e_hw *); 312void ixl_disable_intr0(struct i40e_hw *); 313void ixl_nvm_version_str(struct i40e_hw *hw, struct sbuf *buf); 314void ixl_stat_update48(struct i40e_hw *, u32, u32, bool, 315 u64 *, u64 *); 316void ixl_stat_update32(struct i40e_hw *, u32, bool, 317 u64 *, u64 *); 318 319void ixl_stop(struct ixl_pf *); 320void ixl_vsi_add_sysctls(struct ixl_vsi *, const char *, bool); 321int ixl_get_hw_capabilities(struct ixl_pf *); 322void ixl_link_up_msg(struct ixl_pf *); 323void ixl_update_link_status(struct ixl_pf *); 324int ixl_setup_stations(struct ixl_pf *); 325int ixl_switch_config(struct ixl_pf *); 326void ixl_stop_locked(struct ixl_pf *); 327int ixl_teardown_hw_structs(struct ixl_pf *); 328void ixl_init_locked(struct ixl_pf *); 329void ixl_set_rss_key(struct ixl_pf *); 330void ixl_set_rss_pctypes(struct ixl_pf *); 331void ixl_set_rss_hlut(struct ixl_pf *); 332int ixl_setup_adminq_msix(struct ixl_pf *); 333int ixl_setup_adminq_tq(struct ixl_pf *); 334void ixl_teardown_adminq_msix(struct ixl_pf *); 335void ixl_configure_intr0_msix(struct ixl_pf *); 336void ixl_configure_queue_intr_msix(struct ixl_pf *); 337void ixl_free_adminq_tq(struct ixl_pf *); 338int ixl_setup_legacy(struct ixl_pf *); 339int ixl_init_msix(struct ixl_pf *); 340void ixl_configure_tx_itr(struct ixl_pf *); 341void ixl_configure_rx_itr(struct ixl_pf *); 342void ixl_configure_itr(struct ixl_pf *); 343void ixl_configure_legacy(struct ixl_pf *); 344void ixl_free_pci_resources(struct ixl_pf *); 345void ixl_link_event(struct ixl_pf *, struct i40e_arq_event_info *); 346void ixl_config_rss(struct ixl_pf *); 347int ixl_set_advertised_speeds(struct ixl_pf *, int, bool); 348void ixl_set_initial_advertised_speeds(struct ixl_pf *); 349void ixl_print_nvm_version(struct ixl_pf *pf); 350void ixl_add_sysctls_recovery_mode(struct ixl_pf *); 351void ixl_add_device_sysctls(struct ixl_pf *); 352void ixl_handle_mdd_event(struct ixl_pf *); 353void ixl_add_hw_stats(struct ixl_pf *); 354void ixl_update_stats_counters(struct ixl_pf *); 355void ixl_pf_reset_stats(struct ixl_pf *); 356void ixl_get_bus_info(struct ixl_pf *pf); 357int ixl_aq_get_link_status(struct ixl_pf *, 358 struct i40e_aqc_get_link_status *); 359void ixl_set_link(struct ixl_pf *, bool); 360 361int ixl_handle_nvmupd_cmd(struct ixl_pf *, struct ifdrv *); 362int ixl_handle_i2c_eeprom_read_cmd(struct ixl_pf *, struct ifreq *ifr); 363 364int ixl_setup_hmc(struct ixl_pf *); 365void ixl_shutdown_hmc(struct ixl_pf *); 366void ixl_handle_empr_reset(struct ixl_pf *); 367int ixl_prepare_for_reset(struct ixl_pf *pf, bool is_up); 368int ixl_rebuild_hw_structs_after_reset(struct ixl_pf *, bool is_up); 369int ixl_pf_reset(struct ixl_pf *); 370 371void ixl_set_queue_rx_itr(struct ixl_rx_queue *); 372void ixl_set_queue_tx_itr(struct ixl_tx_queue *); 373 374void ixl_add_filter(struct ixl_vsi *, const u8 *, s16 vlan); 375void ixl_del_filter(struct ixl_vsi *, const u8 *, s16 vlan); 376void ixl_add_vlan_filters(struct ixl_vsi *, const u8 *); 377void ixl_del_all_vlan_filters(struct ixl_vsi *, const u8 *); 378void ixl_reconfigure_filters(struct ixl_vsi *vsi); 379 380int ixl_disable_rings(struct ixl_pf *, struct ixl_vsi *, struct ixl_pf_qtag *); 381int ixl_disable_tx_ring(struct ixl_pf *, struct ixl_pf_qtag *, u16); 382int ixl_disable_rx_ring(struct ixl_pf *, struct ixl_pf_qtag *, u16); 383int ixl_disable_ring(struct ixl_pf *pf, struct ixl_pf_qtag *, u16); 384 385int ixl_enable_rings(struct ixl_vsi *); 386int ixl_enable_tx_ring(struct ixl_pf *, struct ixl_pf_qtag *, u16); 387int ixl_enable_rx_ring(struct ixl_pf *, struct ixl_pf_qtag *, u16); 388int ixl_enable_ring(struct ixl_pf *pf, struct ixl_pf_qtag *, u16); 389 390void ixl_update_eth_stats(struct ixl_vsi *); 391void ixl_cap_txcsum_tso(struct ixl_vsi *, if_t, int); 392int ixl_initialize_vsi(struct ixl_vsi *); 393void ixl_add_ifmedia(struct ifmedia *, u64); 394int ixl_setup_queue_msix(struct ixl_vsi *); 395int ixl_setup_queue_tqs(struct ixl_vsi *); 396int ixl_teardown_queue_msix(struct ixl_vsi *); 397void ixl_free_queue_tqs(struct ixl_vsi *); 398void ixl_enable_intr(struct ixl_vsi *); 399void ixl_disable_rings_intr(struct ixl_vsi *); 400void ixl_set_promisc(struct ixl_vsi *); 401void ixl_add_multi(struct ixl_vsi *); 402void ixl_del_multi(struct ixl_vsi *, bool); 403void ixl_setup_vlan_filters(struct ixl_vsi *); 404void ixl_init_filters(struct ixl_vsi *); 405void ixl_free_filters(struct ixl_ftl_head *); 406void ixl_add_hw_filters(struct ixl_vsi *, struct ixl_ftl_head *, int); 407void ixl_del_hw_filters(struct ixl_vsi *, struct ixl_ftl_head *, int); 408void ixl_del_default_hw_filters(struct ixl_vsi *); 409struct ixl_mac_filter * 410 ixl_find_filter(struct ixl_ftl_head *, const u8 *, s16); 411void ixl_update_vsi_stats(struct ixl_vsi *); 412void ixl_vsi_reset_stats(struct ixl_vsi *); 413 414void ixl_vsi_free_queues(struct ixl_vsi *vsi); 415 416void ixl_if_init(if_ctx_t ctx); 417void ixl_if_stop(if_ctx_t ctx); 418 419/* 420 * I2C Function prototypes 421 */ 422int ixl_find_i2c_interface(struct ixl_pf *); 423s32 ixl_read_i2c_byte_bb(struct ixl_pf *pf, u8 byte_offset, 424 u8 dev_addr, u8 *data); 425s32 ixl_write_i2c_byte_bb(struct ixl_pf *pf, u8 byte_offset, 426 u8 dev_addr, u8 data); 427s32 ixl_read_i2c_byte_reg(struct ixl_pf *pf, u8 byte_offset, 428 u8 dev_addr, u8 *data); 429s32 ixl_write_i2c_byte_reg(struct ixl_pf *pf, u8 byte_offset, 430 u8 dev_addr, u8 data); 431s32 ixl_read_i2c_byte_aq(struct ixl_pf *pf, u8 byte_offset, 432 u8 dev_addr, u8 *data); 433s32 ixl_write_i2c_byte_aq(struct ixl_pf *pf, u8 byte_offset, 434 u8 dev_addr, u8 data); 435 436u64 ixl_max_aq_speed_to_value(u8); 437int ixl_attach_get_link_status(struct ixl_pf *); 438int ixl_sysctl_set_flowcntl(SYSCTL_HANDLER_ARGS); 439 | |
440#endif /* _IXL_PF_H_ */ | 96#endif /* _IXL_PF_H_ */ |