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

Function i40e_phy_conf_link

dpdk/drivers/net/i40e/i40e_ethdev.c:2200–2289  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2198}
2199
2200static int
2201i40e_phy_conf_link(struct i40e_hw *hw,
2202 uint8_t abilities,
2203 uint8_t force_speed,
2204 bool is_up)
2205{
2206 enum i40e_status_code status;
2207 struct i40e_aq_get_phy_abilities_resp phy_ab;
2208 struct i40e_aq_set_phy_config phy_conf;
2209 enum i40e_aq_phy_type cnt;
2210 uint8_t avail_speed;
2211 uint32_t phy_type_mask = 0;
2212
2213 const uint8_t mask = I40E_AQ_PHY_FLAG_PAUSE_TX |
2214 I40E_AQ_PHY_FLAG_PAUSE_RX |
2215 I40E_AQ_PHY_FLAG_PAUSE_RX |
2216 I40E_AQ_PHY_FLAG_LOW_POWER;
2217 int ret = -ENOTSUP;
2218
2219 /* To get phy capabilities of available speeds. */
2220 status = i40e_aq_get_phy_capabilities(hw, false, true, &phy_ab,
2221 NULL);
2222 if (status) {
2223 PMD_DRV_LOG(ERR, "Failed to get PHY capabilities: %d",
2224 status);
2225 return ret;
2226 }
2227 avail_speed = phy_ab.link_speed;
2228
2229 /* To get the current phy config. */
2230 status = i40e_aq_get_phy_capabilities(hw, false, false, &phy_ab,
2231 NULL);
2232 if (status) {
2233 PMD_DRV_LOG(ERR, "Failed to get the current PHY config: %d",
2234 status);
2235 return ret;
2236 }
2237
2238 /* If link needs to go up and it is in autoneg mode the speed is OK,
2239 * no need to set up again.
2240 */
2241 if (is_up && phy_ab.phy_type != 0 &&
2242 abilities & I40E_AQ_PHY_AN_ENABLED &&
2243 phy_ab.link_speed != 0)
2244 return I40E_SUCCESS;
2245
2246 memset(&phy_conf, 0, sizeof(phy_conf));
2247
2248 /* bits 0-2 use the values from get_phy_abilities_resp */
2249 abilities &= ~mask;
2250 abilities |= phy_ab.abilities & mask;
2251
2252 phy_conf.abilities = abilities;
2253
2254 /* If link needs to go up, but the force speed is not supported,
2255 * Warn users and config the default available speeds.
2256 */
2257 if (is_up && !(force_speed & avail_speed)) {

Callers 2

i40e_apply_link_speedFunction · 0.85
i40e_dev_set_link_downFunction · 0.85

Calls 3

memsetFunction · 0.85

Tested by

no test coverage detected