LCOV - code coverage report
Current view: top level - drivers/net/nfp/nfpcore - nfp_nsp.h (source / functions) Hit Total Coverage
Test: Code coverage Lines: 0 1 0.0 %
Date: 2024-01-22 15:35:40 Functions: 0 0 -
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 0 0 -

           Branch data     Line data    Source code
       1                 :            : /* SPDX-License-Identifier: BSD-3-Clause
       2                 :            :  * Copyright(c) 2018 Netronome Systems, Inc.
       3                 :            :  * All rights reserved.
       4                 :            :  */
       5                 :            : 
       6                 :            : #ifndef __NSP_NSP_H__
       7                 :            : #define __NSP_NSP_H__
       8                 :            : 
       9                 :            : #include "nfp_cpp.h"
      10                 :            : 
      11                 :            : struct nfp_nsp;
      12                 :            : 
      13                 :            : struct nfp_nsp *nfp_nsp_open(struct nfp_cpp *cpp);
      14                 :            : void nfp_nsp_close(struct nfp_nsp *state);
      15                 :            : uint16_t nfp_nsp_get_abi_ver_major(struct nfp_nsp *state);
      16                 :            : uint16_t nfp_nsp_get_abi_ver_minor(struct nfp_nsp *state);
      17                 :            : int nfp_nsp_wait(struct nfp_nsp *state);
      18                 :            : int nfp_nsp_device_soft_reset(struct nfp_nsp *state);
      19                 :            : int nfp_nsp_load_fw(struct nfp_nsp *state, void *buf, size_t size);
      20                 :            : int nfp_nsp_mac_reinit(struct nfp_nsp *state);
      21                 :            : int nfp_nsp_read_identify(struct nfp_nsp *state, void *buf, size_t size);
      22                 :            : int nfp_nsp_read_sensors(struct nfp_nsp *state, uint32_t sensor_mask,
      23                 :            :                 void *buf, size_t size);
      24                 :            : 
      25                 :            : static inline bool
      26                 :            : nfp_nsp_has_mac_reinit(struct nfp_nsp *state)
      27                 :            : {
      28                 :            :         return nfp_nsp_get_abi_ver_minor(state) > 20;
      29                 :            : }
      30                 :            : 
      31                 :            : static inline bool
      32                 :            : nfp_nsp_has_stored_fw_load(struct nfp_nsp *state)
      33                 :            : {
      34                 :          0 :         return nfp_nsp_get_abi_ver_minor(state) > 23;
      35                 :            : }
      36                 :            : 
      37                 :            : static inline bool
      38                 :            : nfp_nsp_has_hwinfo_lookup(struct nfp_nsp *state)
      39                 :            : {
      40                 :            :         return nfp_nsp_get_abi_ver_minor(state) > 24;
      41                 :            : }
      42                 :            : 
      43                 :            : static inline bool
      44                 :            : nfp_nsp_has_hwinfo_set(struct nfp_nsp *state)
      45                 :            : {
      46                 :            :         return nfp_nsp_get_abi_ver_minor(state) > 25;
      47                 :            : }
      48                 :            : 
      49                 :            : static inline bool
      50                 :            : nfp_nsp_has_fw_loaded(struct nfp_nsp *state)
      51                 :            : {
      52                 :            :         return nfp_nsp_get_abi_ver_minor(state) > 25;
      53                 :            : }
      54                 :            : 
      55                 :            : static inline bool
      56                 :            : nfp_nsp_has_versions(struct nfp_nsp *state)
      57                 :            : {
      58                 :            :         return nfp_nsp_get_abi_ver_minor(state) > 27;
      59                 :            : }
      60                 :            : 
      61                 :            : static inline bool
      62                 :            : nfp_nsp_has_read_module_eeprom(struct nfp_nsp *state)
      63                 :            : {
      64                 :            :         return nfp_nsp_get_abi_ver_minor(state) > 28;
      65                 :            : }
      66                 :            : 
      67                 :            : static inline bool
      68                 :            : nfp_nsp_has_read_media(struct nfp_nsp *state)
      69                 :            : {
      70                 :            :         return nfp_nsp_get_abi_ver_minor(state) > 33;
      71                 :            : }
      72                 :            : 
      73                 :            : enum nfp_eth_interface {
      74                 :            :         NFP_INTERFACE_NONE      = 0,
      75                 :            :         NFP_INTERFACE_SFP       = 1,
      76                 :            :         NFP_INTERFACE_SFPP      = 10,
      77                 :            :         NFP_INTERFACE_SFP28     = 28,
      78                 :            :         NFP_INTERFACE_QSFP      = 40,
      79                 :            :         NFP_INTERFACE_RJ45      = 45,
      80                 :            :         NFP_INTERFACE_CXP       = 100,
      81                 :            :         NFP_INTERFACE_QSFP28    = 112,
      82                 :            : };
      83                 :            : 
      84                 :            : enum nfp_eth_media {
      85                 :            :         NFP_MEDIA_DAC_PASSIVE = 0,
      86                 :            :         NFP_MEDIA_DAC_ACTIVE,
      87                 :            :         NFP_MEDIA_FIBRE,
      88                 :            : };
      89                 :            : 
      90                 :            : enum nfp_eth_aneg {
      91                 :            :         NFP_ANEG_AUTO = 0,
      92                 :            :         NFP_ANEG_SEARCH,
      93                 :            :         NFP_ANEG_25G_CONSORTIUM,
      94                 :            :         NFP_ANEG_25G_IEEE,
      95                 :            :         NFP_ANEG_DISABLED,
      96                 :            : };
      97                 :            : 
      98                 :            : enum nfp_eth_fec {
      99                 :            :         NFP_FEC_AUTO_BIT = 0,
     100                 :            :         NFP_FEC_BASER_BIT,
     101                 :            :         NFP_FEC_REED_SOLOMON_BIT,
     102                 :            :         NFP_FEC_DISABLED_BIT,
     103                 :            : };
     104                 :            : 
     105                 :            : #define NFP_FEC_AUTO            RTE_BIT32(NFP_FEC_AUTO_BIT)
     106                 :            : #define NFP_FEC_BASER           RTE_BIT32(NFP_FEC_BASER_BIT)
     107                 :            : #define NFP_FEC_REED_SOLOMON    RTE_BIT32(NFP_FEC_REED_SOLOMON_BIT)
     108                 :            : #define NFP_FEC_DISABLED        RTE_BIT32(NFP_FEC_DISABLED_BIT)
     109                 :            : 
     110                 :            : /* ETH table information */
     111                 :            : struct nfp_eth_table {
     112                 :            :         uint32_t count;     /**< Number of table entries */
     113                 :            :         uint32_t max_index; /**< Max of @index fields of all @ports */
     114                 :            :         struct nfp_eth_table_port {
     115                 :            :                 /** Port index according to legacy ethX numbering */
     116                 :            :                 uint32_t eth_index;
     117                 :            :                 uint32_t index;  /**< Chip-wide first channel index */
     118                 :            :                 uint32_t nbi;    /**< NBI index */
     119                 :            :                 uint32_t base;   /**< First channel index (within NBI) */
     120                 :            :                 uint32_t lanes;  /**< Number of channels */
     121                 :            :                 uint32_t speed;  /**< Interface speed (in Mbps) */
     122                 :            : 
     123                 :            :                 uint32_t interface;  /**< Interface (module) plugged in */
     124                 :            :                 enum nfp_eth_media media; /**< Media type of the @interface */
     125                 :            : 
     126                 :            :                 enum nfp_eth_fec fec;     /**< Forward Error Correction mode */
     127                 :            :                 enum nfp_eth_fec act_fec; /**< Active Forward Error Correction mode */
     128                 :            :                 enum nfp_eth_aneg aneg;   /**< Auto negotiation mode */
     129                 :            : 
     130                 :            :                 struct rte_ether_addr mac_addr;  /**< Interface MAC address */
     131                 :            : 
     132                 :            :                 uint8_t label_port;    /**< Port id */
     133                 :            :                 /** Id of interface within port (for split ports) */
     134                 :            :                 uint8_t label_subport;
     135                 :            : 
     136                 :            :                 bool enabled;     /**< Enable port */
     137                 :            :                 bool tx_enabled;  /**< Enable TX */
     138                 :            :                 bool rx_enabled;  /**< Enable RX */
     139                 :            :                 bool supp_aneg;   /**< Support auto negotiation */
     140                 :            : 
     141                 :            :                 bool override_changed;  /**< Media reconfig pending */
     142                 :            :                 bool rx_pause_enabled;  /**< Switch of RX pause frame */
     143                 :            :                 bool tx_pause_enabled;  /**< Switch of TX pause frame */
     144                 :            : 
     145                 :            :                 uint8_t port_type;    /**< One of %PORT_* */
     146                 :            :                 /** Sum of lanes of all subports of this port */
     147                 :            :                 uint32_t port_lanes;
     148                 :            : 
     149                 :            :                 bool is_split;   /**< Split port */
     150                 :            : 
     151                 :            :                 uint32_t fec_modes_supported;  /**< Bitmap of FEC modes supported */
     152                 :            :         } ports[]; /**< Table of ports */
     153                 :            : };
     154                 :            : 
     155                 :            : struct nfp_eth_table *nfp_eth_read_ports(struct nfp_cpp *cpp);
     156                 :            : 
     157                 :            : int nfp_eth_set_mod_enable(struct nfp_cpp *cpp, uint32_t idx, bool enable);
     158                 :            : int nfp_eth_set_configured(struct nfp_cpp *cpp, uint32_t idx, bool configured);
     159                 :            : int nfp_eth_set_fec(struct nfp_cpp *cpp, uint32_t idx, enum nfp_eth_fec mode);
     160                 :            : 
     161                 :            : int nfp_nsp_read_eth_table(struct nfp_nsp *state, void *buf, size_t size);
     162                 :            : int nfp_nsp_write_eth_table(struct nfp_nsp *state, const void *buf,
     163                 :            :                 size_t size);
     164                 :            : void nfp_nsp_config_set_state(struct nfp_nsp *state, void *entries,
     165                 :            :                 uint32_t idx);
     166                 :            : void nfp_nsp_config_clear_state(struct nfp_nsp *state);
     167                 :            : void nfp_nsp_config_set_modified(struct nfp_nsp *state, bool modified);
     168                 :            : void *nfp_nsp_config_entries(struct nfp_nsp *state);
     169                 :            : struct nfp_cpp *nfp_nsp_cpp(struct nfp_nsp *state);
     170                 :            : bool nfp_nsp_config_modified(struct nfp_nsp *state);
     171                 :            : uint32_t nfp_nsp_config_idx(struct nfp_nsp *state);
     172                 :            : 
     173                 :            : static inline bool
     174                 :            : nfp_eth_can_support_fec(struct nfp_eth_table_port *eth_port)
     175                 :            : {
     176                 :            :         return eth_port->fec_modes_supported != 0;
     177                 :            : }
     178                 :            : 
     179                 :            : static inline uint32_t
     180                 :            : nfp_eth_supported_fec_modes(struct nfp_eth_table_port *eth_port)
     181                 :            : {
     182                 :            :         return eth_port->fec_modes_supported;
     183                 :            : }
     184                 :            : 
     185                 :            : struct nfp_nsp *nfp_eth_config_start(struct nfp_cpp *cpp, uint32_t idx);
     186                 :            : int nfp_eth_config_commit_end(struct nfp_nsp *nsp);
     187                 :            : void nfp_eth_config_cleanup_end(struct nfp_nsp *nsp);
     188                 :            : 
     189                 :            : int nfp_eth_set_aneg(struct nfp_nsp *nsp, enum nfp_eth_aneg mode);
     190                 :            : int nfp_eth_set_speed(struct nfp_nsp *nsp, uint32_t speed);
     191                 :            : int nfp_eth_set_split(struct nfp_nsp *nsp, uint32_t lanes);
     192                 :            : int nfp_eth_set_tx_pause(struct nfp_nsp *nsp, bool tx_pause);
     193                 :            : int nfp_eth_set_rx_pause(struct nfp_nsp *nsp, bool rx_pause);
     194                 :            : 
     195                 :            : /* NSP static information */
     196                 :            : struct nfp_nsp_identify {
     197                 :            :         char version[40];      /**< Opaque version string */
     198                 :            :         uint8_t flags;         /**< Version flags */
     199                 :            :         uint8_t br_primary;    /**< Branch id of primary bootloader */
     200                 :            :         uint8_t br_secondary;  /**< Branch id of secondary bootloader */
     201                 :            :         uint8_t br_nsp;        /**< Branch id of NSP */
     202                 :            :         uint16_t primary;      /**< Version of primary bootloader */
     203                 :            :         uint16_t secondary;    /**< Version id of secondary bootloader */
     204                 :            :         uint16_t nsp;          /**< Version id of NSP */
     205                 :            :         uint64_t sensor_mask;  /**< Mask of present sensors available on NIC */
     206                 :            : };
     207                 :            : 
     208                 :            : struct nfp_nsp_identify *nfp_nsp_identify(struct nfp_nsp *nsp);
     209                 :            : 
     210                 :            : enum nfp_nsp_sensor_id {
     211                 :            :         NFP_SENSOR_CHIP_TEMPERATURE,
     212                 :            :         NFP_SENSOR_ASSEMBLY_POWER,
     213                 :            :         NFP_SENSOR_ASSEMBLY_12V_POWER,
     214                 :            :         NFP_SENSOR_ASSEMBLY_3V3_POWER,
     215                 :            : };
     216                 :            : 
     217                 :            : int nfp_hwmon_read_sensor(struct nfp_cpp *cpp, enum nfp_nsp_sensor_id id,
     218                 :            :                 uint32_t *val);
     219                 :            : bool nfp_nsp_fw_loaded(struct nfp_nsp *state);
     220                 :            : 
     221                 :            : #endif /* __NSP_NSP_H__ */

Generated by: LCOV version 1.14