Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0 */
0002 /* Copyright (c)  2018 Intel Corporation */
0003 
0004 #ifndef _IGC_HW_H_
0005 #define _IGC_HW_H_
0006 
0007 #include <linux/types.h>
0008 #include <linux/if_ether.h>
0009 #include <linux/netdevice.h>
0010 
0011 #include "igc_regs.h"
0012 #include "igc_defines.h"
0013 #include "igc_mac.h"
0014 #include "igc_phy.h"
0015 #include "igc_nvm.h"
0016 #include "igc_i225.h"
0017 #include "igc_base.h"
0018 
0019 #define IGC_DEV_ID_I225_LM          0x15F2
0020 #define IGC_DEV_ID_I225_V           0x15F3
0021 #define IGC_DEV_ID_I225_I           0x15F8
0022 #define IGC_DEV_ID_I220_V           0x15F7
0023 #define IGC_DEV_ID_I225_K           0x3100
0024 #define IGC_DEV_ID_I225_K2          0x3101
0025 #define IGC_DEV_ID_I226_K           0x3102
0026 #define IGC_DEV_ID_I225_LMVP            0x5502
0027 #define IGC_DEV_ID_I226_LMVP            0x5503
0028 #define IGC_DEV_ID_I225_IT          0x0D9F
0029 #define IGC_DEV_ID_I226_LM          0x125B
0030 #define IGC_DEV_ID_I226_V           0x125C
0031 #define IGC_DEV_ID_I226_IT          0x125D
0032 #define IGC_DEV_ID_I221_V           0x125E
0033 #define IGC_DEV_ID_I226_BLANK_NVM       0x125F
0034 #define IGC_DEV_ID_I225_BLANK_NVM       0x15FD
0035 
0036 /* Function pointers for the MAC. */
0037 struct igc_mac_operations {
0038     s32 (*check_for_link)(struct igc_hw *hw);
0039     s32 (*reset_hw)(struct igc_hw *hw);
0040     s32 (*init_hw)(struct igc_hw *hw);
0041     s32 (*setup_physical_interface)(struct igc_hw *hw);
0042     void (*rar_set)(struct igc_hw *hw, u8 *address, u32 index);
0043     s32 (*read_mac_addr)(struct igc_hw *hw);
0044     s32 (*get_speed_and_duplex)(struct igc_hw *hw, u16 *speed,
0045                     u16 *duplex);
0046     s32 (*acquire_swfw_sync)(struct igc_hw *hw, u16 mask);
0047     void (*release_swfw_sync)(struct igc_hw *hw, u16 mask);
0048 };
0049 
0050 enum igc_mac_type {
0051     igc_undefined = 0,
0052     igc_i225,
0053     igc_num_macs  /* List is 1-based, so subtract 1 for true count. */
0054 };
0055 
0056 enum igc_media_type {
0057     igc_media_type_unknown = 0,
0058     igc_media_type_copper = 1,
0059     igc_num_media_types
0060 };
0061 
0062 enum igc_nvm_type {
0063     igc_nvm_unknown = 0,
0064     igc_nvm_eeprom_spi,
0065 };
0066 
0067 struct igc_info {
0068     s32 (*get_invariants)(struct igc_hw *hw);
0069     struct igc_mac_operations *mac_ops;
0070     const struct igc_phy_operations *phy_ops;
0071     struct igc_nvm_operations *nvm_ops;
0072 };
0073 
0074 extern const struct igc_info igc_base_info;
0075 
0076 struct igc_mac_info {
0077     struct igc_mac_operations ops;
0078 
0079     u8 addr[ETH_ALEN];
0080     u8 perm_addr[ETH_ALEN];
0081 
0082     enum igc_mac_type type;
0083 
0084     u32 mc_filter_type;
0085 
0086     u16 mta_reg_count;
0087     u16 uta_reg_count;
0088 
0089     u32 mta_shadow[MAX_MTA_REG];
0090     u16 rar_entry_count;
0091 
0092     bool asf_firmware_present;
0093     bool arc_subsystem_valid;
0094 
0095     bool autoneg;
0096     bool autoneg_failed;
0097     bool get_link_status;
0098 };
0099 
0100 struct igc_nvm_operations {
0101     s32 (*acquire)(struct igc_hw *hw);
0102     s32 (*read)(struct igc_hw *hw, u16 offset, u16 i, u16 *data);
0103     void (*release)(struct igc_hw *hw);
0104     s32 (*write)(struct igc_hw *hw, u16 offset, u16 i, u16 *data);
0105     s32 (*update)(struct igc_hw *hw);
0106     s32 (*validate)(struct igc_hw *hw);
0107 };
0108 
0109 struct igc_phy_operations {
0110     s32 (*acquire)(struct igc_hw *hw);
0111     s32 (*check_reset_block)(struct igc_hw *hw);
0112     s32 (*force_speed_duplex)(struct igc_hw *hw);
0113     s32 (*get_phy_info)(struct igc_hw *hw);
0114     s32 (*read_reg)(struct igc_hw *hw, u32 address, u16 *data);
0115     void (*release)(struct igc_hw *hw);
0116     s32 (*reset)(struct igc_hw *hw);
0117     s32 (*write_reg)(struct igc_hw *hw, u32 address, u16 data);
0118 };
0119 
0120 struct igc_nvm_info {
0121     struct igc_nvm_operations ops;
0122     enum igc_nvm_type type;
0123 
0124     u16 word_size;
0125     u16 delay_usec;
0126     u16 address_bits;
0127     u16 opcode_bits;
0128     u16 page_size;
0129 };
0130 
0131 struct igc_phy_info {
0132     struct igc_phy_operations ops;
0133 
0134     u32 addr;
0135     u32 id;
0136     u32 reset_delay_us; /* in usec */
0137     u32 revision;
0138 
0139     enum igc_media_type media_type;
0140 
0141     u16 autoneg_advertised;
0142     u16 autoneg_mask;
0143 
0144     u8 mdix;
0145 
0146     bool is_mdix;
0147     bool speed_downgraded;
0148     bool autoneg_wait_to_complete;
0149 };
0150 
0151 struct igc_bus_info {
0152     u16 func;
0153     u16 pci_cmd_word;
0154 };
0155 
0156 enum igc_fc_mode {
0157     igc_fc_none = 0,
0158     igc_fc_rx_pause,
0159     igc_fc_tx_pause,
0160     igc_fc_full,
0161     igc_fc_default = 0xFF
0162 };
0163 
0164 struct igc_fc_info {
0165     u32 high_water;     /* Flow control high-water mark */
0166     u32 low_water;      /* Flow control low-water mark */
0167     u16 pause_time;     /* Flow control pause timer */
0168     bool send_xon;      /* Flow control send XON */
0169     bool strict_ieee;   /* Strict IEEE mode */
0170     enum igc_fc_mode current_mode; /* Type of flow control */
0171     enum igc_fc_mode requested_mode;
0172 };
0173 
0174 struct igc_dev_spec_base {
0175     bool clear_semaphore_once;
0176     bool eee_enable;
0177 };
0178 
0179 struct igc_hw {
0180     void *back;
0181 
0182     u8 __iomem *hw_addr;
0183     unsigned long io_base;
0184 
0185     struct igc_mac_info  mac;
0186     struct igc_fc_info   fc;
0187     struct igc_nvm_info  nvm;
0188     struct igc_phy_info  phy;
0189 
0190     struct igc_bus_info bus;
0191 
0192     union {
0193         struct igc_dev_spec_base    _base;
0194     } dev_spec;
0195 
0196     u16 device_id;
0197     u16 subsystem_vendor_id;
0198     u16 subsystem_device_id;
0199     u16 vendor_id;
0200 
0201     u8 revision_id;
0202 };
0203 
0204 /* Statistics counters collected by the MAC */
0205 struct igc_hw_stats {
0206     u64 crcerrs;
0207     u64 algnerrc;
0208     u64 symerrs;
0209     u64 rxerrc;
0210     u64 mpc;
0211     u64 scc;
0212     u64 ecol;
0213     u64 mcc;
0214     u64 latecol;
0215     u64 colc;
0216     u64 dc;
0217     u64 tncrs;
0218     u64 sec;
0219     u64 cexterr;
0220     u64 rlec;
0221     u64 xonrxc;
0222     u64 xontxc;
0223     u64 xoffrxc;
0224     u64 xofftxc;
0225     u64 fcruc;
0226     u64 prc64;
0227     u64 prc127;
0228     u64 prc255;
0229     u64 prc511;
0230     u64 prc1023;
0231     u64 prc1522;
0232     u64 tlpic;
0233     u64 rlpic;
0234     u64 gprc;
0235     u64 bprc;
0236     u64 mprc;
0237     u64 gptc;
0238     u64 gorc;
0239     u64 gotc;
0240     u64 rnbc;
0241     u64 ruc;
0242     u64 rfc;
0243     u64 roc;
0244     u64 rjc;
0245     u64 mgprc;
0246     u64 mgpdc;
0247     u64 mgptc;
0248     u64 tor;
0249     u64 tot;
0250     u64 tpr;
0251     u64 tpt;
0252     u64 ptc64;
0253     u64 ptc127;
0254     u64 ptc255;
0255     u64 ptc511;
0256     u64 ptc1023;
0257     u64 ptc1522;
0258     u64 mptc;
0259     u64 bptc;
0260     u64 tsctc;
0261     u64 tsctfc;
0262     u64 iac;
0263     u64 htdpmc;
0264     u64 rpthc;
0265     u64 hgptc;
0266     u64 hgorc;
0267     u64 hgotc;
0268     u64 lenerrs;
0269     u64 scvpc;
0270     u64 hrmpc;
0271     u64 doosync;
0272     u64 o2bgptc;
0273     u64 o2bspc;
0274     u64 b2ospc;
0275     u64 b2ogprc;
0276 };
0277 
0278 struct net_device *igc_get_hw_dev(struct igc_hw *hw);
0279 #define hw_dbg(format, arg...) \
0280     netdev_dbg(igc_get_hw_dev(hw), format, ##arg)
0281 
0282 s32  igc_read_pcie_cap_reg(struct igc_hw *hw, u32 reg, u16 *value);
0283 s32  igc_write_pcie_cap_reg(struct igc_hw *hw, u32 reg, u16 *value);
0284 void igc_read_pci_cfg(struct igc_hw *hw, u32 reg, u16 *value);
0285 void igc_write_pci_cfg(struct igc_hw *hw, u32 reg, u16 *value);
0286 
0287 #endif /* _IGC_HW_H_ */