LCOV - code coverage report
Current view: top level - drivers/net/qede/base - ecore_sp_commands.c (source / functions) Hit Total Coverage
Test: Code coverage Lines: 0 269 0.0 %
Date: 2024-01-22 15:55:54 Functions: 0 17 0.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 0 142 0.0 %

           Branch data     Line data    Source code
       1                 :            : /* SPDX-License-Identifier: BSD-3-Clause
       2                 :            :  * Copyright (c) 2016 - 2018 Cavium Inc.
       3                 :            :  * All rights reserved.
       4                 :            :  * www.cavium.com
       5                 :            :  */
       6                 :            : 
       7                 :            : #include "bcm_osal.h"
       8                 :            : 
       9                 :            : #include "ecore.h"
      10                 :            : #include "ecore_status.h"
      11                 :            : #include "ecore_chain.h"
      12                 :            : #include "ecore_spq.h"
      13                 :            : #include "ecore_init_fw_funcs.h"
      14                 :            : #include "ecore_cxt.h"
      15                 :            : #include "ecore_sp_commands.h"
      16                 :            : #include "ecore_gtt_reg_addr.h"
      17                 :            : #include "ecore_iro.h"
      18                 :            : #include "reg_addr.h"
      19                 :            : #include "ecore_int.h"
      20                 :            : #include "ecore_hw.h"
      21                 :            : #include "ecore_dcbx.h"
      22                 :            : #include "ecore_sriov.h"
      23                 :            : #include "ecore_vf.h"
      24                 :            : 
      25                 :          0 : enum _ecore_status_t ecore_sp_init_request(struct ecore_hwfn *p_hwfn,
      26                 :            :                                            struct ecore_spq_entry **pp_ent,
      27                 :            :                                            u8 cmd,
      28                 :            :                                            u8 protocol,
      29                 :            :                                            struct ecore_sp_init_data *p_data)
      30                 :            : {
      31                 :          0 :         u32 opaque_cid = p_data->opaque_fid << 16 | p_data->cid;
      32                 :            :         struct ecore_spq_entry *p_ent = OSAL_NULL;
      33                 :            :         enum _ecore_status_t rc;
      34                 :            : 
      35         [ #  # ]:          0 :         if (!pp_ent)
      36                 :            :                 return ECORE_INVAL;
      37                 :            : 
      38                 :            :         /* Get an SPQ entry */
      39                 :          0 :         rc = ecore_spq_get_entry(p_hwfn, pp_ent);
      40         [ #  # ]:          0 :         if (rc != ECORE_SUCCESS)
      41                 :            :                 return rc;
      42                 :            : 
      43                 :            :         /* Fill the SPQ entry */
      44                 :          0 :         p_ent = *pp_ent;
      45                 :          0 :         p_ent->elem.hdr.cid = OSAL_CPU_TO_LE32(opaque_cid);
      46                 :          0 :         p_ent->elem.hdr.cmd_id = cmd;
      47                 :          0 :         p_ent->elem.hdr.protocol_id = protocol;
      48                 :          0 :         p_ent->priority = ECORE_SPQ_PRIORITY_NORMAL;
      49                 :          0 :         p_ent->comp_mode = p_data->comp_mode;
      50                 :          0 :         p_ent->comp_done.done = 0;
      51                 :            : 
      52   [ #  #  #  # ]:          0 :         switch (p_ent->comp_mode) {
      53                 :          0 :         case ECORE_SPQ_MODE_EBLOCK:
      54                 :          0 :                 p_ent->comp_cb.cookie = &p_ent->comp_done;
      55                 :          0 :                 break;
      56                 :            : 
      57                 :          0 :         case ECORE_SPQ_MODE_BLOCK:
      58         [ #  # ]:          0 :                 if (!p_data->p_comp_data)
      59                 :            :                         return ECORE_INVAL;
      60                 :            : 
      61                 :          0 :                 p_ent->comp_cb.cookie = p_data->p_comp_data->cookie;
      62                 :          0 :                 break;
      63                 :            : 
      64                 :          0 :         case ECORE_SPQ_MODE_CB:
      65         [ #  # ]:          0 :                 if (!p_data->p_comp_data)
      66                 :          0 :                         p_ent->comp_cb.function = OSAL_NULL;
      67                 :            :                 else
      68                 :          0 :                         p_ent->comp_cb = *p_data->p_comp_data;
      69                 :            :                 break;
      70                 :            : 
      71                 :            :         default:
      72                 :          0 :                 DP_NOTICE(p_hwfn, true, "Unknown SPQE completion mode %d\n",
      73                 :            :                           p_ent->comp_mode);
      74                 :          0 :                 return ECORE_INVAL;
      75                 :            :         }
      76                 :            : 
      77   [ #  #  #  #  :          0 :         DP_VERBOSE(p_hwfn, ECORE_MSG_SPQ,
                   #  # ]
      78                 :            :                    "Initialized: CID %08x cmd %02x protocol %02x data_addr %lu comp_mode [%s]\n",
      79                 :            :                    opaque_cid, cmd, protocol,
      80                 :            :                    (unsigned long)&p_ent->ramrod,
      81                 :            :                    D_TRINE(p_ent->comp_mode, ECORE_SPQ_MODE_EBLOCK,
      82                 :            :                            ECORE_SPQ_MODE_BLOCK, "MODE_EBLOCK", "MODE_BLOCK",
      83                 :            :                            "MODE_CB"));
      84                 :            : 
      85                 :          0 :         OSAL_MEMSET(&p_ent->ramrod, 0, sizeof(p_ent->ramrod));
      86                 :            : 
      87                 :          0 :         return ECORE_SUCCESS;
      88                 :            : }
      89                 :            : 
      90                 :            : static enum tunnel_clss ecore_tunn_clss_to_fw_clss(u8 type)
      91                 :            : {
      92                 :            :         switch (type) {
      93                 :            :         case ECORE_TUNN_CLSS_MAC_VLAN:
      94                 :            :                 return TUNNEL_CLSS_MAC_VLAN;
      95                 :            :         case ECORE_TUNN_CLSS_MAC_VNI:
      96                 :            :                 return TUNNEL_CLSS_MAC_VNI;
      97                 :            :         case ECORE_TUNN_CLSS_INNER_MAC_VLAN:
      98                 :            :                 return TUNNEL_CLSS_INNER_MAC_VLAN;
      99                 :            :         case ECORE_TUNN_CLSS_INNER_MAC_VNI:
     100                 :            :                 return TUNNEL_CLSS_INNER_MAC_VNI;
     101                 :            :         case ECORE_TUNN_CLSS_MAC_VLAN_DUAL_STAGE:
     102                 :            :                 return TUNNEL_CLSS_MAC_VLAN_DUAL_STAGE;
     103                 :            :         default:
     104                 :            :                 return TUNNEL_CLSS_MAC_VLAN;
     105                 :            :         }
     106                 :            : }
     107                 :            : 
     108                 :            : static void
     109                 :          0 : ecore_set_pf_update_tunn_mode(struct ecore_tunnel_info *p_tun,
     110                 :            :                               struct ecore_tunnel_info *p_src,
     111                 :            :                               bool b_pf_start)
     112                 :            : {
     113         [ #  # ]:          0 :         if (p_src->vxlan.b_update_mode || b_pf_start)
     114                 :          0 :                 p_tun->vxlan.b_mode_enabled = p_src->vxlan.b_mode_enabled;
     115                 :            : 
     116         [ #  # ]:          0 :         if (p_src->l2_gre.b_update_mode || b_pf_start)
     117                 :          0 :                 p_tun->l2_gre.b_mode_enabled = p_src->l2_gre.b_mode_enabled;
     118                 :            : 
     119         [ #  # ]:          0 :         if (p_src->ip_gre.b_update_mode || b_pf_start)
     120                 :          0 :                 p_tun->ip_gre.b_mode_enabled = p_src->ip_gre.b_mode_enabled;
     121                 :            : 
     122         [ #  # ]:          0 :         if (p_src->l2_geneve.b_update_mode || b_pf_start)
     123                 :          0 :                 p_tun->l2_geneve.b_mode_enabled =
     124                 :          0 :                                 p_src->l2_geneve.b_mode_enabled;
     125                 :            : 
     126         [ #  # ]:          0 :         if (p_src->ip_geneve.b_update_mode || b_pf_start)
     127                 :          0 :                 p_tun->ip_geneve.b_mode_enabled =
     128                 :          0 :                                 p_src->ip_geneve.b_mode_enabled;
     129                 :          0 : }
     130                 :            : 
     131                 :          0 : static void ecore_set_tunn_cls_info(struct ecore_tunnel_info *p_tun,
     132                 :            :                                     struct ecore_tunnel_info *p_src)
     133                 :            : {
     134                 :            :         enum tunnel_clss type;
     135                 :            : 
     136                 :          0 :         p_tun->b_update_rx_cls = p_src->b_update_rx_cls;
     137                 :          0 :         p_tun->b_update_tx_cls = p_src->b_update_tx_cls;
     138                 :            : 
     139                 :            :         /* @DPDK - typecast tunnul class */
     140         [ #  # ]:          0 :         type = ecore_tunn_clss_to_fw_clss(p_src->vxlan.tun_cls);
     141                 :          0 :         p_tun->vxlan.tun_cls = (enum ecore_tunn_clss)type;
     142         [ #  # ]:          0 :         type = ecore_tunn_clss_to_fw_clss(p_src->l2_gre.tun_cls);
     143                 :          0 :         p_tun->l2_gre.tun_cls = (enum ecore_tunn_clss)type;
     144         [ #  # ]:          0 :         type = ecore_tunn_clss_to_fw_clss(p_src->ip_gre.tun_cls);
     145                 :          0 :         p_tun->ip_gre.tun_cls = (enum ecore_tunn_clss)type;
     146         [ #  # ]:          0 :         type = ecore_tunn_clss_to_fw_clss(p_src->l2_geneve.tun_cls);
     147                 :          0 :         p_tun->l2_geneve.tun_cls = (enum ecore_tunn_clss)type;
     148         [ #  # ]:          0 :         type = ecore_tunn_clss_to_fw_clss(p_src->ip_geneve.tun_cls);
     149                 :          0 :         p_tun->ip_geneve.tun_cls = (enum ecore_tunn_clss)type;
     150                 :          0 : }
     151                 :            : 
     152                 :            : static void ecore_set_tunn_ports(struct ecore_tunnel_info *p_tun,
     153                 :            :                                  struct ecore_tunnel_info *p_src)
     154                 :            : {
     155                 :          0 :         p_tun->geneve_port.b_update_port = p_src->geneve_port.b_update_port;
     156                 :          0 :         p_tun->vxlan_port.b_update_port = p_src->vxlan_port.b_update_port;
     157                 :            : 
     158   [ #  #  #  # ]:          0 :         if (p_src->geneve_port.b_update_port)
     159                 :          0 :                 p_tun->geneve_port.port = p_src->geneve_port.port;
     160                 :            : 
     161   [ #  #  #  # ]:          0 :         if (p_src->vxlan_port.b_update_port)
     162                 :          0 :                 p_tun->vxlan_port.port = p_src->vxlan_port.port;
     163                 :            : }
     164                 :            : 
     165                 :            : static void
     166                 :            : __ecore_set_ramrod_tunnel_param(u8 *p_tunn_cls,
     167                 :            :                                 struct ecore_tunn_update_type *tun_type)
     168                 :            : {
     169                 :          0 :         *p_tunn_cls = tun_type->tun_cls;
     170                 :          0 : }
     171                 :            : 
     172                 :            : static void
     173                 :            : ecore_set_ramrod_tunnel_param(u8 *p_tunn_cls,
     174                 :            :                               struct ecore_tunn_update_type *tun_type,
     175                 :            :                               u8 *p_update_port, __le16 *p_port,
     176                 :            :                               struct ecore_tunn_update_udp_port *p_udp_port)
     177                 :            : {
     178                 :            :         __ecore_set_ramrod_tunnel_param(p_tunn_cls, tun_type);
     179   [ #  #  #  #  :          0 :         if (p_udp_port->b_update_port) {
             #  #  #  # ]
     180                 :          0 :                 *p_update_port = 1;
     181                 :          0 :                 *p_port = OSAL_CPU_TO_LE16(p_udp_port->port);
     182                 :            :         }
     183                 :            : }
     184                 :            : 
     185                 :            : static void
     186                 :          0 : ecore_tunn_set_pf_update_params(struct ecore_hwfn               *p_hwfn,
     187                 :            :                                 struct ecore_tunnel_info *p_src,
     188                 :            :                                 struct pf_update_tunnel_config  *p_tunn_cfg)
     189                 :            : {
     190                 :          0 :         struct ecore_tunnel_info *p_tun = &p_hwfn->p_dev->tunnel;
     191                 :            : 
     192                 :          0 :         ecore_set_pf_update_tunn_mode(p_tun, p_src, false);
     193                 :          0 :         ecore_set_tunn_cls_info(p_tun, p_src);
     194                 :            :         ecore_set_tunn_ports(p_tun, p_src);
     195                 :            : 
     196                 :            :         ecore_set_ramrod_tunnel_param(&p_tunn_cfg->tunnel_clss_vxlan,
     197                 :            :                                       &p_tun->vxlan,
     198                 :            :                                       &p_tunn_cfg->set_vxlan_udp_port_flg,
     199                 :            :                                       &p_tunn_cfg->vxlan_udp_port,
     200                 :            :                                       &p_tun->vxlan_port);
     201                 :            : 
     202                 :            :         ecore_set_ramrod_tunnel_param(&p_tunn_cfg->tunnel_clss_l2geneve,
     203                 :            :                                       &p_tun->l2_geneve,
     204                 :            :                                       &p_tunn_cfg->set_geneve_udp_port_flg,
     205                 :            :                                       &p_tunn_cfg->geneve_udp_port,
     206                 :            :                                       &p_tun->geneve_port);
     207                 :            : 
     208                 :            :         __ecore_set_ramrod_tunnel_param(&p_tunn_cfg->tunnel_clss_ipgeneve,
     209                 :            :                                         &p_tun->ip_geneve);
     210                 :            : 
     211                 :            :         __ecore_set_ramrod_tunnel_param(&p_tunn_cfg->tunnel_clss_l2gre,
     212                 :            :                                         &p_tun->l2_gre);
     213                 :            : 
     214                 :            :         __ecore_set_ramrod_tunnel_param(&p_tunn_cfg->tunnel_clss_ipgre,
     215                 :            :                                         &p_tun->ip_gre);
     216                 :            : 
     217                 :          0 :         p_tunn_cfg->update_rx_pf_clss = p_tun->b_update_rx_cls;
     218                 :          0 : }
     219                 :            : 
     220                 :          0 : static void ecore_set_hw_tunn_mode(struct ecore_hwfn *p_hwfn,
     221                 :            :                                    struct ecore_ptt *p_ptt,
     222                 :            :                                    struct ecore_tunnel_info *p_tun)
     223                 :            : {
     224                 :          0 :         ecore_set_gre_enable(p_hwfn, p_ptt, p_tun->l2_gre.b_mode_enabled,
     225                 :          0 :                              p_tun->ip_gre.b_mode_enabled);
     226                 :          0 :         ecore_set_vxlan_enable(p_hwfn, p_ptt, p_tun->vxlan.b_mode_enabled);
     227                 :            : 
     228                 :          0 :         ecore_set_geneve_enable(p_hwfn, p_ptt, p_tun->l2_geneve.b_mode_enabled,
     229                 :          0 :                                 p_tun->ip_geneve.b_mode_enabled);
     230                 :          0 : }
     231                 :            : 
     232                 :          0 : static void ecore_set_hw_tunn_mode_port(struct ecore_hwfn *p_hwfn,
     233                 :            :                                         struct ecore_ptt  *p_ptt,
     234                 :            :                                         struct ecore_tunnel_info *p_tunn)
     235                 :            : {
     236   [ #  #  #  #  :          0 :         if (ECORE_IS_BB_A0(p_hwfn->p_dev)) {
                   #  # ]
     237                 :          0 :                 DP_NOTICE(p_hwfn, true,
     238                 :            :                           "A0 chip: tunnel hw config is not supported\n");
     239                 :          0 :                 return;
     240                 :            :         }
     241                 :            : 
     242         [ #  # ]:          0 :         if (p_tunn->vxlan_port.b_update_port)
     243                 :          0 :                 ecore_set_vxlan_dest_port(p_hwfn, p_ptt,
     244                 :          0 :                                           p_tunn->vxlan_port.port);
     245                 :            : 
     246         [ #  # ]:          0 :         if (p_tunn->geneve_port.b_update_port)
     247                 :          0 :                 ecore_set_geneve_dest_port(p_hwfn, p_ptt,
     248                 :          0 :                                            p_tunn->geneve_port.port);
     249                 :            : 
     250                 :          0 :         ecore_set_hw_tunn_mode(p_hwfn, p_ptt, p_tunn);
     251                 :            : }
     252                 :            : 
     253                 :            : static void
     254                 :          0 : ecore_tunn_set_pf_start_params(struct ecore_hwfn *p_hwfn,
     255                 :            :                                struct ecore_tunnel_info         *p_src,
     256                 :            :                                struct pf_start_tunnel_config *p_tunn_cfg)
     257                 :            : {
     258                 :          0 :         struct ecore_tunnel_info *p_tun = &p_hwfn->p_dev->tunnel;
     259                 :            : 
     260   [ #  #  #  #  :          0 :         if (ECORE_IS_BB_A0(p_hwfn->p_dev)) {
                   #  # ]
     261                 :          0 :                 DP_NOTICE(p_hwfn, true,
     262                 :            :                           "A0 chip: tunnel pf start config is not supported\n");
     263                 :          0 :                 return;
     264                 :            :         }
     265                 :            : 
     266         [ #  # ]:          0 :         if (!p_src)
     267                 :            :                 return;
     268                 :            : 
     269                 :          0 :         ecore_set_pf_update_tunn_mode(p_tun, p_src, true);
     270                 :          0 :         ecore_set_tunn_cls_info(p_tun, p_src);
     271                 :            :         ecore_set_tunn_ports(p_tun, p_src);
     272                 :            : 
     273                 :            :         ecore_set_ramrod_tunnel_param(&p_tunn_cfg->tunnel_clss_vxlan,
     274                 :            :                                       &p_tun->vxlan,
     275                 :            :                                       &p_tunn_cfg->set_vxlan_udp_port_flg,
     276                 :            :                                       &p_tunn_cfg->vxlan_udp_port,
     277                 :            :                                       &p_tun->vxlan_port);
     278                 :            : 
     279                 :            :         ecore_set_ramrod_tunnel_param(&p_tunn_cfg->tunnel_clss_l2geneve,
     280                 :            :                                       &p_tun->l2_geneve,
     281                 :            :                                       &p_tunn_cfg->set_geneve_udp_port_flg,
     282                 :            :                                       &p_tunn_cfg->geneve_udp_port,
     283                 :            :                                       &p_tun->geneve_port);
     284                 :            : 
     285                 :            :         __ecore_set_ramrod_tunnel_param(&p_tunn_cfg->tunnel_clss_ipgeneve,
     286                 :            :                                         &p_tun->ip_geneve);
     287                 :            : 
     288                 :            :         __ecore_set_ramrod_tunnel_param(&p_tunn_cfg->tunnel_clss_l2gre,
     289                 :            :                                         &p_tun->l2_gre);
     290                 :            : 
     291                 :            :         __ecore_set_ramrod_tunnel_param(&p_tunn_cfg->tunnel_clss_ipgre,
     292                 :            :                                         &p_tun->ip_gre);
     293                 :            : }
     294                 :            : 
     295                 :            : #define ETH_P_8021Q 0x8100
     296                 :            : #define ETH_P_8021AD 0x88A8 /* 802.1ad Service VLAN         */
     297                 :            : 
     298                 :          0 : enum _ecore_status_t ecore_sp_pf_start(struct ecore_hwfn *p_hwfn,
     299                 :            :                                        struct ecore_ptt *p_ptt,
     300                 :            :                                        struct ecore_tunnel_info *p_tunn,
     301                 :            :                                        bool allow_npar_tx_switch)
     302                 :            : {
     303                 :            :         struct pf_start_ramrod_data *p_ramrod = OSAL_NULL;
     304                 :          0 :         u16 sb = ecore_int_get_sp_sb_id(p_hwfn);
     305                 :          0 :         u8 sb_index = p_hwfn->p_eq->eq_sb_index;
     306         [ #  # ]:          0 :         struct ecore_spq_entry *p_ent = OSAL_NULL;
     307                 :            :         struct ecore_sp_init_data init_data;
     308                 :            :         enum _ecore_status_t rc = ECORE_NOTIMPL;
     309                 :            :         u8 page_cnt;
     310                 :            :         u8 i;
     311                 :            : 
     312                 :            :         /* update initial eq producer */
     313                 :          0 :         ecore_eq_prod_update(p_hwfn,
     314                 :            :                              ecore_chain_get_prod_idx(&p_hwfn->p_eq->chain));
     315                 :            : 
     316                 :            :         /* Initialize the SPQ entry for the ramrod */
     317                 :            :         OSAL_MEMSET(&init_data, 0, sizeof(init_data));
     318                 :          0 :         init_data.cid = ecore_spq_get_cid(p_hwfn);
     319                 :          0 :         init_data.opaque_fid = p_hwfn->hw_info.opaque_fid;
     320                 :          0 :         init_data.comp_mode = ECORE_SPQ_MODE_EBLOCK;
     321                 :            : 
     322                 :          0 :         rc = ecore_sp_init_request(p_hwfn, &p_ent,
     323                 :            :                                    COMMON_RAMROD_PF_START,
     324                 :            :                                    PROTOCOLID_COMMON, &init_data);
     325         [ #  # ]:          0 :         if (rc != ECORE_SUCCESS)
     326                 :            :                 return rc;
     327                 :            : 
     328                 :            :         /* Fill the ramrod data */
     329                 :          0 :         p_ramrod = &p_ent->ramrod.pf_start;
     330                 :          0 :         p_ramrod->event_ring_sb_id = OSAL_CPU_TO_LE16(sb);
     331                 :          0 :         p_ramrod->event_ring_sb_index = sb_index;
     332         [ #  # ]:          0 :         p_ramrod->path_id = ECORE_PATH_ID(p_hwfn);
     333                 :            : 
     334                 :            :         /* For easier debugging */
     335                 :          0 :         p_ramrod->dont_log_ramrods = 0;
     336         [ #  # ]:          0 :         p_ramrod->log_type_mask = OSAL_CPU_TO_LE16(0x8f);
     337                 :            : 
     338         [ #  # ]:          0 :         if (OSAL_GET_BIT(ECORE_MF_OVLAN_CLSS, &p_hwfn->p_dev->mf_bits))
     339                 :          0 :                 p_ramrod->mf_mode = MF_OVLAN;
     340                 :            :         else
     341                 :          0 :                 p_ramrod->mf_mode = MF_NPAR;
     342                 :            : 
     343                 :          0 :         p_ramrod->outer_tag_config.outer_tag.tci =
     344         [ #  # ]:          0 :                 OSAL_CPU_TO_LE16(p_hwfn->hw_info.ovlan);
     345         [ #  # ]:          0 :         if (OSAL_GET_BIT(ECORE_MF_8021Q_TAGGING, &p_hwfn->p_dev->mf_bits)) {
     346                 :          0 :                 p_ramrod->outer_tag_config.outer_tag.tpid = ETH_P_8021Q;
     347         [ #  # ]:          0 :         } else if (OSAL_GET_BIT(ECORE_MF_8021AD_TAGGING,
     348                 :            :                  &p_hwfn->p_dev->mf_bits)) {
     349                 :          0 :                 p_ramrod->outer_tag_config.outer_tag.tpid = ETH_P_8021AD;
     350                 :          0 :                 p_ramrod->outer_tag_config.enable_stag_pri_change = 1;
     351                 :            :         }
     352                 :            : 
     353                 :          0 :         p_ramrod->outer_tag_config.pri_map_valid = 1;
     354         [ #  # ]:          0 :         for (i = 0; i < ECORE_MAX_PFC_PRIORITIES; i++)
     355                 :          0 :                 p_ramrod->outer_tag_config.inner_to_outer_pri_map[i] = i;
     356                 :            : 
     357                 :            :         /* enable_stag_pri_change should be set if port is in BD mode or,
     358                 :            :          * UFP with Host Control mode.
     359                 :            :          */
     360         [ #  # ]:          0 :         if (OSAL_GET_BIT(ECORE_MF_UFP_SPECIFIC, &p_hwfn->p_dev->mf_bits)) {
     361         [ #  # ]:          0 :                 if (p_hwfn->ufp_info.pri_type == ECORE_UFP_PRI_OS)
     362                 :          0 :                         p_ramrod->outer_tag_config.enable_stag_pri_change = 1;
     363                 :            :                 else
     364                 :          0 :                         p_ramrod->outer_tag_config.enable_stag_pri_change = 0;
     365                 :            : 
     366                 :          0 :                 p_ramrod->outer_tag_config.outer_tag.tci |=
     367                 :          0 :                         OSAL_CPU_TO_LE16(((u16)p_hwfn->ufp_info.tc << 13));
     368                 :            :         }
     369                 :            : 
     370                 :            :         /* Place EQ address in RAMROD */
     371                 :          0 :         DMA_REGPAIR_LE(p_ramrod->event_ring_pbl_addr,
     372                 :            :                        p_hwfn->p_eq->chain.pbl_sp.p_phys_table);
     373                 :          0 :         page_cnt = (u8)ecore_chain_get_page_cnt(&p_hwfn->p_eq->chain);
     374                 :          0 :         p_ramrod->event_ring_num_pages = page_cnt;
     375                 :          0 :         DMA_REGPAIR_LE(p_ramrod->consolid_q_pbl_addr,
     376                 :            :                        p_hwfn->p_consq->chain.pbl_sp.p_phys_table);
     377                 :            : 
     378                 :          0 :         ecore_tunn_set_pf_start_params(p_hwfn, p_tunn,
     379                 :            :                                        &p_ramrod->tunnel_config);
     380                 :            : 
     381         [ #  # ]:          0 :         if (OSAL_GET_BIT(ECORE_MF_INTER_PF_SWITCH,
     382                 :            :                           &p_hwfn->p_dev->mf_bits))
     383                 :          0 :                 p_ramrod->allow_npar_tx_switching = allow_npar_tx_switch;
     384                 :            : 
     385         [ #  # ]:          0 :         switch (p_hwfn->hw_info.personality) {
     386                 :          0 :         case ECORE_PCI_ETH:
     387                 :          0 :                 p_ramrod->personality = PERSONALITY_ETH;
     388                 :          0 :                 break;
     389                 :            :         default:
     390                 :          0 :                 DP_NOTICE(p_hwfn, true, "Unknown personality %d\n",
     391                 :            :                          p_hwfn->hw_info.personality);
     392                 :          0 :                 p_ramrod->personality = PERSONALITY_ETH;
     393                 :            :         }
     394                 :            : 
     395         [ #  # ]:          0 :         if (p_hwfn->p_dev->p_iov_info) {
     396                 :            :                 struct ecore_hw_sriov_info *p_iov = p_hwfn->p_dev->p_iov_info;
     397                 :            : 
     398                 :          0 :                 p_ramrod->base_vf_id = (u8)p_iov->first_vf_in_pf;
     399                 :          0 :                 p_ramrod->num_vfs = (u8)p_iov->total_vfs;
     400                 :            :         }
     401                 :            :         /* @@@TBD - update also the "ROCE_VER_KEY" entries when the FW RoCE HSI
     402                 :            :          * version is available.
     403                 :            :          */
     404                 :          0 :         p_ramrod->hsi_fp_ver.major_ver_arr[ETH_VER_KEY] = ETH_HSI_VER_MAJOR;
     405                 :          0 :         p_ramrod->hsi_fp_ver.minor_ver_arr[ETH_VER_KEY] = ETH_HSI_VER_MINOR;
     406                 :            : 
     407         [ #  # ]:          0 :         DP_VERBOSE(p_hwfn, ECORE_MSG_SPQ,
     408                 :            :                    "Setting event_ring_sb [id %04x index %02x], outer_tag.tpid [%d], outer_tag.tci [%d]\n",
     409                 :            :                    sb, sb_index, p_ramrod->outer_tag_config.outer_tag.tpid,
     410                 :            :                    p_ramrod->outer_tag_config.outer_tag.tci);
     411                 :            : 
     412                 :          0 :         rc = ecore_spq_post(p_hwfn, p_ent, OSAL_NULL);
     413                 :            : 
     414         [ #  # ]:          0 :         if (p_tunn)
     415                 :          0 :                 ecore_set_hw_tunn_mode_port(p_hwfn, p_ptt,
     416                 :          0 :                                             &p_hwfn->p_dev->tunnel);
     417                 :            : 
     418                 :            :         return rc;
     419                 :            : }
     420                 :            : 
     421                 :          0 : enum _ecore_status_t ecore_sp_pf_update_dcbx(struct ecore_hwfn *p_hwfn)
     422                 :            : {
     423                 :          0 :         struct ecore_spq_entry *p_ent = OSAL_NULL;
     424                 :            :         struct ecore_sp_init_data init_data;
     425                 :            :         enum _ecore_status_t rc = ECORE_NOTIMPL;
     426                 :            : 
     427                 :            :         /* Get SPQ entry */
     428                 :            :         OSAL_MEMSET(&init_data, 0, sizeof(init_data));
     429                 :          0 :         init_data.cid = ecore_spq_get_cid(p_hwfn);
     430                 :          0 :         init_data.opaque_fid = p_hwfn->hw_info.opaque_fid;
     431                 :          0 :         init_data.comp_mode = ECORE_SPQ_MODE_CB;
     432                 :            : 
     433                 :          0 :         rc = ecore_sp_init_request(p_hwfn, &p_ent,
     434                 :            :                                    COMMON_RAMROD_PF_UPDATE, PROTOCOLID_COMMON,
     435                 :            :                                    &init_data);
     436         [ #  # ]:          0 :         if (rc != ECORE_SUCCESS)
     437                 :            :                 return rc;
     438                 :            : 
     439                 :          0 :         ecore_dcbx_set_pf_update_params(&p_hwfn->p_dcbx_info->results,
     440                 :          0 :                                         &p_ent->ramrod.pf_update);
     441                 :            : 
     442                 :          0 :         return ecore_spq_post(p_hwfn, p_ent, OSAL_NULL);
     443                 :            : }
     444                 :            : 
     445                 :          0 : enum _ecore_status_t ecore_sp_pf_update_ufp(struct ecore_hwfn *p_hwfn)
     446                 :            : {
     447                 :          0 :         struct ecore_spq_entry *p_ent = OSAL_NULL;
     448                 :            :         struct ecore_sp_init_data init_data;
     449                 :            :         enum _ecore_status_t rc = ECORE_NOTIMPL;
     450                 :            : 
     451                 :            :         /* Get SPQ entry */
     452                 :            :         OSAL_MEMSET(&init_data, 0, sizeof(init_data));
     453                 :          0 :         init_data.cid = ecore_spq_get_cid(p_hwfn);
     454                 :          0 :         init_data.opaque_fid = p_hwfn->hw_info.opaque_fid;
     455                 :          0 :         init_data.comp_mode = ECORE_SPQ_MODE_CB;
     456                 :            : 
     457                 :          0 :         rc = ecore_sp_init_request(p_hwfn, &p_ent,
     458                 :            :                                    COMMON_RAMROD_PF_UPDATE, PROTOCOLID_COMMON,
     459                 :            :                                    &init_data);
     460         [ #  # ]:          0 :         if (rc != ECORE_SUCCESS)
     461                 :            :                 return rc;
     462                 :            : 
     463                 :          0 :         p_ent->ramrod.pf_update.update_enable_stag_pri_change = true;
     464         [ #  # ]:          0 :         if (p_hwfn->ufp_info.pri_type == ECORE_UFP_PRI_OS)
     465                 :          0 :                 p_ent->ramrod.pf_update.enable_stag_pri_change = 1;
     466                 :            :         else
     467                 :          0 :                 p_ent->ramrod.pf_update.enable_stag_pri_change = 0;
     468                 :            : 
     469                 :          0 :         return ecore_spq_post(p_hwfn, p_ent, OSAL_NULL);
     470                 :            : }
     471                 :            : 
     472                 :            : 
     473                 :            : /* QM rate limiter resolution is 1.6Mbps */
     474                 :            : #define QM_RL_RESOLUTION(mb_val)        ((mb_val) * 10 / 16)
     475                 :            : 
     476                 :            : /* FW uses 1/64k to express gd */
     477                 :            : #define FW_GD_RESOLUTION(gd)            (64 * 1024 / (gd))
     478                 :            : 
     479                 :          0 : u16 ecore_sp_rl_mb_to_qm(u32 mb_val)
     480                 :            : {
     481         [ #  # ]:          0 :         return (u16)OSAL_MIN_T(u32, (u16)(~0U), QM_RL_RESOLUTION(mb_val));
     482                 :            : }
     483                 :            : 
     484                 :          0 : u16 ecore_sp_rl_gd_denom(u32 gd)
     485                 :            : {
     486   [ #  #  #  # ]:          0 :         return gd ? (u16)OSAL_MIN_T(u32, (u16)(~0U), FW_GD_RESOLUTION(gd)) : 0;
     487                 :            : }
     488                 :            : 
     489                 :          0 : enum _ecore_status_t ecore_sp_rl_update(struct ecore_hwfn *p_hwfn,
     490                 :            :                                         struct ecore_rl_update_params *params)
     491                 :            : {
     492                 :          0 :         struct ecore_spq_entry *p_ent = OSAL_NULL;
     493                 :            :         enum _ecore_status_t rc = ECORE_NOTIMPL;
     494                 :            :         struct rl_update_ramrod_data *rl_update;
     495                 :            :         struct ecore_sp_init_data init_data;
     496                 :            : 
     497                 :            :         /* Get SPQ entry */
     498                 :            :         OSAL_MEMSET(&init_data, 0, sizeof(init_data));
     499                 :          0 :         init_data.cid = ecore_spq_get_cid(p_hwfn);
     500                 :          0 :         init_data.opaque_fid = p_hwfn->hw_info.opaque_fid;
     501                 :          0 :         init_data.comp_mode = ECORE_SPQ_MODE_EBLOCK;
     502                 :            : 
     503                 :          0 :         rc = ecore_sp_init_request(p_hwfn, &p_ent,
     504                 :            :                                    COMMON_RAMROD_RL_UPDATE, PROTOCOLID_COMMON,
     505                 :            :                                    &init_data);
     506         [ #  # ]:          0 :         if (rc != ECORE_SUCCESS)
     507                 :            :                 return rc;
     508                 :            : 
     509                 :          0 :         rl_update = &p_ent->ramrod.rl_update;
     510                 :            : 
     511                 :          0 :         rl_update->qcn_update_param_flg = params->qcn_update_param_flg;
     512                 :          0 :         rl_update->dcqcn_update_param_flg = params->dcqcn_update_param_flg;
     513                 :          0 :         rl_update->rl_init_flg = params->rl_init_flg;
     514                 :          0 :         rl_update->rl_start_flg = params->rl_start_flg;
     515                 :          0 :         rl_update->rl_stop_flg = params->rl_stop_flg;
     516                 :          0 :         rl_update->rl_id_first = params->rl_id_first;
     517                 :          0 :         rl_update->rl_id_last = params->rl_id_last;
     518                 :          0 :         rl_update->rl_dc_qcn_flg = params->rl_dc_qcn_flg;
     519                 :          0 :         rl_update->dcqcn_reset_alpha_on_idle =
     520                 :          0 :                 params->dcqcn_reset_alpha_on_idle;
     521                 :          0 :         rl_update->rl_bc_stage_th = params->rl_bc_stage_th;
     522                 :          0 :         rl_update->rl_timer_stage_th = params->rl_timer_stage_th;
     523                 :          0 :         rl_update->rl_bc_rate = OSAL_CPU_TO_LE32(params->rl_bc_rate);
     524                 :          0 :         rl_update->rl_max_rate =
     525                 :          0 :                 OSAL_CPU_TO_LE16(ecore_sp_rl_mb_to_qm(params->rl_max_rate));
     526                 :          0 :         rl_update->rl_r_ai =
     527                 :          0 :                 OSAL_CPU_TO_LE16(ecore_sp_rl_mb_to_qm(params->rl_r_ai));
     528                 :          0 :         rl_update->rl_r_hai =
     529                 :          0 :                 OSAL_CPU_TO_LE16(ecore_sp_rl_mb_to_qm(params->rl_r_hai));
     530                 :          0 :         rl_update->dcqcn_g =
     531                 :          0 :                 OSAL_CPU_TO_LE16(ecore_sp_rl_gd_denom(params->dcqcn_gd));
     532                 :          0 :         rl_update->dcqcn_k_us = OSAL_CPU_TO_LE32(params->dcqcn_k_us);
     533                 :          0 :         rl_update->dcqcn_timeuot_us =
     534                 :          0 :                 OSAL_CPU_TO_LE32(params->dcqcn_timeuot_us);
     535                 :          0 :         rl_update->qcn_timeuot_us = OSAL_CPU_TO_LE32(params->qcn_timeuot_us);
     536                 :            : 
     537         [ #  # ]:          0 :         DP_VERBOSE(p_hwfn, ECORE_MSG_SPQ, "rl_params: qcn_update_param_flg %x, dcqcn_update_param_flg %x, rl_init_flg %x, rl_start_flg %x, rl_stop_flg %x, rl_id_first %x, rl_id_last %x, rl_dc_qcn_flg %x,dcqcn_reset_alpha_on_idle %x, rl_bc_stage_th %x, rl_timer_stage_th %x, rl_bc_rate %x, rl_max_rate %x, rl_r_ai %x, rl_r_hai %x, dcqcn_g %x, dcqcn_k_us %x, dcqcn_timeuot_us %x, qcn_timeuot_us %x\n",
     538                 :            :                    rl_update->qcn_update_param_flg,
     539                 :            :                    rl_update->dcqcn_update_param_flg,
     540                 :            :                    rl_update->rl_init_flg, rl_update->rl_start_flg,
     541                 :            :                    rl_update->rl_stop_flg, rl_update->rl_id_first,
     542                 :            :                    rl_update->rl_id_last, rl_update->rl_dc_qcn_flg,
     543                 :            :                    rl_update->dcqcn_reset_alpha_on_idle,
     544                 :            :                    rl_update->rl_bc_stage_th, rl_update->rl_timer_stage_th,
     545                 :            :                    rl_update->rl_bc_rate, rl_update->rl_max_rate,
     546                 :            :                    rl_update->rl_r_ai, rl_update->rl_r_hai,
     547                 :            :                    rl_update->dcqcn_g, rl_update->dcqcn_k_us,
     548                 :            :                    rl_update->dcqcn_timeuot_us, rl_update->qcn_timeuot_us);
     549                 :            : 
     550                 :          0 :         return ecore_spq_post(p_hwfn, p_ent, OSAL_NULL);
     551                 :            : }
     552                 :            : 
     553                 :            : /* Set pf update ramrod command params */
     554                 :            : enum _ecore_status_t
     555                 :          0 : ecore_sp_pf_update_tunn_cfg(struct ecore_hwfn *p_hwfn,
     556                 :            :                             struct ecore_ptt *p_ptt,
     557                 :            :                             struct ecore_tunnel_info *p_tunn,
     558                 :            :                             enum spq_mode comp_mode,
     559                 :            :                             struct ecore_spq_comp_cb *p_comp_data)
     560                 :            : {
     561                 :          0 :         struct ecore_spq_entry *p_ent = OSAL_NULL;
     562                 :            :         struct ecore_sp_init_data init_data;
     563                 :            :         enum _ecore_status_t rc = ECORE_NOTIMPL;
     564                 :            : 
     565         [ #  # ]:          0 :         if (IS_VF(p_hwfn->p_dev))
     566                 :          0 :                 return ecore_vf_pf_tunnel_param_update(p_hwfn, p_tunn);
     567                 :            : 
     568   [ #  #  #  #  :          0 :         if (ECORE_IS_BB_A0(p_hwfn->p_dev)) {
                   #  # ]
     569                 :          0 :                 DP_NOTICE(p_hwfn, true,
     570                 :            :                           "A0 chip: tunnel pf update config is not supported\n");
     571                 :          0 :                 return rc;
     572                 :            :         }
     573                 :            : 
     574         [ #  # ]:          0 :         if (!p_tunn)
     575                 :            :                 return ECORE_INVAL;
     576                 :            : 
     577                 :            :         /* Get SPQ entry */
     578                 :            :         OSAL_MEMSET(&init_data, 0, sizeof(init_data));
     579                 :          0 :         init_data.cid = ecore_spq_get_cid(p_hwfn);
     580                 :          0 :         init_data.opaque_fid = p_hwfn->hw_info.opaque_fid;
     581                 :          0 :         init_data.comp_mode = comp_mode;
     582                 :          0 :         init_data.p_comp_data = p_comp_data;
     583                 :            : 
     584                 :          0 :         rc = ecore_sp_init_request(p_hwfn, &p_ent,
     585                 :            :                                    COMMON_RAMROD_PF_UPDATE, PROTOCOLID_COMMON,
     586                 :            :                                    &init_data);
     587         [ #  # ]:          0 :         if (rc != ECORE_SUCCESS)
     588                 :            :                 return rc;
     589                 :            : 
     590                 :          0 :         ecore_tunn_set_pf_update_params(p_hwfn, p_tunn,
     591                 :          0 :                                         &p_ent->ramrod.pf_update.tunnel_config);
     592                 :            : 
     593                 :          0 :         rc = ecore_spq_post(p_hwfn, p_ent, OSAL_NULL);
     594         [ #  # ]:          0 :         if (rc != ECORE_SUCCESS)
     595                 :            :                 return rc;
     596                 :            : 
     597                 :          0 :         ecore_set_hw_tunn_mode_port(p_hwfn, p_ptt, &p_hwfn->p_dev->tunnel);
     598                 :            : 
     599                 :          0 :         return rc;
     600                 :            : }
     601                 :            : 
     602                 :          0 : enum _ecore_status_t ecore_sp_pf_stop(struct ecore_hwfn *p_hwfn)
     603                 :            : {
     604                 :          0 :         struct ecore_spq_entry *p_ent = OSAL_NULL;
     605                 :            :         struct ecore_sp_init_data init_data;
     606                 :            :         enum _ecore_status_t rc = ECORE_NOTIMPL;
     607                 :            : 
     608                 :            :         /* Get SPQ entry */
     609                 :            :         OSAL_MEMSET(&init_data, 0, sizeof(init_data));
     610                 :          0 :         init_data.cid = ecore_spq_get_cid(p_hwfn);
     611                 :          0 :         init_data.opaque_fid = p_hwfn->hw_info.opaque_fid;
     612                 :          0 :         init_data.comp_mode = ECORE_SPQ_MODE_EBLOCK;
     613                 :            : 
     614                 :          0 :         rc = ecore_sp_init_request(p_hwfn, &p_ent,
     615                 :            :                                    COMMON_RAMROD_PF_STOP, PROTOCOLID_COMMON,
     616                 :            :                                    &init_data);
     617         [ #  # ]:          0 :         if (rc != ECORE_SUCCESS)
     618                 :            :                 return rc;
     619                 :            : 
     620                 :          0 :         return ecore_spq_post(p_hwfn, p_ent, OSAL_NULL);
     621                 :            : }
     622                 :            : 
     623                 :          0 : enum _ecore_status_t ecore_sp_heartbeat_ramrod(struct ecore_hwfn *p_hwfn)
     624                 :            : {
     625                 :          0 :         struct ecore_spq_entry *p_ent = OSAL_NULL;
     626                 :            :         struct ecore_sp_init_data init_data;
     627                 :            :         enum _ecore_status_t rc;
     628                 :            : 
     629                 :            :         /* Get SPQ entry */
     630                 :            :         OSAL_MEMSET(&init_data, 0, sizeof(init_data));
     631                 :          0 :         init_data.cid = ecore_spq_get_cid(p_hwfn);
     632                 :          0 :         init_data.opaque_fid = p_hwfn->hw_info.opaque_fid;
     633                 :          0 :         init_data.comp_mode = ECORE_SPQ_MODE_EBLOCK;
     634                 :            : 
     635                 :          0 :         rc = ecore_sp_init_request(p_hwfn, &p_ent,
     636                 :            :                                    COMMON_RAMROD_EMPTY, PROTOCOLID_COMMON,
     637                 :            :                                    &init_data);
     638         [ #  # ]:          0 :         if (rc != ECORE_SUCCESS)
     639                 :            :                 return rc;
     640                 :            : 
     641         [ #  # ]:          0 :         if (OSAL_GET_BIT(ECORE_MF_UFP_SPECIFIC, &p_hwfn->p_dev->mf_bits))
     642                 :          0 :                 p_ent->ramrod.pf_update.mf_vlan |=
     643                 :          0 :                         OSAL_CPU_TO_LE16(((u16)p_hwfn->ufp_info.tc << 13));
     644                 :            : 
     645                 :          0 :         return ecore_spq_post(p_hwfn, p_ent, OSAL_NULL);
     646                 :            : }
     647                 :            : 
     648                 :          0 : enum _ecore_status_t ecore_sp_pf_update_stag(struct ecore_hwfn *p_hwfn)
     649                 :            : {
     650                 :          0 :         struct ecore_spq_entry *p_ent = OSAL_NULL;
     651                 :            :         struct ecore_sp_init_data init_data;
     652                 :            :         enum _ecore_status_t rc = ECORE_NOTIMPL;
     653                 :            : 
     654                 :            :         /* Get SPQ entry */
     655                 :            :         OSAL_MEMSET(&init_data, 0, sizeof(init_data));
     656                 :          0 :         init_data.cid = ecore_spq_get_cid(p_hwfn);
     657                 :          0 :         init_data.opaque_fid = p_hwfn->hw_info.opaque_fid;
     658                 :          0 :         init_data.comp_mode = ECORE_SPQ_MODE_CB;
     659                 :            : 
     660                 :          0 :         rc = ecore_sp_init_request(p_hwfn, &p_ent,
     661                 :            :                                    COMMON_RAMROD_PF_UPDATE, PROTOCOLID_COMMON,
     662                 :            :                                    &init_data);
     663         [ #  # ]:          0 :         if (rc != ECORE_SUCCESS)
     664                 :            :                 return rc;
     665                 :            : 
     666                 :          0 :         p_ent->ramrod.pf_update.update_mf_vlan_flag = true;
     667                 :          0 :         p_ent->ramrod.pf_update.mf_vlan =
     668                 :          0 :                                 OSAL_CPU_TO_LE16(p_hwfn->hw_info.ovlan);
     669                 :            : 
     670                 :          0 :         return ecore_spq_post(p_hwfn, p_ent, OSAL_NULL);
     671                 :            : }

Generated by: LCOV version 1.14