?? enable_gmacs.c
字號:
*/ /* Write out Port 0 table values to NET 0. */ for (i = 0; i < port0Table.valid_count; i++) { status = writeMACAddress(port0Table.values[i], HFTC_GMAC_NET0_CONTROL, i); if (status != HFTC_STATUS_OK) { printf("Problem in setting MAC %d on NET0\n", i); break; } } /* There is no NET1 on an X300. */ if ((isX300 == HFTC_TRUE) && (port1Table.valid_count > 0)) { printf("Error in %s. " "There is no Net1 to configure yet values were found.\n", configparamsFile); status = HFTC_INVALID_OPERATION; break; } /* Write out Port 1 table values to NET 1. */ for (i = 0; i < port1Table.valid_count; i++) { status = writeMACAddress(port1Table.values[i], HFTC_GMAC_NET1_CONTROL, i); if (status != HFTC_STATUS_OK) { printf("Problem was in setting MAC %d on NET1\n", i); break; } } /* If debug is on, read back all MAC address filter values */ if (DL_DEBUG) { printf("Net0 values:\n"); for (i = 0; i < port0Table.valid_count; i++) { readMACFilterValue(HFTC_GMAC_NET0_CONTROL, i); } printf("Net1 values:\n"); for (i = 0; i < port1Table.valid_count; i++) { readMACFilterValue(HFTC_GMAC_NET1_CONTROL, i); } } } while (HFTC_FALSE); return status;} /* End setupMACFiltering *//*----------------------------------------------------------------------------* * enable_gmacs *----------------------------------------------------------------------------* * @ingroup startup * @brief Enable gmacs. * * This function to set up the GMAC registers. * * @param param_p RO: Parameters pointer * * @par Externals: * None. * * @return * HFTC_STATUS_OK * * @par Errors: * None. * * @par Assumptions: * Assumes unit table has been set up. * *----------------------------------------------------------------------------*/HFTC_Status_t enable_gmacs(download_param_t *param_p){ HFTC_Status_t status = HFTC_STATUS_OK; HFTC_Unit_t unit = 0; HFTC_Reqid_t reqid = 0; /* Arbitrary */ HFTC_Cbp_t cbp = NULL; uint32_t retries = 0; HFTC_hardware_status_t hardware_status; uint32_t i; uint32_t configTableSize = GMAC_CONFIG_TABLE_SIZE; uint32_t configValue; HFTC_Boolean_t isX300 = HFTC_FALSE; HFTC_Boolean_t isX4X0 = HFTC_FALSE; do { /* Try reading the hardware status. */ param_p->processorType = HFTC_DPU; hardware_status.statusVersion = HFTC_HARDWARE_STATUS_VERSION_2; status = read_status(unit, param_p, RETRANSMIT_RETRY_SECONDS, &hardware_status); if (status == HFTC_STATUS_OK) { /* If this is a 4300 or 8300 then there is only 1 set of GMACs to enable, so the table size is smaller than the default. */ if ((hardware_status.deviceId == 0x4300) || (hardware_status.deviceId == 0x8300)) { isX300 = HFTC_TRUE; configTableSize = GMAC_CONFIG_TABLE_SIZE_x300; } if ((hardware_status.deviceId & 0x0F00) == 0x0400) { isX4X0 = HFTC_TRUE; } if (DL_DEBUG) { printf("Read Hardware Status read. Device ID = %04x\n", hardware_status.deviceId); } } /* -------------------- Configure GMACS -------------------- */ /* The following code sets up the MAC addresses needed if we are not in promiscuous mode. */ if (param_p->promiscuous == HFTC_FALSE) { /* Read the configparams file and set up MAC filtering */ status = setupMACFiltering(param_p->configparams, isX300); if (status != HFTC_STATUS_OK) { printf("Problem with config file %s - status = %s (%d).\n", param_p->configparams, HFTC_Status_t_text(status), status); break; } } /* The following loop is used to configure and enable the GMACs. */ for (i = 0; i < configTableSize; i++) { /* First read in the current value. */ retries = 0; do { status = HFTC_ReadGMACRegister(unit, cbp, reqid, gmac_config_table[i].gmac, gmac_config_table[i].index, &configValue); RESEND_TIMEOUTS(status, retries); } while (status == HFTC_RESEND); if (status != HFTC_STATUS_OK) { printf("Read from GMAC %s (%d) index %s (%d) failed.\n", HFTC_GMACReg_t_text(gmac_config_table[i].gmac), gmac_config_table[i].gmac, HFTC_GMACIndex_t_text(gmac_config_table[i].index), gmac_config_table[i].index); printf(" Error from HFTC_ReadGMACRegister, status = %s (%d)\n", HFTC_Status_t_text(status), status); break; } else if (DL_DEBUG) { printf("Read from GMAC %s (%d) index %s (%d) success read %08x.\n", HFTC_GMACReg_t_text(gmac_config_table[i].gmac), gmac_config_table[i].gmac, HFTC_GMACIndex_t_text(gmac_config_table[i].index), gmac_config_table[i].index, configValue); } /* If this is a filter register, mask out the unwanted bits and or in the wanted bits. These depend on whether or not we are using promiscuous mode or not, and if we are on a 44x0/84x0 which needs multicast addresses for neighbor discovery of IPv6 set on the network side and promiscuous mode on the host side. The 44x0/84x0 has no pause frame issues. */ if (gmac_config_table[i].index == HFTC_GMAC_SYN_MAC_FRAME_FILTER) { configValue &= ~FILTER_MASK; if ((param_p->promiscuous == HFTC_TRUE) || ((isX4X0 == HFTC_TRUE) && ((gmac_config_table[i].gmac == HFTC_GMAC_HOST0_CONTROL) || (gmac_config_table[i].gmac == HFTC_GMAC_HOST1_CONTROL)))) { configValue |= FILTER_PROMISC; } else { configValue |= gmac_config_table[i].config; if (isX4X0 == HFTC_TRUE) { configValue |= FILTER_ALLOW_MULTICAST; } } } /* For control filter registers, just or in the needed bits. */ else if (gmac_config_table[i].index == HFTC_GMAC_SYN_MAC_CONFIG) { configValue |= gmac_config_table[i].config; } /* For all other registers, use the set value. */ else { configValue = gmac_config_table[i].config; } /* Then write out the new value. */ retries = 0; do { status = HFTC_WriteGMACRegister(unit, cbp, reqid, gmac_config_table[i].gmac, gmac_config_table[i].index, &configValue); RESEND_TIMEOUTS(status, retries); } while (status == HFTC_RESEND); if (status != HFTC_STATUS_OK) { printf("Write to GMAC %s (%d) index %s (%d) failed.\n", HFTC_GMACReg_t_text(gmac_config_table[i].gmac), gmac_config_table[i].gmac, HFTC_GMACIndex_t_text(gmac_config_table[i].index), gmac_config_table[i].index); printf(" Error from HFTC_WriteGMACRegister, status = %s (%d)\n", HFTC_Status_t_text(status), status); break; } else if (DL_DEBUG) { printf("Write to GMAC %s (%d) index %s (%d) success wrote %08x.\n", HFTC_GMACReg_t_text(gmac_config_table[i].gmac), gmac_config_table[i].gmac, HFTC_GMACIndex_t_text(gmac_config_table[i].index), gmac_config_table[i].index, configValue); } } /* end for (i = 0; i < configTableSize; i++) */ } while (HFTC_FALSE); return(status);} /* End enable_gmacs *//* End enable_gmacs.c *//*----------------------------------------------------------------------------*REV # DATE BY REVISION DESCRIPTION----- -------- ----- ------------------------------------------------------0001 07/06/05 msz Created.0002 05/19/06 msz Added MAC Filtering.0003 06/05/06 rlh Changed to use new porting layer and app_utils includes instead of test_*.h.0004 08/08/06 msz Use HFTC_ConfigParameters_t rather than esc_parameters_t; use HFTC_ReadConfigFile rather than HFTC_UT_ReadESCConfigFile. These changes were needed from merging in above MAC filtering changes.0005 08/22/06 msz Support of MAC filtering for Viper, where there are more MAC addresses and a port mapping table.0006 08/29/06 msz Minor changes from mini code review done by Rich. Setting up GMAC to allow multicast through on x4x0 (Viper) as it is needed for neighbor discovery in IPv6, and Viper should not have pause frame problem.0007 09/25/06 rlh Changed public names to be more general & consistent w/ existing naming conventions (HFTC_esc_parameter* -> HFTC_ConfigParameter*).0008 10/09/06 rlh * Added DPU port MTU params. Since the port MTU values are a DPU parameter, generalized the config file to not just handle ESC parameters. * Renamed config/escconfig -> config/configparams and changed all related definitions to be consistent w/ new naming scheme: HFTC_ReadESCConfigFile -> HFTC_ReadConfigFile ESC_PARAMETER -> CONFIG_PARAMETER, esc_parameters -> config_params, etc.0009 10/19/06 msz Fix for Bug-1856 fixing bad status value when only H1 mac addresses are configured.0010 02/26/07 msz Fix for Bug-2279, On 44x0/84x0 use promiscuous mode on H0, H1.0011 03/20/07 msz Added RESEND_TIMEOUTS so we will resend on ft-api (ft-min) timeouts. This should make download over the MII more reliable. (Bug 2307)0012 03/27/07 msz Variable amount of time on read_status to allow more time for POST when running long-sdram-test. (Bug-2317)*-----------------------------------------------------------------------------*/
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -