igc: Add HW initialization code
Subsystems (2)
PATCH v4 7/11 igc: Add HW initialization code
Add code for hw initialization and reset.
Add code for semaphore handling.
Sasha Neftin (v2):
fixed code indentation
refactor of igc_desc_unused method
Sasha Neftin (v3):
clean code and remove unused methods
Sasha Neftin (v4):
address comments
fix comments in e1000_i225.c and e1000_regs.h files fix xmas tree layout
fix typos in e1000_mac.c file
replace e1000_ prefix with igc_ prefix
--- drivers/net/ethernet/intel/igc/Makefile | 2 +- drivers/net/ethernet/intel/igc/igc_base.c | 192 ++++++++++++++++ drivers/net/ethernet/intel/igc/igc_base.h | 2 + drivers/net/ethernet/intel/igc/igc_defines.h | 39 ++++ drivers/net/ethernet/intel/igc/igc_hw.h | 85 +++++++ drivers/net/ethernet/intel/igc/igc_i225.c | 141 ++++++++++++ drivers/net/ethernet/intel/igc/igc_mac.c | 320 +++++++++++++++++++++++++++ drivers/net/ethernet/intel/igc/igc_mac.h | 11 + drivers/net/ethernet/intel/igc/igc_main.c | 21 ++ drivers/net/ethernet/intel/igc/igc_regs.h | 20 ++ 10 files changed, 832 insertions(+), 1 deletion(-) create mode 100644 drivers/net/ethernet/intel/igc/igc_i225.c
drivers/net/ethernet/intel/igc/Makefile +1 -1
@@ -7,4 +7,4 @@ obj-$(CONFIG_IGC) += igc.o -igc-objs := igc_main.o igc_mac.o igc_base.o +igc-objs := igc_main.o igc_mac.o igc_i225.o igc_base.o
drivers/net/ethernet/intel/igc/igc_base.c +192 -0
201 lines not on this page · raw message
drivers/net/ethernet/intel/igc/igc_base.h +2 -0
@@ -33,6 +33,8 @@ union igc_adv_tx_desc {#define IGC_ADVTXD_DCMD_TSE 0x80000000/* TCP Seg enable */ #define IGC_ADVTXD_PAYLEN_SHIFT 14/* Adv desc PAYLEN shift */ +#define IGC_RAR_ENTRIES 16 +struct igc_adv_data_desc {__le64 buffer_addr;/* Address of the descriptor's data buffer */ union {
drivers/net/ethernet/intel/igc/igc_defines.h +39 -0
@@ -17,6 +17,22 @@#define PCIE_DEVICE_CONTROL2 0x28#define PCIE_DEVICE_CONTROL2_16ms 0x0005 +/* Physical Func Reset Done Indication */ +#define IGC_CTRL_EXT_LINK_MODE_MASK 0x00C00000 + +/* Number of 100 microseconds we wait for PCI Express master disable */ +#define MASTER_DISABLE_TIMEOUT 800 +/*Blocks new Master requests */ +#define IGC_CTRL_GIO_MASTER_DISABLE 0x00000004 +/* Status of Master requests. */ +#define IGC_STATUS_GIO_MASTER_ENABLE 0x00080000 + +/* PCI Express Control */ +#define IGC_GCR_CMPL_TMOUT_MASK 0x0000F000 +#define IGC_GCR_CMPL_TMOUT_10ms 0x00001000 +#define IGC_GCR_CMPL_TMOUT_RESEND 0x00010000 +#define IGC_GCR_CAP_VER2 0x00040000 +/* Receive Address * Number of high/low register pairs in the RAR. The RAR (Receive Address * Registers) holds the directed and multicast addresses that we monitor.
@@ -35,10 +51,26 @@#define IGC_ERR_PARAM 4#define IGC_ERR_MAC_INIT 5#define IGC_ERR_RESET 9 +#define IGC_ERR_MASTER_REQUESTS_PENDING 10 +#define IGC_ERR_SWFW_SYNC 13 + +/* Device Control */ +#define IGC_CTRL_RST 0x04000000/* Global reset */ /* PBA constants */ #define IGC_PBA_34K 0x0022 +/* SW Semaphore Register */ +#define IGC_SWSM_SMBI 0x00000001/* Driver Semaphore bit */ +#define IGC_SWSM_SWESMBI 0x00000002/* FW Semaphore bit */ + +/* NVM Control */ +#define IGC_EECD_PRES 0x00000100/* NVM Present */ + +/* Number of milliseconds for NVM auto read done after MAC reset. */ +#define AUTO_READ_DONE_TIMEOUT 10 +#define IGC_EECD_AUTO_RD 0x00000200/* NVM Auto Read done */ +/* Device Status */ #define IGC_STATUS_FD 0x00000001/* Full duplex.0=half,1=full */ #define IGC_STATUS_LU 0x00000002/* Link up.0=no,1=link */
@@ -125,6 +157,13 @@#define IGC_CT_SHIFT 4#define IGC_COLLISION_THRESHOLD 15 +/* Flow Control Constants */ +#define FLOW_CONTROL_ADDRESS_LOW 0x00C28001 +#define FLOW_CONTROL_ADDRESS_HIGH 0x00000100 +#define FLOW_CONTROL_TYPE 0x8808 +/* Enable XON frame transmission */ +#define IGC_FCRTL_XONE 0x80000000 +/* Management Control */ #define IGC_MANC_RCV_TCO_EN 0x00020000/* Receive TCO Packets Enabled */
drivers/net/ethernet/intel/igc/igc_hw.h +85 -0
136 lines not on this page · raw message
drivers/net/ethernet/intel/igc/igc_i225.c new file +141 -0
141 lines not on this page · raw message
drivers/net/ethernet/intel/igc/igc_mac.c +320 -0
331 lines not on this page · raw message
drivers/net/ethernet/intel/igc/igc_mac.h +11 -0
@@ -4,10 +4,21 @@#ifndef _IGC_MAC_H_#define _IGC_MAC_H_ +#include "igc_hw.h" +#include "igc_defines.h" +#ifndef IGC_REMOVED #define IGC_REMOVED @ (0)#endif /* IGC_REMOVED */ +/* forward declaration */ +s32 igc_disable_pcie_master (struct igc_hw *hw); +void igc_init_rx_addrs (struct igc_hw *hw,u16 rar_count); +s32 igc_setup_link (struct igc_hw *hw); +void igc_clear_hw_cntrs_base (struct igc_hw *hw); +s32 igc_get_auto_rd_done (struct igc_hw *hw); +void igc_put_hw_semaphore (struct igc_hw *hw); +s32 igc_get_bus_info_pcie (struct igc_hw *hw);#endif
drivers/net/ethernet/intel/igc/igc_main.c +21 -0
@@ -86,6 +86,14 @@ enum latency_range {static void igc_reset (struct igc_adapter *adapter) { +struct pci_dev *pdev = adapter->pdev; +struct igc_hw *hw = &adapter->hw; + + hw->mac.ops.reset_hw (hw); + +if (hw->mac.ops.init_hw (hw)) +dev_err (&pdev->dev,"Hardware Error\n" ); +if (!netif_running (adapter->netdev))igc_power_down_link (adapter); }
@@ -3588,6 +3596,19 @@ static void igc_nfc_filter_exit(struct igc_adapter *adapter) }/** +* igc_get_hw_dev - return device +* @hw: pointer to hardware structure +* +* used by hardware layer to print debugging information +**/ +struct net_device *igc_get_hw_dev (struct igc_hw *hw) +{ +struct igc_adapter *adapter = hw->back; + +return adapter->netdev; +} + +/** * igc_init_module - Driver Registration Routine * * igc_init_module is the first routine called when the driver is
drivers/net/ethernet/intel/igc/igc_regs.h +20 -0
@@ -7,6 +7,7 @@/* General Register Descriptions */ #define IGC_CTRL 0x00000/* Device Control - RW */ #define IGC_STATUS 0x00008/* Device Status - RO */ +#define IGC_EECD 0x00010/* EEPROM/Flash Control - RW */ #define IGC_CTRL_EXT 0x00018/* Extended Device Control - RW */ #define IGC_MDIC 0x00020/* MDI Control - RW */ #define IGC_MDICNFG 0x00E04/* MDC/MDIO Configuration - RW */
@@ -56,6 +57,23 @@#define IGC_IVAR_MISC 0x01740/* IVAR for "other" causes - RW */ #define IGC_GPIE 0x01514/* General Purpose Intr Enable - RW */ +/* Interrupt Cause */ +#define IGC_ICRXPTC 0x04104/* Rx Packet Timer Expire Count */ +#define IGC_ICRXATC 0x04108/* Rx Absolute Timer Expire Count */ +#define IGC_ICTXPTC 0x0410C/* Tx Packet Timer Expire Count */ +#define IGC_ICTXATC 0x04110/* Tx Absolute Timer Expire Count */ +#define IGC_ICTXQEC 0x04118/* Tx Queue Empty Count */ +#define IGC_ICTXQMTC 0x0411C/* Tx Queue Min Threshold Count */ +#define IGC_ICRXDMTC 0x04120/* Rx Descriptor Min Threshold Count */ +#define IGC_ICRXOC 0x04124/* Receiver Overrun Count */ + +#define IGC_CBTMPC 0x0402C/* Circuit Breaker TX Packet Count */ +#define IGC_HTDPMC 0x0403C/* Host Transmit Discarded Packets */ +#define IGC_CBRMPC 0x040FC/* Circuit Breaker RX Packet Count */ +#define IGC_RPTHC 0x04104/* Rx Packets To Host */ +#define IGC_HGPTC 0x04118/* Host Good Packets TX Count */ +#define IGC_HTCBDPC 0x04124/* Host TX Circ.Breaker Drop Count */ +/* MSI-X Table Register Descriptions */ #define IGC_PBACL 0x05B68/* MSIx PBA Clear - R/W 1 to clear */
@@ -73,6 +91,8 @@#define IGC_RXCSUM 0x05000/* Rx Checksum Control - RW */ #define IGC_RLPML 0x05004/* Rx Long Packet Max Length */ #define IGC_RFCTL 0x05008/* Receive Filter Control*/ +#define IGC_MTA 0x05200/* Multicast Table Array - RW Array */ +#define IGC_UTA 0x0A000/* Unicast Table Array - RW */ #define IGC_RAL (_n) (0x05400 + ((_n) * 0x08))#define IGC_RAH (_n) (0x05404 + ((_n) * 0x08))
Signature · 1 line
2.11.0
kbuild test robot
build botThank you for the patch! Perhaps something to improve:
Hi Sasha,
Thank you for the patch! Perhaps something to improve:
[auto build test WARNING on jkirsher-next-queue/dev-queue]
[also build test WARNING on v4.18-rc5 next-20180718]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]
url: https://github.com/0day-ci/linux/commits/Sasha-Neftin/igc-Add-skeletal-frame-for-Intel-R-2-5G-Ethernet-Controller-support/20180719-055021 base: https://git.kernel.org/pub/scm/linux/kernel/git/jkirsher/next-queue.git dev-queue reproduce: # apt-get install sparse make ARCH=x86_64 allmodconfig make C=1 CF=-D__CHECK_ENDIAN__
sparse warnings: (new ones prefixed by >>)
>> drivers/net/ethernet/intel/igc/igc_mac.c:228:9: sparse: incorrect type in initializer (different address spaces) @@ expected unsigned char [noderef] [usertype] <asn:2>*hw_addr @@ got deref] [usertype] <asn:2>*hw_addr @@
drivers/net/ethernet/intel/igc/igc_mac.c:228:9: expected unsigned char [noderef] [usertype] <asn:2>*hw_addr
drivers/net/ethernet/intel/igc/igc_mac.c:228:9: got unsigned char [usertype] *__val
drivers/net/ethernet/intel/igc/igc_mac.c:229:9: sparse: incorrect type in initializer (different address spaces) @@ expected unsigned char [noderef] [usertype] <asn:2>*hw_addr @@ got deref] [usertype] <asn:2>*hw_addr @@
drivers/net/ethernet/intel/igc/igc_mac.c:229:9: expected unsigned char [noderef] [usertype] <asn:2>*hw_addr
drivers/net/ethernet/intel/igc/igc_mac.c:229:9: got unsigned char [usertype] *__val
drivers/net/ethernet/intel/igc/igc_mac.c:82:9: sparse: incorrect type in initializer (different address spaces) @@ expected unsigned char [noderef] [usertype] <asn:2>*hw_addr @@ got deref] [usertype] <asn:2>*hw_addr @@
drivers/net/ethernet/intel/igc/igc_mac.c:82:9: expected unsigned char [noderef] [usertype] <asn:2>*hw_addr
drivers/net/ethernet/intel/igc/igc_mac.c:82:9: got unsigned char [usertype] *__val
drivers/net/ethernet/intel/igc/igc_mac.c:173:9: sparse: incorrect type in initializer (different address spaces) @@ expected unsigned char [noderef] [usertype] <asn:2>*hw_addr @@ got deref] [usertype] <asn:2>*hw_addr @@
drivers/net/ethernet/intel/igc/igc_mac.c:173:9: expected unsigned char [noderef] [usertype] <asn:2>*hw_addr
drivers/net/ethernet/intel/igc/igc_mac.c:173:9: got unsigned char [usertype] *__val
drivers/net/ethernet/intel/igc/igc_mac.c:174:9: sparse: incorrect type in initializer (different address spaces) @@ expected unsigned char [noderef] [usertype] <asn:2>*hw_addr @@ got deref] [usertype] <asn:2>*hw_addr @@
drivers/net/ethernet/intel/igc/igc_mac.c:174:9: expected unsigned char [noderef] [usertype] <asn:2>*hw_addr
drivers/net/ethernet/intel/igc/igc_mac.c:174:9: got unsigned char [usertype] *__val
drivers/net/ethernet/intel/igc/igc_mac.c:175:9: sparse: incorrect type in initializer (different address spaces) @@ expected unsigned char [noderef] [usertype] <asn:2>*hw_addr @@ got deref] [usertype] <asn:2>*hw_addr @@
drivers/net/ethernet/intel/igc/igc_mac.c:175:9: expected unsigned char [noderef] [usertype] <asn:2>*hw_addr
drivers/net/ethernet/intel/igc/igc_mac.c:175:9: got unsigned char [usertype] *__val
drivers/net/ethernet/intel/igc/igc_mac.c:177:9: sparse: incorrect type in initializer (different address spaces) @@ expected unsigned char [noderef] [usertype] <asn:2>*hw_addr @@ got deref] [usertype] <asn:2>*hw_addr @@
drivers/net/ethernet/intel/igc/igc_mac.c:177:9: expected unsigned char [noderef] [usertype] <asn:2>*hw_addr
drivers/net/ethernet/intel/igc/igc_mac.c:177:9: got unsigned char [usertype] *__val
drivers/net/ethernet/intel/igc/igc_mac.c:370:9: sparse: incorrect type in initializer (different address spaces) @@ expected unsigned char [noderef] [usertype] <asn:2>*hw_addr @@ got deref] [usertype] <asn:2>*hw_addr @@
drivers/net/ethernet/intel/igc/igc_mac.c:370:9: expected unsigned char [noderef] [usertype] <asn:2>*hw_addr
drivers/net/ethernet/intel/igc/igc_mac.c:370:9: got unsigned char [usertype] *__val
--
>> drivers/net/ethernet/intel/igc/igc_i225.c:56:17: sparse: incorrect type in initializer (different address spaces) @@ expected unsigned char [noderef] [usertype] <asn:2>*hw_addr @@ got deref] [usertype] <asn:2>*hw_addr @@
drivers/net/ethernet/intel/igc/igc_i225.c:56:17: expected unsigned char [noderef] [usertype] <asn:2>*hw_addr
drivers/net/ethernet/intel/igc/igc_i225.c:56:17: got unsigned char [usertype] *__val
drivers/net/ethernet/intel/igc/igc_i225.c:114:9: sparse: incorrect type in initializer (different address spaces) @@ expected unsigned char [noderef] [usertype] <asn:2>*hw_addr @@ got deref] [usertype] <asn:2>*hw_addr @@
drivers/net/ethernet/intel/igc/igc_i225.c:114:9: expected unsigned char [noderef] [usertype] <asn:2>*hw_addr
drivers/net/ethernet/intel/igc/igc_i225.c:114:9: got unsigned char [usertype] *__val
drivers/net/ethernet/intel/igc/igc_i225.c:138:9: sparse: incorrect type in initializer (different address spaces) @@ expected unsigned char [noderef] [usertype] <asn:2>*hw_addr @@ got deref] [usertype] <asn:2>*hw_addr @@
drivers/net/ethernet/intel/igc/igc_i225.c:138:9: expected unsigned char [noderef] [usertype] <asn:2>*hw_addr
drivers/net/ethernet/intel/igc/igc_i225.c:138:9: got unsigned char [usertype] *__val
vim +228 drivers/net/ethernet/intel/igc/igc_mac.c
197
198 /**
199 * igc_set_fc_watermarks - Set flow control high/low watermarks
200 * @hw: pointer to the HW structure
201 *
202 * Sets the flow control high/low threshold (watermark) registers. If
203 * flow control XON frame transmission is enabled, then set XON frame
204 * transmission as well.
205 **/
206 static s32 igc_set_fc_watermarks(struct igc_hw *hw)
207 {
208 u32 fcrtl = 0, fcrth = 0;
209 s32 ret_val = 0;
210
211 /* Set the flow control receive threshold registers. Normally,
212 * these registers will be set to a default threshold that may be
213 * adjusted later by the driver's runtime code. However, if the
214 * ability to transmit pause frames is not enabled, then these
215 * registers will be set to 0.
216 */
217 if (hw->fc.current_mode & igc_fc_tx_pause) {
218 /* We need to set up the Receive Threshold high and low water
219 * marks as well as (optionally) enabling the transmission of
220 * XON frames.
221 */
222 fcrtl = hw->fc.low_water;
223 if (hw->fc.send_xon)
224 fcrtl |= IGC_FCRTL_XONE;
225
226 fcrth = hw->fc.high_water;
227 }
> 228 wr32(IGC_FCRTL, fcrtl); 229 wr32(IGC_FCRTH, fcrth);
230
231 return ret_val;
232 }
233
---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation