| 2561 | } |
| 2562 | |
| 2563 | static int |
| 2564 | sfc_fec_capa_check(struct rte_eth_dev *dev, uint32_t fec_capa, |
| 2565 | uint32_t supported_caps) |
| 2566 | { |
| 2567 | struct rte_eth_fec_capa *speed_fec_capa; |
| 2568 | struct rte_eth_link current_link; |
| 2569 | bool is_supported = false; |
| 2570 | unsigned int num_entries; |
| 2571 | bool auto_fec = false; |
| 2572 | unsigned int i; |
| 2573 | |
| 2574 | struct sfc_adapter *sa = sfc_adapter_by_eth_dev(dev); |
| 2575 | |
| 2576 | if (sa->state != SFC_ETHDEV_STARTED) |
| 2577 | return 0; |
| 2578 | |
| 2579 | if (fec_capa & RTE_ETH_FEC_MODE_TO_CAPA(RTE_ETH_FEC_AUTO)) { |
| 2580 | auto_fec = true; |
| 2581 | fec_capa &= ~RTE_ETH_FEC_MODE_TO_CAPA(RTE_ETH_FEC_AUTO); |
| 2582 | } |
| 2583 | |
| 2584 | /* |
| 2585 | * If only the AUTO bit is set, the decision on which FEC |
| 2586 | * mode to use will be made by HW/FW or driver. |
| 2587 | */ |
| 2588 | if (auto_fec && fec_capa == 0) |
| 2589 | return 0; |
| 2590 | |
| 2591 | sfc_dev_get_rte_link(dev, 1, ¤t_link); |
| 2592 | |
| 2593 | num_entries = sfc_fec_get_capa_speed_to_fec(supported_caps, NULL); |
| 2594 | if (num_entries == 0) |
| 2595 | return ENOTSUP; |
| 2596 | |
| 2597 | speed_fec_capa = rte_calloc("fec_capa", num_entries, |
| 2598 | sizeof(*speed_fec_capa), 0); |
| 2599 | num_entries = sfc_fec_get_capa_speed_to_fec(supported_caps, |
| 2600 | speed_fec_capa); |
| 2601 | |
| 2602 | for (i = 0; i < num_entries; i++) { |
| 2603 | if (speed_fec_capa[i].speed == current_link.link_speed) { |
| 2604 | if ((fec_capa & speed_fec_capa[i].capa) != 0) |
| 2605 | is_supported = true; |
| 2606 | |
| 2607 | break; |
| 2608 | } |
| 2609 | } |
| 2610 | |
| 2611 | rte_free(speed_fec_capa); |
| 2612 | |
| 2613 | if (is_supported) |
| 2614 | return 0; |
| 2615 | |
| 2616 | return ENOTSUP; |
| 2617 | } |
| 2618 | |
| 2619 | static int |
| 2620 | sfc_fec_capa_to_efx(uint32_t supported_caps, uint32_t fec_capa, |
no test coverage detected