e1000_mac.c (176667) | e1000_mac.c (177867) |
---|---|
1/******************************************************************************* | 1/****************************************************************************** |
2 3 Copyright (c) 2001-2008, 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, --- 14 unchanged lines hidden (view full) --- 24 LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 25 CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 26 SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 27 INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 28 CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 29 ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 30 POSSIBILITY OF SUCH DAMAGE. 31 | 2 3 Copyright (c) 2001-2008, 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, --- 14 unchanged lines hidden (view full) --- 24 LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 25 CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 26 SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 27 INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 28 CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 29 ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 30 POSSIBILITY OF SUCH DAMAGE. 31 |
32*******************************************************************************/ 33/* $FreeBSD: head/sys/dev/em/e1000_mac.c 176667 2008-02-29 21:50:11Z jfv $ */ | 32******************************************************************************/ 33/*$FreeBSD: head/sys/dev/em/e1000_mac.c 177867 2008-04-02 22:00:36Z jfv $*/ |
34 | 34 |
35 | |
36#include "e1000_api.h" 37#include "e1000_mac.h" 38 39/** | 35#include "e1000_api.h" 36#include "e1000_mac.h" 37 38/** |
39 * e1000_init_mac_ops_generic - Initialize MAC function pointers 40 * @hw: pointer to the HW structure 41 * 42 * Setups up the function pointers to no-op functions 43 **/ 44void e1000_init_mac_ops_generic(struct e1000_hw *hw) 45{ 46 struct e1000_mac_info *mac = &hw->mac; 47 DEBUGFUNC("e1000_init_mac_ops_generic"); 48 49 /* General Setup */ 50 mac->ops.init_params = e1000_null_ops_generic; 51 mac->ops.init_hw = e1000_null_ops_generic; 52 mac->ops.reset_hw = e1000_null_ops_generic; 53 mac->ops.setup_physical_interface = e1000_null_ops_generic; 54 mac->ops.get_bus_info = e1000_null_ops_generic; 55 mac->ops.read_mac_addr = e1000_read_mac_addr_generic; 56 mac->ops.remove_device = e1000_remove_device_generic; 57 mac->ops.config_collision_dist = e1000_config_collision_dist_generic; 58 mac->ops.clear_hw_cntrs = e1000_null_mac_generic; 59 /* LED */ 60 mac->ops.cleanup_led = e1000_null_ops_generic; 61 mac->ops.setup_led = e1000_null_ops_generic; 62 mac->ops.blink_led = e1000_null_ops_generic; 63 mac->ops.led_on = e1000_null_ops_generic; 64 mac->ops.led_off = e1000_null_ops_generic; 65 /* LINK */ 66 mac->ops.setup_link = e1000_null_ops_generic; 67 mac->ops.get_link_up_info = e1000_null_link_info; 68 mac->ops.check_for_link = e1000_null_ops_generic; 69 mac->ops.wait_autoneg = e1000_wait_autoneg_generic; 70 /* Management */ 71 mac->ops.check_mng_mode = e1000_null_mng_mode; 72 mac->ops.mng_host_if_write = e1000_mng_host_if_write_generic; 73 mac->ops.mng_write_cmd_header = e1000_mng_write_cmd_header_generic; 74 mac->ops.mng_enable_host_if = e1000_mng_enable_host_if_generic; 75 /* VLAN, MC, etc. */ 76 mac->ops.update_mc_addr_list = e1000_null_update_mc; 77 mac->ops.clear_vfta = e1000_null_mac_generic; 78 mac->ops.write_vfta = e1000_null_write_vfta; 79 mac->ops.mta_set = e1000_null_mta_set; 80 mac->ops.rar_set = e1000_rar_set_generic; 81 mac->ops.validate_mdi_setting = e1000_validate_mdi_setting_generic; 82} 83 84/** 85 * e1000_null_ops_generic - No-op function, returns 0 86 * @hw: pointer to the HW structure 87 **/ 88s32 e1000_null_ops_generic(struct e1000_hw *hw) 89{ 90 DEBUGFUNC("e1000_null_ops_generic"); 91 return E1000_SUCCESS; 92} 93 94/** 95 * e1000_null_mac_generic - No-op function, return void 96 * @hw: pointer to the HW structure 97 **/ 98void e1000_null_mac_generic(struct e1000_hw *hw) 99{ 100 DEBUGFUNC("e1000_null_mac_generic"); 101 return; 102} 103 104/** 105 * e1000_null_link_info - No-op function, return 0 106 * @hw: pointer to the HW structure 107 **/ 108s32 e1000_null_link_info(struct e1000_hw *hw, u16 *s, u16 *d) 109{ 110 DEBUGFUNC("e1000_null_link_info"); 111 return E1000_SUCCESS; 112} 113 114/** 115 * e1000_null_mng_mode - No-op function, return FALSE 116 * @hw: pointer to the HW structure 117 **/ 118bool e1000_null_mng_mode(struct e1000_hw *hw) 119{ 120 DEBUGFUNC("e1000_null_mng_mode"); 121 return FALSE; 122} 123 124/** 125 * e1000_null_update_mc - No-op function, return void 126 * @hw: pointer to the HW structure 127 **/ 128void e1000_null_update_mc(struct e1000_hw *hw, u8 *h, u32 a, u32 b, u32 c) 129{ 130 DEBUGFUNC("e1000_null_update_mc"); 131 return; 132} 133 134/** 135 * e1000_null_write_vfta - No-op function, return void 136 * @hw: pointer to the HW structure 137 **/ 138void e1000_null_write_vfta(struct e1000_hw *hw, u32 a, u32 b) 139{ 140 DEBUGFUNC("e1000_null_write_vfta"); 141 return; 142} 143 144/** 145 * e1000_null_set_mta - No-op function, return void 146 * @hw: pointer to the HW structure 147 **/ 148void e1000_null_mta_set(struct e1000_hw *hw, u32 a) 149{ 150 DEBUGFUNC("e1000_null_mta_set"); 151 return; 152} 153 154/** 155 * e1000_null_rar_set - No-op function, return void 156 * @hw: pointer to the HW structure 157 **/ 158void e1000_null_rar_set(struct e1000_hw *hw, u8 *h, u32 a) 159{ 160 DEBUGFUNC("e1000_null_rar_set"); 161 return; 162} 163 164/** |
|
40 * e1000_remove_device_generic - Free device specific structure 41 * @hw: pointer to the HW structure 42 * 43 * If a device specific structure was allocated, this function will 44 * free it. 45 **/ 46void e1000_remove_device_generic(struct e1000_hw *hw) 47{ --- 154 unchanged lines hidden (view full) --- 202{ 203 u32 i; 204 205 DEBUGFUNC("e1000_init_rx_addrs_generic"); 206 207 /* Setup the receive address */ 208 DEBUGOUT("Programming MAC Address into RAR[0]\n"); 209 | 165 * e1000_remove_device_generic - Free device specific structure 166 * @hw: pointer to the HW structure 167 * 168 * If a device specific structure was allocated, this function will 169 * free it. 170 **/ 171void e1000_remove_device_generic(struct e1000_hw *hw) 172{ --- 154 unchanged lines hidden (view full) --- 327{ 328 u32 i; 329 330 DEBUGFUNC("e1000_init_rx_addrs_generic"); 331 332 /* Setup the receive address */ 333 DEBUGOUT("Programming MAC Address into RAR[0]\n"); 334 |
210 e1000_rar_set_generic(hw, hw->mac.addr, 0); | 335 hw->mac.ops.rar_set(hw, hw->mac.addr, 0); |
211 212 /* Zero out the other (rar_entry_count - 1) receive addresses */ 213 DEBUGOUT1("Clearing RAR[1-%u]\n", rar_count-1); 214 for (i = 1; i < rar_count; i++) { 215 E1000_WRITE_REG_ARRAY(hw, E1000_RA, (i << 1), 0); 216 E1000_WRITE_FLUSH(hw); 217 E1000_WRITE_REG_ARRAY(hw, E1000_RA, ((i << 1) + 1), 0); 218 E1000_WRITE_FLUSH(hw); --- 15 unchanged lines hidden (view full) --- 234{ 235 u32 i; 236 s32 ret_val = E1000_SUCCESS; 237 u16 offset, nvm_alt_mac_addr_offset, nvm_data; 238 u8 alt_mac_addr[ETH_ADDR_LEN]; 239 240 DEBUGFUNC("e1000_check_alt_mac_addr_generic"); 241 | 336 337 /* Zero out the other (rar_entry_count - 1) receive addresses */ 338 DEBUGOUT1("Clearing RAR[1-%u]\n", rar_count-1); 339 for (i = 1; i < rar_count; i++) { 340 E1000_WRITE_REG_ARRAY(hw, E1000_RA, (i << 1), 0); 341 E1000_WRITE_FLUSH(hw); 342 E1000_WRITE_REG_ARRAY(hw, E1000_RA, ((i << 1) + 1), 0); 343 E1000_WRITE_FLUSH(hw); --- 15 unchanged lines hidden (view full) --- 359{ 360 u32 i; 361 s32 ret_val = E1000_SUCCESS; 362 u16 offset, nvm_alt_mac_addr_offset, nvm_data; 363 u8 alt_mac_addr[ETH_ADDR_LEN]; 364 365 DEBUGFUNC("e1000_check_alt_mac_addr_generic"); 366 |
242 ret_val = e1000_read_nvm(hw, NVM_ALT_MAC_ADDR_PTR, 1, | 367 ret_val = hw->nvm.ops.read(hw, NVM_ALT_MAC_ADDR_PTR, 1, |
243 &nvm_alt_mac_addr_offset); 244 if (ret_val) { 245 DEBUGOUT("NVM Read Error\n"); 246 goto out; 247 } 248 249 if (nvm_alt_mac_addr_offset == 0xFFFF) { 250 ret_val = -(E1000_NOT_IMPLEMENTED); 251 goto out; 252 } 253 254 if (hw->bus.func == E1000_FUNC_1) 255 nvm_alt_mac_addr_offset += ETH_ADDR_LEN/sizeof(u16); 256 257 for (i = 0; i < ETH_ADDR_LEN; i += 2) { 258 offset = nvm_alt_mac_addr_offset + (i >> 1); | 368 &nvm_alt_mac_addr_offset); 369 if (ret_val) { 370 DEBUGOUT("NVM Read Error\n"); 371 goto out; 372 } 373 374 if (nvm_alt_mac_addr_offset == 0xFFFF) { 375 ret_val = -(E1000_NOT_IMPLEMENTED); 376 goto out; 377 } 378 379 if (hw->bus.func == E1000_FUNC_1) 380 nvm_alt_mac_addr_offset += ETH_ADDR_LEN/sizeof(u16); 381 382 for (i = 0; i < ETH_ADDR_LEN; i += 2) { 383 offset = nvm_alt_mac_addr_offset + (i >> 1); |
259 ret_val = e1000_read_nvm(hw, offset, 1, &nvm_data); | 384 ret_val = hw->nvm.ops.read(hw, offset, 1, &nvm_data); |
260 if (ret_val) { 261 DEBUGOUT("NVM Read Error\n"); 262 goto out; 263 } 264 265 alt_mac_addr[i] = (u8)(nvm_data & 0xFF); 266 alt_mac_addr[i + 1] = (u8)(nvm_data >> 8); 267 } 268 269 /* if multicast bit is set, the alternate address will not be used */ 270 if (alt_mac_addr[0] & 0x01) { 271 ret_val = -(E1000_NOT_IMPLEMENTED); 272 goto out; 273 } 274 275 for (i = 0; i < ETH_ADDR_LEN; i++) 276 hw->mac.addr[i] = hw->mac.perm_addr[i] = alt_mac_addr[i]; 277 | 385 if (ret_val) { 386 DEBUGOUT("NVM Read Error\n"); 387 goto out; 388 } 389 390 alt_mac_addr[i] = (u8)(nvm_data & 0xFF); 391 alt_mac_addr[i + 1] = (u8)(nvm_data >> 8); 392 } 393 394 /* if multicast bit is set, the alternate address will not be used */ 395 if (alt_mac_addr[0] & 0x01) { 396 ret_val = -(E1000_NOT_IMPLEMENTED); 397 goto out; 398 } 399 400 for (i = 0; i < ETH_ADDR_LEN; i++) 401 hw->mac.addr[i] = hw->mac.perm_addr[i] = alt_mac_addr[i]; 402 |
278 e1000_rar_set(hw, hw->mac.perm_addr, 0); | 403 hw->mac.ops.rar_set(hw, hw->mac.perm_addr, 0); |
279 280out: 281 return ret_val; 282} 283 284/** 285 * e1000_rar_set_generic - Set receive address register 286 * @hw: pointer to the HW structure --- 89 unchanged lines hidden (view full) --- 376 377 /* 378 * Load the first set of multicast addresses into the exact 379 * filters (RAR). If there are not enough to fill the RAR 380 * array, clear the filters. 381 */ 382 for (i = rar_used_count; i < rar_count; i++) { 383 if (mc_addr_count) { | 404 405out: 406 return ret_val; 407} 408 409/** 410 * e1000_rar_set_generic - Set receive address register 411 * @hw: pointer to the HW structure --- 89 unchanged lines hidden (view full) --- 501 502 /* 503 * Load the first set of multicast addresses into the exact 504 * filters (RAR). If there are not enough to fill the RAR 505 * array, clear the filters. 506 */ 507 for (i = rar_used_count; i < rar_count; i++) { 508 if (mc_addr_count) { |
384 e1000_rar_set(hw, mc_addr_list, i); | 509 hw->mac.ops.rar_set(hw, mc_addr_list, i); |
385 mc_addr_count--; 386 mc_addr_list += ETH_ADDR_LEN; 387 } else { 388 E1000_WRITE_REG_ARRAY(hw, E1000_RA, i << 1, 0); 389 E1000_WRITE_FLUSH(hw); 390 E1000_WRITE_REG_ARRAY(hw, E1000_RA, (i << 1) + 1, 0); 391 E1000_WRITE_FLUSH(hw); 392 } --- 5 unchanged lines hidden (view full) --- 398 E1000_WRITE_REG_ARRAY(hw, E1000_MTA, i, 0); 399 E1000_WRITE_FLUSH(hw); 400 } 401 402 /* Load any remaining multicast addresses into the hash table. */ 403 for (; mc_addr_count > 0; mc_addr_count--) { 404 hash_value = e1000_hash_mc_addr(hw, mc_addr_list); 405 DEBUGOUT1("Hash value = 0x%03X\n", hash_value); | 510 mc_addr_count--; 511 mc_addr_list += ETH_ADDR_LEN; 512 } else { 513 E1000_WRITE_REG_ARRAY(hw, E1000_RA, i << 1, 0); 514 E1000_WRITE_FLUSH(hw); 515 E1000_WRITE_REG_ARRAY(hw, E1000_RA, (i << 1) + 1, 0); 516 E1000_WRITE_FLUSH(hw); 517 } --- 5 unchanged lines hidden (view full) --- 523 E1000_WRITE_REG_ARRAY(hw, E1000_MTA, i, 0); 524 E1000_WRITE_FLUSH(hw); 525 } 526 527 /* Load any remaining multicast addresses into the hash table. */ 528 for (; mc_addr_count > 0; mc_addr_count--) { 529 hash_value = e1000_hash_mc_addr(hw, mc_addr_list); 530 DEBUGOUT1("Hash value = 0x%03X\n", hash_value); |
406 e1000_mta_set(hw, hash_value); | 531 hw->mac.ops.mta_set(hw, hash_value); |
407 mc_addr_list += ETH_ADDR_LEN; 408 } 409} 410 411/** 412 * e1000_hash_mc_addr_generic - Generate a multicast hash value 413 * @hw: pointer to the HW structure 414 * @mc_addr: pointer to a multicast address --- 401 unchanged lines hidden (view full) --- 816 * Determines which flow control settings to use, then configures flow 817 * control. Calls the appropriate media-specific link configuration 818 * function. Assuming the adapter has a valid link partner, a valid link 819 * should be established. Assumes the hardware has previously been reset 820 * and the transmitter and receiver are not enabled. 821 **/ 822s32 e1000_setup_link_generic(struct e1000_hw *hw) 823{ | 532 mc_addr_list += ETH_ADDR_LEN; 533 } 534} 535 536/** 537 * e1000_hash_mc_addr_generic - Generate a multicast hash value 538 * @hw: pointer to the HW structure 539 * @mc_addr: pointer to a multicast address --- 401 unchanged lines hidden (view full) --- 941 * Determines which flow control settings to use, then configures flow 942 * control. Calls the appropriate media-specific link configuration 943 * function. Assuming the adapter has a valid link partner, a valid link 944 * should be established. Assumes the hardware has previously been reset 945 * and the transmitter and receiver are not enabled. 946 **/ 947s32 e1000_setup_link_generic(struct e1000_hw *hw) 948{ |
824 struct e1000_functions *func = &hw->func; | |
825 s32 ret_val = E1000_SUCCESS; 826 827 DEBUGFUNC("e1000_setup_link_generic"); 828 829 /* 830 * In the case of the phy reset being blocked, we already have a link. 831 * We do not need to set it up again. 832 */ | 949 s32 ret_val = E1000_SUCCESS; 950 951 DEBUGFUNC("e1000_setup_link_generic"); 952 953 /* 954 * In the case of the phy reset being blocked, we already have a link. 955 * We do not need to set it up again. 956 */ |
833 if (e1000_check_reset_block(hw)) 834 goto out; | 957 if (hw->phy.ops.check_reset_block) 958 if (hw->phy.ops.check_reset_block(hw)) 959 goto out; |
835 836 /* 837 * If flow control is set to default, set flow control based on 838 * the EEPROM flow control settings. 839 */ 840 if (hw->fc.type == e1000_fc_default) { 841 ret_val = e1000_set_default_fc_generic(hw); 842 if (ret_val) --- 5 unchanged lines hidden (view full) --- 848 * in case we get disconnected and then reconnected into a different 849 * hub or switch with different Flow Control capabilities. 850 */ 851 hw->fc.original_type = hw->fc.type; 852 853 DEBUGOUT1("After fix-ups FlowControl is now = %x\n", hw->fc.type); 854 855 /* Call the necessary media_type subroutine to configure the link. */ | 960 961 /* 962 * If flow control is set to default, set flow control based on 963 * the EEPROM flow control settings. 964 */ 965 if (hw->fc.type == e1000_fc_default) { 966 ret_val = e1000_set_default_fc_generic(hw); 967 if (ret_val) --- 5 unchanged lines hidden (view full) --- 973 * in case we get disconnected and then reconnected into a different 974 * hub or switch with different Flow Control capabilities. 975 */ 976 hw->fc.original_type = hw->fc.type; 977 978 DEBUGOUT1("After fix-ups FlowControl is now = %x\n", hw->fc.type); 979 980 /* Call the necessary media_type subroutine to configure the link. */ |
856 ret_val = func->setup_physical_interface(hw); | 981 ret_val = hw->mac.ops.setup_physical_interface(hw); |
857 if (ret_val) 858 goto out; 859 860 /* 861 * Initialize the flow control address, type, and PAUSE timer 862 * registers to their default values. This is done even if flow 863 * control is disabled, because it does not hurt anything to 864 * initialize these registers. --- 99 unchanged lines hidden (view full) --- 964{ 965 struct e1000_mac_info *mac = &hw->mac; 966 u32 i, status; 967 s32 ret_val = E1000_SUCCESS; 968 969 DEBUGFUNC("e1000_poll_fiber_serdes_link_generic"); 970 971 /* | 982 if (ret_val) 983 goto out; 984 985 /* 986 * Initialize the flow control address, type, and PAUSE timer 987 * registers to their default values. This is done even if flow 988 * control is disabled, because it does not hurt anything to 989 * initialize these registers. --- 99 unchanged lines hidden (view full) --- 1089{ 1090 struct e1000_mac_info *mac = &hw->mac; 1091 u32 i, status; 1092 s32 ret_val = E1000_SUCCESS; 1093 1094 DEBUGFUNC("e1000_poll_fiber_serdes_link_generic"); 1095 1096 /* |
972 * If we have a signal (the cable is plugged in, or assumed true for | 1097 * If we have a signal (the cable is plugged in, or assumed TRUE for |
973 * serdes media) then poll for a "Link-Up" indication in the Device 974 * Status Register. Time-out if a link isn't seen in 500 milliseconds 975 * seconds (Auto-negotiation should complete in less than 500 976 * milliseconds even if the other end is doing it in SW). 977 */ 978 for (i = 0; i < FIBER_LINK_UP_LIMIT; i++) { 979 msec_delay(10); 980 status = E1000_READ_REG(hw, E1000_STATUS); --- 4 unchanged lines hidden (view full) --- 985 DEBUGOUT("Never got a valid link from auto-neg!!!\n"); 986 mac->autoneg_failed = 1; 987 /* 988 * AutoNeg failed to achieve a link, so we'll call 989 * mac->check_for_link. This routine will force the 990 * link up if we detect a signal. This will allow us to 991 * communicate with non-autonegotiating link partners. 992 */ | 1098 * serdes media) then poll for a "Link-Up" indication in the Device 1099 * Status Register. Time-out if a link isn't seen in 500 milliseconds 1100 * seconds (Auto-negotiation should complete in less than 500 1101 * milliseconds even if the other end is doing it in SW). 1102 */ 1103 for (i = 0; i < FIBER_LINK_UP_LIMIT; i++) { 1104 msec_delay(10); 1105 status = E1000_READ_REG(hw, E1000_STATUS); --- 4 unchanged lines hidden (view full) --- 1110 DEBUGOUT("Never got a valid link from auto-neg!!!\n"); 1111 mac->autoneg_failed = 1; 1112 /* 1113 * AutoNeg failed to achieve a link, so we'll call 1114 * mac->check_for_link. This routine will force the 1115 * link up if we detect a signal. This will allow us to 1116 * communicate with non-autonegotiating link partners. 1117 */ |
993 ret_val = e1000_check_for_link(hw); | 1118 ret_val = hw->mac.ops.check_for_link(hw); |
994 if (ret_val) { 995 DEBUGOUT("Error while checking for link\n"); 996 goto out; 997 } 998 mac->autoneg_failed = 0; 999 } else { 1000 mac->autoneg_failed = 0; 1001 DEBUGOUT("Valid Link Found\n"); --- 137 unchanged lines hidden (view full) --- 1139 * Read and store word 0x0F of the EEPROM. This word contains bits 1140 * that determine the hardware's default PAUSE (flow control) mode, 1141 * a bit that determines whether the HW defaults to enabling or 1142 * disabling auto-negotiation, and the direction of the 1143 * SW defined pins. If there is no SW over-ride of the flow 1144 * control setting, then the variable hw->fc will 1145 * be initialized based on a value in the EEPROM. 1146 */ | 1119 if (ret_val) { 1120 DEBUGOUT("Error while checking for link\n"); 1121 goto out; 1122 } 1123 mac->autoneg_failed = 0; 1124 } else { 1125 mac->autoneg_failed = 0; 1126 DEBUGOUT("Valid Link Found\n"); --- 137 unchanged lines hidden (view full) --- 1264 * Read and store word 0x0F of the EEPROM. This word contains bits 1265 * that determine the hardware's default PAUSE (flow control) mode, 1266 * a bit that determines whether the HW defaults to enabling or 1267 * disabling auto-negotiation, and the direction of the 1268 * SW defined pins. If there is no SW over-ride of the flow 1269 * control setting, then the variable hw->fc will 1270 * be initialized based on a value in the EEPROM. 1271 */ |
1147 ret_val = e1000_read_nvm(hw, NVM_INIT_CONTROL2_REG, 1, &nvm_data); | 1272 ret_val = hw->nvm.ops.read(hw, NVM_INIT_CONTROL2_REG, 1, &nvm_data); |
1148 1149 if (ret_val) { 1150 DEBUGOUT("NVM Read Error\n"); 1151 goto out; 1152 } 1153 1154 if ((nvm_data & NVM_WORD0F_PAUSE_MASK) == 0) 1155 hw->fc.type = e1000_fc_none; --- 81 unchanged lines hidden (view full) --- 1237 * speed and duplex were not forced. If the link needed to be forced, then 1238 * flow control needs to be forced also. If auto-negotiation is enabled 1239 * and did not fail, then we configure flow control based on our link 1240 * partner. 1241 **/ 1242s32 e1000_config_fc_after_link_up_generic(struct e1000_hw *hw) 1243{ 1244 struct e1000_mac_info *mac = &hw->mac; | 1273 1274 if (ret_val) { 1275 DEBUGOUT("NVM Read Error\n"); 1276 goto out; 1277 } 1278 1279 if ((nvm_data & NVM_WORD0F_PAUSE_MASK) == 0) 1280 hw->fc.type = e1000_fc_none; --- 81 unchanged lines hidden (view full) --- 1362 * speed and duplex were not forced. If the link needed to be forced, then 1363 * flow control needs to be forced also. If auto-negotiation is enabled 1364 * and did not fail, then we configure flow control based on our link 1365 * partner. 1366 **/ 1367s32 e1000_config_fc_after_link_up_generic(struct e1000_hw *hw) 1368{ 1369 struct e1000_mac_info *mac = &hw->mac; |
1370 struct e1000_phy_info *phy = &hw->phy; |
|
1245 s32 ret_val = E1000_SUCCESS; 1246 u16 mii_status_reg, mii_nway_adv_reg, mii_nway_lp_ability_reg; 1247 u16 speed, duplex; 1248 1249 DEBUGFUNC("e1000_config_fc_after_link_up_generic"); 1250 1251 /* 1252 * Check for the case where we have fiber media and auto-neg failed --- 21 unchanged lines hidden (view full) --- 1274 * flow control configured. 1275 */ 1276 if ((hw->phy.media_type == e1000_media_type_copper) && mac->autoneg) { 1277 /* 1278 * Read the MII Status Register and check to see if AutoNeg 1279 * has completed. We read this twice because this reg has 1280 * some "sticky" (latched) bits. 1281 */ | 1371 s32 ret_val = E1000_SUCCESS; 1372 u16 mii_status_reg, mii_nway_adv_reg, mii_nway_lp_ability_reg; 1373 u16 speed, duplex; 1374 1375 DEBUGFUNC("e1000_config_fc_after_link_up_generic"); 1376 1377 /* 1378 * Check for the case where we have fiber media and auto-neg failed --- 21 unchanged lines hidden (view full) --- 1400 * flow control configured. 1401 */ 1402 if ((hw->phy.media_type == e1000_media_type_copper) && mac->autoneg) { 1403 /* 1404 * Read the MII Status Register and check to see if AutoNeg 1405 * has completed. We read this twice because this reg has 1406 * some "sticky" (latched) bits. 1407 */ |
1282 ret_val = e1000_read_phy_reg(hw, PHY_STATUS, &mii_status_reg); | 1408 ret_val = phy->ops.read_reg(hw, PHY_STATUS, &mii_status_reg); |
1283 if (ret_val) 1284 goto out; | 1409 if (ret_val) 1410 goto out; |
1285 ret_val = e1000_read_phy_reg(hw, PHY_STATUS, &mii_status_reg); | 1411 ret_val = phy->ops.read_reg(hw, PHY_STATUS, &mii_status_reg); |
1286 if (ret_val) 1287 goto out; 1288 1289 if (!(mii_status_reg & MII_SR_AUTONEG_COMPLETE)) { 1290 DEBUGOUT("Copper PHY and Auto Neg " 1291 "has not completed.\n"); 1292 goto out; 1293 } 1294 1295 /* 1296 * The AutoNeg process has completed, so we now need to 1297 * read both the Auto Negotiation Advertisement 1298 * Register (Address 4) and the Auto_Negotiation Base 1299 * Page Ability Register (Address 5) to determine how 1300 * flow control was negotiated. 1301 */ | 1412 if (ret_val) 1413 goto out; 1414 1415 if (!(mii_status_reg & MII_SR_AUTONEG_COMPLETE)) { 1416 DEBUGOUT("Copper PHY and Auto Neg " 1417 "has not completed.\n"); 1418 goto out; 1419 } 1420 1421 /* 1422 * The AutoNeg process has completed, so we now need to 1423 * read both the Auto Negotiation Advertisement 1424 * Register (Address 4) and the Auto_Negotiation Base 1425 * Page Ability Register (Address 5) to determine how 1426 * flow control was negotiated. 1427 */ |
1302 ret_val = e1000_read_phy_reg(hw, PHY_AUTONEG_ADV, | 1428 ret_val = phy->ops.read_reg(hw, PHY_AUTONEG_ADV, |
1303 &mii_nway_adv_reg); 1304 if (ret_val) 1305 goto out; | 1429 &mii_nway_adv_reg); 1430 if (ret_val) 1431 goto out; |
1306 ret_val = e1000_read_phy_reg(hw, PHY_LP_ABILITY, | 1432 ret_val = phy->ops.read_reg(hw, PHY_LP_ABILITY, |
1307 &mii_nway_lp_ability_reg); 1308 if (ret_val) 1309 goto out; 1310 1311 /* 1312 * Two bits in the Auto Negotiation Advertisement Register 1313 * (Address 4) and two bits in the Auto Negotiation Base 1314 * Page Ability Register (Address 5) determine flow control --- 83 unchanged lines hidden (view full) --- 1398 DEBUGOUT("Flow Control = NONE.\r\n"); 1399 } 1400 1401 /* 1402 * Now we need to do one last check... If we auto- 1403 * negotiated to HALF DUPLEX, flow control should not be 1404 * enabled per IEEE 802.3 spec. 1405 */ | 1433 &mii_nway_lp_ability_reg); 1434 if (ret_val) 1435 goto out; 1436 1437 /* 1438 * Two bits in the Auto Negotiation Advertisement Register 1439 * (Address 4) and two bits in the Auto Negotiation Base 1440 * Page Ability Register (Address 5) determine flow control --- 83 unchanged lines hidden (view full) --- 1524 DEBUGOUT("Flow Control = NONE.\r\n"); 1525 } 1526 1527 /* 1528 * Now we need to do one last check... If we auto- 1529 * negotiated to HALF DUPLEX, flow control should not be 1530 * enabled per IEEE 802.3 spec. 1531 */ |
1406 ret_val = e1000_get_speed_and_duplex(hw, &speed, &duplex); | 1532 ret_val = mac->ops.get_link_up_info(hw, &speed, &duplex); |
1407 if (ret_val) { 1408 DEBUGOUT("Error getting link speed and duplex\n"); 1409 goto out; 1410 } 1411 1412 if (duplex == HALF_DUPLEX) 1413 hw->fc.type = e1000_fc_none; 1414 --- 59 unchanged lines hidden (view full) --- 1474 * 1475 * Sets the speed and duplex to gigabit full duplex (the only possible option) 1476 * for fiber/serdes links. 1477 **/ 1478s32 e1000_get_speed_and_duplex_fiber_serdes_generic(struct e1000_hw *hw, 1479 u16 *speed, u16 *duplex) 1480{ 1481 DEBUGFUNC("e1000_get_speed_and_duplex_fiber_serdes_generic"); | 1533 if (ret_val) { 1534 DEBUGOUT("Error getting link speed and duplex\n"); 1535 goto out; 1536 } 1537 1538 if (duplex == HALF_DUPLEX) 1539 hw->fc.type = e1000_fc_none; 1540 --- 59 unchanged lines hidden (view full) --- 1600 * 1601 * Sets the speed and duplex to gigabit full duplex (the only possible option) 1602 * for fiber/serdes links. 1603 **/ 1604s32 e1000_get_speed_and_duplex_fiber_serdes_generic(struct e1000_hw *hw, 1605 u16 *speed, u16 *duplex) 1606{ 1607 DEBUGFUNC("e1000_get_speed_and_duplex_fiber_serdes_generic"); |
1482 UNREFERENCED_PARAMETER(hw); | |
1483 1484 *speed = SPEED_1000; 1485 *duplex = FULL_DUPLEX; 1486 1487 return E1000_SUCCESS; 1488} 1489 1490/** --- 109 unchanged lines hidden (view full) --- 1600 * LED configuration is not valid, set to a valid LED configuration. 1601 **/ 1602s32 e1000_valid_led_default_generic(struct e1000_hw *hw, u16 *data) 1603{ 1604 s32 ret_val; 1605 1606 DEBUGFUNC("e1000_valid_led_default_generic"); 1607 | 1608 1609 *speed = SPEED_1000; 1610 *duplex = FULL_DUPLEX; 1611 1612 return E1000_SUCCESS; 1613} 1614 1615/** --- 109 unchanged lines hidden (view full) --- 1725 * LED configuration is not valid, set to a valid LED configuration. 1726 **/ 1727s32 e1000_valid_led_default_generic(struct e1000_hw *hw, u16 *data) 1728{ 1729 s32 ret_val; 1730 1731 DEBUGFUNC("e1000_valid_led_default_generic"); 1732 |
1608 ret_val = e1000_read_nvm(hw, NVM_ID_LED_SETTINGS, 1, data); | 1733 ret_val = hw->nvm.ops.read(hw, NVM_ID_LED_SETTINGS, 1, data); |
1609 if (ret_val) { 1610 DEBUGOUT("NVM Read Error\n"); 1611 goto out; 1612 } 1613 1614 if (*data == ID_LED_RESERVED_0000 || *data == ID_LED_RESERVED_FFFF) 1615 *data = ID_LED_DEFAULT; 1616 --- 13 unchanged lines hidden (view full) --- 1630 const u32 ledctl_mask = 0x000000FF; 1631 const u32 ledctl_on = E1000_LEDCTL_MODE_LED_ON; 1632 const u32 ledctl_off = E1000_LEDCTL_MODE_LED_OFF; 1633 u16 data, i, temp; 1634 const u16 led_mask = 0x0F; 1635 1636 DEBUGFUNC("e1000_id_led_init_generic"); 1637 | 1734 if (ret_val) { 1735 DEBUGOUT("NVM Read Error\n"); 1736 goto out; 1737 } 1738 1739 if (*data == ID_LED_RESERVED_0000 || *data == ID_LED_RESERVED_FFFF) 1740 *data = ID_LED_DEFAULT; 1741 --- 13 unchanged lines hidden (view full) --- 1755 const u32 ledctl_mask = 0x000000FF; 1756 const u32 ledctl_on = E1000_LEDCTL_MODE_LED_ON; 1757 const u32 ledctl_off = E1000_LEDCTL_MODE_LED_OFF; 1758 u16 data, i, temp; 1759 const u16 led_mask = 0x0F; 1760 1761 DEBUGFUNC("e1000_id_led_init_generic"); 1762 |
1638 ret_val = hw->func.valid_led_default(hw, &data); | 1763 ret_val = hw->nvm.ops.valid_led_default(hw, &data); |
1639 if (ret_val) 1640 goto out; 1641 1642 mac->ledctl_default = E1000_READ_REG(hw, E1000_LEDCTL); 1643 mac->ledctl_mode1 = mac->ledctl_default; 1644 mac->ledctl_mode2 = mac->ledctl_default; 1645 1646 for (i = 0; i < 4; i++) { --- 47 unchanged lines hidden (view full) --- 1694 **/ 1695s32 e1000_setup_led_generic(struct e1000_hw *hw) 1696{ 1697 u32 ledctl; 1698 s32 ret_val = E1000_SUCCESS; 1699 1700 DEBUGFUNC("e1000_setup_led_generic"); 1701 | 1764 if (ret_val) 1765 goto out; 1766 1767 mac->ledctl_default = E1000_READ_REG(hw, E1000_LEDCTL); 1768 mac->ledctl_mode1 = mac->ledctl_default; 1769 mac->ledctl_mode2 = mac->ledctl_default; 1770 1771 for (i = 0; i < 4; i++) { --- 47 unchanged lines hidden (view full) --- 1819 **/ 1820s32 e1000_setup_led_generic(struct e1000_hw *hw) 1821{ 1822 u32 ledctl; 1823 s32 ret_val = E1000_SUCCESS; 1824 1825 DEBUGFUNC("e1000_setup_led_generic"); 1826 |
1702 if (hw->func.setup_led != e1000_setup_led_generic) { | 1827 if (hw->mac.ops.setup_led != e1000_setup_led_generic) { |
1703 ret_val = -E1000_ERR_CONFIG; 1704 goto out; 1705 } 1706 1707 if (hw->phy.media_type == e1000_media_type_fiber) { 1708 ledctl = E1000_READ_REG(hw, E1000_LEDCTL); 1709 hw->mac.ledctl_default = ledctl; 1710 /* Turn off LED0 */ --- 19 unchanged lines hidden (view full) --- 1730 * to the default value, saved from the EEPROM. 1731 **/ 1732s32 e1000_cleanup_led_generic(struct e1000_hw *hw) 1733{ 1734 s32 ret_val = E1000_SUCCESS; 1735 1736 DEBUGFUNC("e1000_cleanup_led_generic"); 1737 | 1828 ret_val = -E1000_ERR_CONFIG; 1829 goto out; 1830 } 1831 1832 if (hw->phy.media_type == e1000_media_type_fiber) { 1833 ledctl = E1000_READ_REG(hw, E1000_LEDCTL); 1834 hw->mac.ledctl_default = ledctl; 1835 /* Turn off LED0 */ --- 19 unchanged lines hidden (view full) --- 1855 * to the default value, saved from the EEPROM. 1856 **/ 1857s32 e1000_cleanup_led_generic(struct e1000_hw *hw) 1858{ 1859 s32 ret_val = E1000_SUCCESS; 1860 1861 DEBUGFUNC("e1000_cleanup_led_generic"); 1862 |
1738 if (hw->func.cleanup_led != e1000_cleanup_led_generic) { | 1863 if (hw->mac.ops.cleanup_led != e1000_cleanup_led_generic) { |
1739 ret_val = -E1000_ERR_CONFIG; 1740 goto out; 1741 } 1742 1743 E1000_WRITE_REG(hw, E1000_LEDCTL, hw->mac.ledctl_default); 1744 1745out: 1746 return ret_val; --- 301 unchanged lines hidden --- | 1864 ret_val = -E1000_ERR_CONFIG; 1865 goto out; 1866 } 1867 1868 E1000_WRITE_REG(hw, E1000_LEDCTL, hw->mac.ledctl_default); 1869 1870out: 1871 return ret_val; --- 301 unchanged lines hidden --- |