MCPcopy Create free account
hub / github.com/F-Stack/f-stack / eth_em_link_update

Function eth_em_link_update

dpdk/drivers/net/e1000/em_ethdev.c:1155–1218  ·  view source on GitHub ↗

return 0 means link status changed, -1 means not changed */

Source from the content-addressed store, hash-verified

1153
1154/* return 0 means link status changed, -1 means not changed */
1155static int
1156eth_em_link_update(struct rte_eth_dev *dev, int wait_to_complete)
1157{
1158 struct e1000_hw *hw =
1159 E1000_DEV_PRIVATE_TO_HW(dev->data->dev_private);
1160 struct rte_eth_link link;
1161 int link_up, count;
1162
1163 if (rte_eal_process_type() != RTE_PROC_PRIMARY)
1164 return -1;
1165
1166 link_up = 0;
1167 hw->mac.get_link_status = 1;
1168
1169 /* possible wait-to-complete in up to 9 seconds */
1170 for (count = 0; count < EM_LINK_UPDATE_CHECK_TIMEOUT; count ++) {
1171 /* Read the real link status */
1172 switch (hw->phy.media_type) {
1173 case e1000_media_type_copper:
1174 /* Do the work to read phy */
1175 e1000_check_for_link(hw);
1176 link_up = !hw->mac.get_link_status;
1177 break;
1178
1179 case e1000_media_type_fiber:
1180 e1000_check_for_link(hw);
1181 link_up = (E1000_READ_REG(hw, E1000_STATUS) &
1182 E1000_STATUS_LU);
1183 break;
1184
1185 case e1000_media_type_internal_serdes:
1186 e1000_check_for_link(hw);
1187 link_up = hw->mac.serdes_has_link;
1188 break;
1189
1190 default:
1191 break;
1192 }
1193 if (link_up || wait_to_complete == 0)
1194 break;
1195 rte_delay_ms(EM_LINK_UPDATE_CHECK_INTERVAL);
1196 }
1197 memset(&link, 0, sizeof(link));
1198
1199 /* Now we check if a transition has happened */
1200 if (link_up) {
1201 uint16_t duplex, speed;
1202 hw->mac.ops.get_link_up_info(hw, &speed, &duplex);
1203 link.link_duplex = (duplex == FULL_DUPLEX) ?
1204 RTE_ETH_LINK_FULL_DUPLEX :
1205 RTE_ETH_LINK_HALF_DUPLEX;
1206 link.link_speed = speed;
1207 link.link_status = RTE_ETH_LINK_UP;
1208 link.link_autoneg = !(dev->data->dev_conf.link_speeds &
1209 RTE_ETH_LINK_SPEED_FIXED);
1210 } else {
1211 link.link_speed = RTE_ETH_SPEED_NUM_NONE;
1212 link.link_duplex = RTE_ETH_LINK_HALF_DUPLEX;

Callers 2

eth_em_startFunction · 0.85
eth_em_interrupt_actionFunction · 0.85

Calls 5

rte_eal_process_typeFunction · 0.85
e1000_check_for_linkFunction · 0.85
rte_delay_msFunction · 0.85
memsetFunction · 0.85
rte_eth_linkstatus_setFunction · 0.85

Tested by

no test coverage detected