LCOV - code coverage report
Current view: top level - drivers/net/txgbe/base - txgbe_aml40.c (source / functions) Hit Total Coverage
Test: Code coverage Lines: 0 59 0.0 %
Date: 2025-12-01 19:08:10 Functions: 0 6 0.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 0 28 0.0 %

           Branch data     Line data    Source code
       1                 :            : /* SPDX-License-Identifier: BSD-3-Clause
       2                 :            :  * Copyright(c) 2015-2025 Beijing WangXun Technology Co., Ltd.
       3                 :            :  * Copyright(c) 2010-2017 Intel Corporation
       4                 :            :  */
       5                 :            : 
       6                 :            : #include "txgbe_type.h"
       7                 :            : #include "txgbe_mbx.h"
       8                 :            : #include "txgbe_phy.h"
       9                 :            : #include "txgbe_dcb.h"
      10                 :            : #include "txgbe_vf.h"
      11                 :            : #include "txgbe_eeprom.h"
      12                 :            : #include "txgbe_mng.h"
      13                 :            : #include "txgbe_hw.h"
      14                 :            : #include "txgbe_aml.h"
      15                 :            : #include "txgbe_aml40.h"
      16                 :            : 
      17                 :          0 : void txgbe_init_ops_aml40(struct txgbe_hw *hw)
      18                 :            : {
      19                 :            :         struct txgbe_mac_info *mac = &hw->mac;
      20                 :            :         struct txgbe_phy_info *phy = &hw->phy;
      21                 :            :         struct txgbe_mbx_info *mbx = &hw->mbx;
      22                 :            : 
      23                 :          0 :         txgbe_init_ops_generic(hw);
      24                 :            : 
      25                 :            :         /* PHY */
      26                 :          0 :         phy->get_media_type = txgbe_get_media_type_aml40;
      27                 :            : 
      28                 :            :         /* LINK */
      29                 :          0 :         mac->init_mac_link_ops = txgbe_init_mac_link_ops_aml40;
      30                 :          0 :         mac->get_link_capabilities = txgbe_get_link_capabilities_aml40;
      31                 :          0 :         mac->check_link = txgbe_check_mac_link_aml40;
      32                 :            : 
      33                 :            :         /* FW interaction */
      34                 :          0 :         mbx->host_interface_command = txgbe_host_interface_command_aml;
      35                 :          0 : }
      36                 :            : 
      37                 :          0 : s32 txgbe_check_mac_link_aml40(struct txgbe_hw *hw, u32 *speed,
      38                 :            :                                  bool *link_up, bool link_up_wait_to_complete)
      39                 :            : {
      40                 :            :         u32 links_reg, links_orig;
      41                 :            :         u32 i;
      42                 :            : 
      43                 :            :         /* clear the old state */
      44                 :            :         links_orig = rd32(hw, TXGBE_PORTSTAT);
      45                 :            : 
      46                 :            :         links_reg = rd32(hw, TXGBE_PORTSTAT);
      47                 :            : 
      48         [ #  # ]:          0 :         if (links_orig != links_reg) {
      49                 :          0 :                 DEBUGOUT("LINKS changed from %08X to %08X",
      50                 :            :                           links_orig, links_reg);
      51                 :            :         }
      52                 :            : 
      53         [ #  # ]:          0 :         if (link_up_wait_to_complete) {
      54         [ #  # ]:          0 :                 for (i = 0; i < hw->mac.max_link_up_time; i++) {
      55         [ #  # ]:          0 :                         if (!(links_reg & TXGBE_PORTSTAT_UP)) {
      56                 :          0 :                                 *link_up = false;
      57                 :            :                         } else {
      58                 :          0 :                                 *link_up = true;
      59                 :          0 :                                 break;
      60                 :            :                         }
      61                 :            :                         msec_delay(100);
      62                 :            :                         links_reg = rd32(hw, TXGBE_PORTSTAT);
      63                 :            :                 }
      64                 :            :         } else {
      65         [ #  # ]:          0 :                 if (links_reg & TXGBE_PORTSTAT_UP)
      66                 :          0 :                         *link_up = true;
      67                 :            :                 else
      68                 :          0 :                         *link_up = false;
      69                 :            :         }
      70                 :            : 
      71         [ #  # ]:          0 :         if (link_up) {
      72         [ #  # ]:          0 :                 if ((links_reg & TXGBE_CFG_PORT_ST_AML_LINK_40G) ==
      73                 :            :                         TXGBE_CFG_PORT_ST_AML_LINK_40G)
      74                 :          0 :                         *speed = TXGBE_LINK_SPEED_40GB_FULL;
      75                 :            :         } else {
      76                 :          0 :                 *speed = TXGBE_LINK_SPEED_UNKNOWN;
      77                 :            :         }
      78                 :            : 
      79                 :          0 :         return 0;
      80                 :            : }
      81                 :            : 
      82                 :          0 : s32 txgbe_get_link_capabilities_aml40(struct txgbe_hw *hw,
      83                 :            :                                       u32 *speed,
      84                 :            :                                       bool *autoneg)
      85                 :            : {
      86         [ #  # ]:          0 :         if (hw->phy.sfp_type == txgbe_qsfp_type_40g_cu_core0 ||
      87                 :            :             hw->phy.sfp_type == txgbe_qsfp_type_40g_cu_core1) {
      88                 :          0 :                 *speed = TXGBE_LINK_SPEED_40GB_FULL;
      89                 :          0 :                 *autoneg = false;
      90                 :            :         } else {
      91                 :            :                 /*
      92                 :            :                  * Temporary workaround: set speed to 40G even if sfp not present
      93                 :            :                  * to avoid TXGBE_ERR_LINK_SETUP returned by setup_mac_link, but
      94                 :            :                  * a more reasonable solution is don't execute setup_mac_link when
      95                 :            :                  * sfp module not present.
      96                 :            :                  */
      97                 :          0 :                 *speed = TXGBE_LINK_SPEED_40GB_FULL;
      98                 :          0 :                 *autoneg = true;
      99                 :            :         }
     100                 :            : 
     101                 :          0 :         return 0;
     102                 :            : }
     103                 :            : 
     104                 :          0 : u32 txgbe_get_media_type_aml40(struct txgbe_hw *hw)
     105                 :            : {
     106                 :            :         UNREFERENCED_PARAMETER(hw);
     107                 :          0 :         return txgbe_media_type_fiber_qsfp;
     108                 :            : }
     109                 :            : 
     110                 :          0 : s32 txgbe_setup_mac_link_aml40(struct txgbe_hw *hw,
     111                 :            :                                u32 speed,
     112                 :            :                                bool autoneg_wait_to_complete)
     113                 :            : {
     114                 :          0 :         bool autoneg = false;
     115                 :            :         s32 status = 0;
     116                 :          0 :         u32 link_speed = TXGBE_LINK_SPEED_UNKNOWN;
     117                 :          0 :         bool link_up = false;
     118                 :          0 :         u32 link_capabilities = TXGBE_LINK_SPEED_UNKNOWN;
     119                 :            : 
     120         [ #  # ]:          0 :         if (hw->phy.sfp_type == txgbe_sfp_type_not_present) {
     121                 :          0 :                 DEBUGOUT("SFP not detected, skip setup mac link");
     122                 :          0 :                 return 0;
     123                 :            :         }
     124                 :            : 
     125                 :            :         /* Check to see if speed passed in is supported. */
     126                 :          0 :         status = hw->mac.get_link_capabilities(hw,
     127                 :            :                         &link_capabilities, &autoneg);
     128         [ #  # ]:          0 :         if (status)
     129                 :            :                 return status;
     130                 :            : 
     131                 :          0 :         speed &= link_capabilities;
     132         [ #  # ]:          0 :         if (speed == TXGBE_LINK_SPEED_UNKNOWN)
     133                 :            :                 return TXGBE_ERR_LINK_SETUP;
     134                 :            : 
     135                 :          0 :         status = hw->mac.check_link(hw, &link_speed, &link_up,
     136                 :            :                                     autoneg_wait_to_complete);
     137                 :            : 
     138   [ #  #  #  # ]:          0 :         if (link_speed == speed && link_up)
     139                 :            :                 return status;
     140                 :            : 
     141         [ #  # ]:          0 :         if (speed & TXGBE_LINK_SPEED_40GB_FULL)
     142                 :            :                 speed = 0x20;
     143                 :            : 
     144                 :          0 :         status = hw->phy.set_link_hostif(hw, (u8)speed, autoneg, true);
     145                 :            : 
     146                 :          0 :         txgbe_wait_for_link_up_aml(hw, speed);
     147                 :            : 
     148                 :          0 :         return status;
     149                 :            : }
     150                 :            : 
     151                 :          0 : void txgbe_init_mac_link_ops_aml40(struct txgbe_hw *hw)
     152                 :            : {
     153                 :            :         struct txgbe_mac_info *mac = &hw->mac;
     154                 :            : 
     155                 :          0 :         mac->disable_tx_laser =
     156                 :            :                 txgbe_disable_tx_laser_multispeed_fiber;
     157                 :          0 :         mac->enable_tx_laser =
     158                 :            :                 txgbe_enable_tx_laser_multispeed_fiber;
     159                 :          0 :         mac->flap_tx_laser =
     160                 :            :                 txgbe_flap_tx_laser_multispeed_fiber;
     161                 :            : 
     162                 :          0 :         mac->setup_link = txgbe_setup_mac_link_aml40;
     163                 :          0 :         mac->set_rate_select_speed = txgbe_set_hard_rate_select_speed;
     164                 :          0 : }

Generated by: LCOV version 1.14