LCOV - code coverage report
Current view: top level - drivers/net/ice/base - ice_dcb.c (source / functions) Hit Total Coverage
Test: Code coverage Lines: 0 462 0.0 %
Date: 2024-12-01 18:57:19 Functions: 0 31 0.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 0 250 0.0 %

           Branch data     Line data    Source code
       1                 :            : /* SPDX-License-Identifier: BSD-3-Clause
       2                 :            :  * Copyright(c) 2001-2023 Intel Corporation
       3                 :            :  */
       4                 :            : 
       5                 :            : #include "ice_common.h"
       6                 :            : #include "ice_sched.h"
       7                 :            : #include "ice_dcb.h"
       8                 :            : 
       9                 :            : /**
      10                 :            :  * ice_aq_get_lldp_mib
      11                 :            :  * @hw: pointer to the HW struct
      12                 :            :  * @bridge_type: type of bridge requested
      13                 :            :  * @mib_type: Local, Remote or both Local and Remote MIBs
      14                 :            :  * @buf: pointer to the caller-supplied buffer to store the MIB block
      15                 :            :  * @buf_size: size of the buffer (in bytes)
      16                 :            :  * @local_len: length of the returned Local LLDP MIB
      17                 :            :  * @remote_len: length of the returned Remote LLDP MIB
      18                 :            :  * @cd: pointer to command details structure or NULL
      19                 :            :  *
      20                 :            :  * Requests the complete LLDP MIB (entire packet). (0x0A00)
      21                 :            :  */
      22                 :            : int
      23                 :          0 : ice_aq_get_lldp_mib(struct ice_hw *hw, u8 bridge_type, u8 mib_type, void *buf,
      24                 :            :                     u16 buf_size, u16 *local_len, u16 *remote_len,
      25                 :            :                     struct ice_sq_cd *cd)
      26                 :            : {
      27                 :            :         struct ice_aqc_lldp_get_mib *cmd;
      28                 :            :         struct ice_aq_desc desc;
      29                 :            :         int status;
      30                 :            : 
      31                 :            :         cmd = &desc.params.lldp_get_mib;
      32                 :            : 
      33         [ #  # ]:          0 :         if (buf_size == 0 || !buf)
      34                 :            :                 return ICE_ERR_PARAM;
      35                 :            : 
      36                 :          0 :         ice_fill_dflt_direct_cmd_desc(&desc, ice_aqc_opc_lldp_get_mib);
      37                 :            : 
      38                 :          0 :         cmd->type = mib_type & ICE_AQ_LLDP_MIB_TYPE_M;
      39                 :          0 :         cmd->type |= (bridge_type << ICE_AQ_LLDP_BRID_TYPE_S) &
      40                 :            :                 ICE_AQ_LLDP_BRID_TYPE_M;
      41                 :            : 
      42                 :          0 :         desc.datalen = CPU_TO_LE16(buf_size);
      43                 :            : 
      44                 :          0 :         status = ice_aq_send_cmd(hw, &desc, buf, buf_size, cd);
      45         [ #  # ]:          0 :         if (!status) {
      46         [ #  # ]:          0 :                 if (local_len)
      47                 :          0 :                         *local_len = LE16_TO_CPU(cmd->local_len);
      48         [ #  # ]:          0 :                 if (remote_len)
      49                 :          0 :                         *remote_len = LE16_TO_CPU(cmd->remote_len);
      50                 :            :         }
      51                 :            : 
      52                 :            :         return status;
      53                 :            : }
      54                 :            : 
      55                 :            : /**
      56                 :            :  * ice_aq_cfg_lldp_mib_change
      57                 :            :  * @hw: pointer to the HW struct
      58                 :            :  * @ena_update: Enable or Disable event posting
      59                 :            :  * @cd: pointer to command details structure or NULL
      60                 :            :  *
      61                 :            :  * Enable or Disable posting of an event on ARQ when LLDP MIB
      62                 :            :  * associated with the interface changes (0x0A01)
      63                 :            :  */
      64                 :            : int
      65                 :          0 : ice_aq_cfg_lldp_mib_change(struct ice_hw *hw, bool ena_update,
      66                 :            :                            struct ice_sq_cd *cd)
      67                 :            : {
      68                 :            :         struct ice_aqc_lldp_set_mib_change *cmd;
      69                 :            :         struct ice_aq_desc desc;
      70                 :            : 
      71                 :            :         cmd = &desc.params.lldp_set_event;
      72                 :            : 
      73                 :          0 :         ice_fill_dflt_direct_cmd_desc(&desc, ice_aqc_opc_lldp_set_mib_change);
      74                 :            : 
      75         [ #  # ]:          0 :         if (!ena_update)
      76                 :          0 :                 cmd->command |= ICE_AQ_LLDP_MIB_UPDATE_DIS;
      77                 :            :         else
      78                 :          0 :                 cmd->command |= ICE_AQ_LLDP_MIB_PENDING_ENABLE <<
      79                 :            :                                 ICE_AQ_LLDP_MIB_PENDING_S;
      80                 :            : 
      81                 :          0 :         return ice_aq_send_cmd(hw, &desc, NULL, 0, cd);
      82                 :            : }
      83                 :            : 
      84                 :            : /**
      85                 :            :  * ice_aq_stop_lldp
      86                 :            :  * @hw: pointer to the HW struct
      87                 :            :  * @shutdown_lldp_agent: True if LLDP Agent needs to be Shutdown
      88                 :            :  *                       False if LLDP Agent needs to be Stopped
      89                 :            :  * @persist: True if Stop/Shutdown of LLDP Agent needs to be persistent across
      90                 :            :  *           reboots
      91                 :            :  * @cd: pointer to command details structure or NULL
      92                 :            :  *
      93                 :            :  * Stop or Shutdown the embedded LLDP Agent (0x0A05)
      94                 :            :  */
      95                 :            : int
      96                 :          0 : ice_aq_stop_lldp(struct ice_hw *hw, bool shutdown_lldp_agent, bool persist,
      97                 :            :                  struct ice_sq_cd *cd)
      98                 :            : {
      99                 :            :         struct ice_aqc_lldp_stop *cmd;
     100                 :            :         struct ice_aq_desc desc;
     101                 :            : 
     102                 :            :         cmd = &desc.params.lldp_stop;
     103                 :            : 
     104                 :          0 :         ice_fill_dflt_direct_cmd_desc(&desc, ice_aqc_opc_lldp_stop);
     105                 :            : 
     106         [ #  # ]:          0 :         if (shutdown_lldp_agent)
     107                 :          0 :                 cmd->command |= ICE_AQ_LLDP_AGENT_SHUTDOWN;
     108                 :            : 
     109         [ #  # ]:          0 :         if (persist)
     110                 :          0 :                 cmd->command |= ICE_AQ_LLDP_AGENT_PERSIST_DIS;
     111                 :            : 
     112                 :          0 :         return ice_aq_send_cmd(hw, &desc, NULL, 0, cd);
     113                 :            : }
     114                 :            : 
     115                 :            : /**
     116                 :            :  * ice_aq_start_lldp
     117                 :            :  * @hw: pointer to the HW struct
     118                 :            :  * @persist: True if Start of LLDP Agent needs to be persistent across reboots
     119                 :            :  * @cd: pointer to command details structure or NULL
     120                 :            :  *
     121                 :            :  * Start the embedded LLDP Agent on all ports. (0x0A06)
     122                 :            :  */
     123                 :            : int
     124                 :          0 : ice_aq_start_lldp(struct ice_hw *hw, bool persist, struct ice_sq_cd *cd)
     125                 :            : {
     126                 :            :         struct ice_aqc_lldp_start *cmd;
     127                 :            :         struct ice_aq_desc desc;
     128                 :            : 
     129                 :            :         cmd = &desc.params.lldp_start;
     130                 :            : 
     131                 :          0 :         ice_fill_dflt_direct_cmd_desc(&desc, ice_aqc_opc_lldp_start);
     132                 :            : 
     133                 :          0 :         cmd->command = ICE_AQ_LLDP_AGENT_START;
     134                 :            : 
     135         [ #  # ]:          0 :         if (persist)
     136                 :          0 :                 cmd->command |= ICE_AQ_LLDP_AGENT_PERSIST_ENA;
     137                 :            : 
     138                 :          0 :         return ice_aq_send_cmd(hw, &desc, NULL, 0, cd);
     139                 :            : }
     140                 :            : 
     141                 :            : /**
     142                 :            :  * ice_get_dcbx_status
     143                 :            :  * @hw: pointer to the HW struct
     144                 :            :  *
     145                 :            :  * Get the DCBX status from the Firmware
     146                 :            :  */
     147                 :          0 : u8 ice_get_dcbx_status(struct ice_hw *hw)
     148                 :            : {
     149                 :            :         u32 reg;
     150                 :            : 
     151                 :          0 :         reg = rd32(hw, PRTDCB_GENS);
     152                 :          0 :         return (u8)((reg & PRTDCB_GENS_DCBX_STATUS_M) >>
     153                 :            :                     PRTDCB_GENS_DCBX_STATUS_S);
     154                 :            : }
     155                 :            : 
     156                 :            : /**
     157                 :            :  * ice_parse_ieee_ets_common_tlv
     158                 :            :  * @buf: Data buffer to be parsed for ETS CFG/REC data
     159                 :            :  * @ets_cfg: Container to store parsed data
     160                 :            :  *
     161                 :            :  * Parses the common data of IEEE 802.1Qaz ETS CFG/REC TLV
     162                 :            :  */
     163                 :            : static void
     164                 :          0 : ice_parse_ieee_ets_common_tlv(u8 *buf, struct ice_dcb_ets_cfg *ets_cfg)
     165                 :            : {
     166                 :            :         u8 offset = 0;
     167                 :            :         int i;
     168                 :            : 
     169                 :            :         /* Priority Assignment Table (4 octets)
     170                 :            :          * Octets:|    1    |    2    |    3    |    4    |
     171                 :            :          *        -----------------------------------------
     172                 :            :          *        |pri0|pri1|pri2|pri3|pri4|pri5|pri6|pri7|
     173                 :            :          *        -----------------------------------------
     174                 :            :          *   Bits:|7  4|3  0|7  4|3  0|7  4|3  0|7  4|3  0|
     175                 :            :          *        -----------------------------------------
     176                 :            :          */
     177         [ #  # ]:          0 :         for (i = 0; i < 4; i++) {
     178                 :          0 :                 ets_cfg->prio_table[i * 2] =
     179                 :          0 :                         ((buf[offset] & ICE_IEEE_ETS_PRIO_1_M) >>
     180                 :            :                          ICE_IEEE_ETS_PRIO_1_S);
     181                 :          0 :                 ets_cfg->prio_table[i * 2 + 1] =
     182                 :          0 :                         ((buf[offset] & ICE_IEEE_ETS_PRIO_0_M) >>
     183                 :            :                          ICE_IEEE_ETS_PRIO_0_S);
     184                 :          0 :                 offset++;
     185                 :            :         }
     186                 :            : 
     187                 :            :         /* TC Bandwidth Table (8 octets)
     188                 :            :          * Octets:| 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 |
     189                 :            :          *        ---------------------------------
     190                 :            :          *        |tc0|tc1|tc2|tc3|tc4|tc5|tc6|tc7|
     191                 :            :          *        ---------------------------------
     192                 :            :          *
     193                 :            :          * TSA Assignment Table (8 octets)
     194                 :            :          * Octets:| 9 | 10| 11| 12| 13| 14| 15| 16|
     195                 :            :          *        ---------------------------------
     196                 :            :          *        |tc0|tc1|tc2|tc3|tc4|tc5|tc6|tc7|
     197                 :            :          *        ---------------------------------
     198                 :            :          */
     199         [ #  # ]:          0 :         ice_for_each_traffic_class(i) {
     200                 :          0 :                 ets_cfg->tcbwtable[i] = buf[offset];
     201                 :          0 :                 ets_cfg->tsatable[i] = buf[ICE_MAX_TRAFFIC_CLASS + offset++];
     202                 :            :         }
     203                 :          0 : }
     204                 :            : 
     205                 :            : /**
     206                 :            :  * ice_parse_ieee_etscfg_tlv
     207                 :            :  * @tlv: IEEE 802.1Qaz ETS CFG TLV
     208                 :            :  * @dcbcfg: Local store to update ETS CFG data
     209                 :            :  *
     210                 :            :  * Parses IEEE 802.1Qaz ETS CFG TLV
     211                 :            :  */
     212                 :            : static void
     213                 :            : ice_parse_ieee_etscfg_tlv(struct ice_lldp_org_tlv *tlv,
     214                 :            :                           struct ice_dcbx_cfg *dcbcfg)
     215                 :            : {
     216                 :            :         struct ice_dcb_ets_cfg *etscfg;
     217                 :            :         u8 *buf = tlv->tlvinfo;
     218                 :            : 
     219                 :            :         /* First Octet post subtype
     220                 :            :          * --------------------------
     221                 :            :          * |will-|CBS  | Re-  | Max |
     222                 :            :          * |ing  |     |served| TCs |
     223                 :            :          * --------------------------
     224                 :            :          * |1bit | 1bit|3 bits|3bits|
     225                 :            :          */
     226                 :          0 :         etscfg = &dcbcfg->etscfg;
     227                 :          0 :         etscfg->willing = ((buf[0] & ICE_IEEE_ETS_WILLING_M) >>
     228                 :            :                            ICE_IEEE_ETS_WILLING_S);
     229                 :          0 :         etscfg->cbs = ((buf[0] & ICE_IEEE_ETS_CBS_M) >> ICE_IEEE_ETS_CBS_S);
     230                 :          0 :         etscfg->maxtcs = ((buf[0] & ICE_IEEE_ETS_MAXTC_M) >>
     231                 :            :                           ICE_IEEE_ETS_MAXTC_S);
     232                 :            : 
     233                 :            :         /* Begin parsing at Priority Assignment Table (offset 1 in buf) */
     234                 :          0 :         ice_parse_ieee_ets_common_tlv(&buf[1], etscfg);
     235                 :          0 : }
     236                 :            : 
     237                 :            : /**
     238                 :            :  * ice_parse_ieee_etsrec_tlv
     239                 :            :  * @tlv: IEEE 802.1Qaz ETS REC TLV
     240                 :            :  * @dcbcfg: Local store to update ETS REC data
     241                 :            :  *
     242                 :            :  * Parses IEEE 802.1Qaz ETS REC TLV
     243                 :            :  */
     244                 :            : static void
     245                 :            : ice_parse_ieee_etsrec_tlv(struct ice_lldp_org_tlv *tlv,
     246                 :            :                           struct ice_dcbx_cfg *dcbcfg)
     247                 :            : {
     248                 :            :         u8 *buf = tlv->tlvinfo;
     249                 :            : 
     250                 :            :         /* Begin parsing at Priority Assignment Table (offset 1 in buf) */
     251                 :          0 :         ice_parse_ieee_ets_common_tlv(&buf[1], &dcbcfg->etsrec);
     252                 :          0 : }
     253                 :            : 
     254                 :            : /**
     255                 :            :  * ice_parse_ieee_pfccfg_tlv
     256                 :            :  * @tlv: IEEE 802.1Qaz PFC CFG TLV
     257                 :            :  * @dcbcfg: Local store to update PFC CFG data
     258                 :            :  *
     259                 :            :  * Parses IEEE 802.1Qaz PFC CFG TLV
     260                 :            :  */
     261                 :            : static void
     262                 :            : ice_parse_ieee_pfccfg_tlv(struct ice_lldp_org_tlv *tlv,
     263                 :            :                           struct ice_dcbx_cfg *dcbcfg)
     264                 :            : {
     265                 :            :         u8 *buf = tlv->tlvinfo;
     266                 :            : 
     267                 :            :         /* ----------------------------------------
     268                 :            :          * |will-|MBC  | Re-  | PFC |  PFC Enable  |
     269                 :            :          * |ing  |     |served| cap |              |
     270                 :            :          * -----------------------------------------
     271                 :            :          * |1bit | 1bit|2 bits|4bits| 1 octet      |
     272                 :            :          */
     273                 :          0 :         dcbcfg->pfc.willing = ((buf[0] & ICE_IEEE_PFC_WILLING_M) >>
     274                 :            :                                ICE_IEEE_PFC_WILLING_S);
     275                 :          0 :         dcbcfg->pfc.mbc = ((buf[0] & ICE_IEEE_PFC_MBC_M) >> ICE_IEEE_PFC_MBC_S);
     276                 :          0 :         dcbcfg->pfc.pfccap = ((buf[0] & ICE_IEEE_PFC_CAP_M) >>
     277                 :            :                               ICE_IEEE_PFC_CAP_S);
     278                 :          0 :         dcbcfg->pfc.pfcena = buf[1];
     279                 :          0 : }
     280                 :            : 
     281                 :            : /**
     282                 :            :  * ice_parse_ieee_app_tlv
     283                 :            :  * @tlv: IEEE 802.1Qaz APP TLV
     284                 :            :  * @dcbcfg: Local store to update APP PRIO data
     285                 :            :  *
     286                 :            :  * Parses IEEE 802.1Qaz APP PRIO TLV
     287                 :            :  */
     288                 :            : static void
     289                 :          0 : ice_parse_ieee_app_tlv(struct ice_lldp_org_tlv *tlv,
     290                 :            :                        struct ice_dcbx_cfg *dcbcfg)
     291                 :            : {
     292                 :            :         u16 offset = 0;
     293                 :            :         u16 typelen;
     294                 :            :         int i = 0;
     295                 :            :         u16 len;
     296                 :            :         u8 *buf;
     297                 :            : 
     298         [ #  # ]:          0 :         typelen = NTOHS(tlv->typelen);
     299                 :          0 :         len = ((typelen & ICE_LLDP_TLV_LEN_M) >> ICE_LLDP_TLV_LEN_S);
     300                 :          0 :         buf = tlv->tlvinfo;
     301                 :            : 
     302                 :            :         /* Removing sizeof(ouisubtype) and reserved byte from len.
     303                 :            :          * Remaining len div 3 is number of APP TLVs.
     304                 :            :          */
     305                 :          0 :         len -= (sizeof(tlv->ouisubtype) + 1);
     306                 :            : 
     307                 :            :         /* Move offset to App Priority Table */
     308                 :            :         offset++;
     309                 :            : 
     310                 :            :         /* Application Priority Table (3 octets)
     311                 :            :          * Octets:|         1          |    2    |    3    |
     312                 :            :          *        -----------------------------------------
     313                 :            :          *        |Priority|Rsrvd| Sel |    Protocol ID    |
     314                 :            :          *        -----------------------------------------
     315                 :            :          *   Bits:|23    21|20 19|18 16|15                0|
     316                 :            :          *        -----------------------------------------
     317                 :            :          */
     318         [ #  # ]:          0 :         while (offset < len) {
     319                 :          0 :                 dcbcfg->app[i].priority = ((buf[offset] &
     320                 :          0 :                                             ICE_IEEE_APP_PRIO_M) >>
     321                 :            :                                            ICE_IEEE_APP_PRIO_S);
     322                 :          0 :                 dcbcfg->app[i].selector = ((buf[offset] &
     323                 :          0 :                                             ICE_IEEE_APP_SEL_M) >>
     324                 :            :                                            ICE_IEEE_APP_SEL_S);
     325                 :          0 :                 dcbcfg->app[i].prot_id = (buf[offset + 1] << 0x8) |
     326                 :          0 :                         buf[offset + 2];
     327                 :            :                 /* Move to next app */
     328                 :          0 :                 offset += 3;
     329                 :          0 :                 i++;
     330         [ #  # ]:          0 :                 if (i >= ICE_DCBX_MAX_APPS)
     331                 :            :                         break;
     332                 :            :         }
     333                 :            : 
     334                 :          0 :         dcbcfg->numapps = i;
     335                 :          0 : }
     336                 :            : 
     337                 :            : /**
     338                 :            :  * ice_parse_ieee_tlv
     339                 :            :  * @tlv: IEEE 802.1Qaz TLV
     340                 :            :  * @dcbcfg: Local store to update ETS REC data
     341                 :            :  *
     342                 :            :  * Get the TLV subtype and send it to parsing function
     343                 :            :  * based on the subtype value
     344                 :            :  */
     345                 :            : static void
     346                 :          0 : ice_parse_ieee_tlv(struct ice_lldp_org_tlv *tlv, struct ice_dcbx_cfg *dcbcfg)
     347                 :            : {
     348                 :            :         u32 ouisubtype;
     349                 :            :         u8 subtype;
     350                 :            : 
     351         [ #  # ]:          0 :         ouisubtype = NTOHL(tlv->ouisubtype);
     352                 :            :         subtype = (u8)((ouisubtype & ICE_LLDP_TLV_SUBTYPE_M) >>
     353                 :            :                        ICE_LLDP_TLV_SUBTYPE_S);
     354   [ #  #  #  #  :          0 :         switch (subtype) {
                      # ]
     355                 :            :         case ICE_IEEE_SUBTYPE_ETS_CFG:
     356                 :            :                 ice_parse_ieee_etscfg_tlv(tlv, dcbcfg);
     357                 :            :                 break;
     358                 :            :         case ICE_IEEE_SUBTYPE_ETS_REC:
     359                 :            :                 ice_parse_ieee_etsrec_tlv(tlv, dcbcfg);
     360                 :            :                 break;
     361                 :            :         case ICE_IEEE_SUBTYPE_PFC_CFG:
     362                 :            :                 ice_parse_ieee_pfccfg_tlv(tlv, dcbcfg);
     363                 :            :                 break;
     364                 :          0 :         case ICE_IEEE_SUBTYPE_APP_PRI:
     365                 :          0 :                 ice_parse_ieee_app_tlv(tlv, dcbcfg);
     366                 :          0 :                 break;
     367                 :            :         default:
     368                 :            :                 break;
     369                 :            :         }
     370                 :          0 : }
     371                 :            : 
     372                 :            : /**
     373                 :            :  * ice_parse_cee_pgcfg_tlv
     374                 :            :  * @tlv: CEE DCBX PG CFG TLV
     375                 :            :  * @dcbcfg: Local store to update ETS CFG data
     376                 :            :  *
     377                 :            :  * Parses CEE DCBX PG CFG TLV
     378                 :            :  */
     379                 :            : static void
     380                 :          0 : ice_parse_cee_pgcfg_tlv(struct ice_cee_feat_tlv *tlv,
     381                 :            :                         struct ice_dcbx_cfg *dcbcfg)
     382                 :            : {
     383                 :            :         struct ice_dcb_ets_cfg *etscfg;
     384                 :          0 :         u8 *buf = tlv->tlvinfo;
     385                 :            :         u16 offset = 0;
     386                 :            :         int i;
     387                 :            : 
     388                 :            :         etscfg = &dcbcfg->etscfg;
     389                 :            : 
     390         [ #  # ]:          0 :         if (tlv->en_will_err & ICE_CEE_FEAT_TLV_WILLING_M)
     391                 :          0 :                 etscfg->willing = 1;
     392                 :            : 
     393                 :          0 :         etscfg->cbs = 0;
     394                 :            :         /* Priority Group Table (4 octets)
     395                 :            :          * Octets:|    1    |    2    |    3    |    4    |
     396                 :            :          *        -----------------------------------------
     397                 :            :          *        |pri0|pri1|pri2|pri3|pri4|pri5|pri6|pri7|
     398                 :            :          *        -----------------------------------------
     399                 :            :          *   Bits:|7  4|3  0|7  4|3  0|7  4|3  0|7  4|3  0|
     400                 :            :          *        -----------------------------------------
     401                 :            :          */
     402         [ #  # ]:          0 :         for (i = 0; i < 4; i++) {
     403                 :          0 :                 etscfg->prio_table[i * 2] =
     404                 :          0 :                         ((buf[offset] & ICE_CEE_PGID_PRIO_1_M) >>
     405                 :            :                          ICE_CEE_PGID_PRIO_1_S);
     406                 :          0 :                 etscfg->prio_table[i * 2 + 1] =
     407                 :          0 :                         ((buf[offset] & ICE_CEE_PGID_PRIO_0_M) >>
     408                 :            :                          ICE_CEE_PGID_PRIO_0_S);
     409                 :          0 :                 offset++;
     410                 :            :         }
     411                 :            : 
     412                 :            :         /* PG Percentage Table (8 octets)
     413                 :            :          * Octets:| 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 |
     414                 :            :          *        ---------------------------------
     415                 :            :          *        |pg0|pg1|pg2|pg3|pg4|pg5|pg6|pg7|
     416                 :            :          *        ---------------------------------
     417                 :            :          */
     418         [ #  # ]:          0 :         ice_for_each_traffic_class(i) {
     419                 :          0 :                 etscfg->tcbwtable[i] = buf[offset++];
     420                 :            : 
     421         [ #  # ]:          0 :                 if (etscfg->prio_table[i] == ICE_CEE_PGID_STRICT)
     422                 :          0 :                         dcbcfg->etscfg.tsatable[i] = ICE_IEEE_TSA_STRICT;
     423                 :            :                 else
     424                 :          0 :                         dcbcfg->etscfg.tsatable[i] = ICE_IEEE_TSA_ETS;
     425                 :            :         }
     426                 :            : 
     427                 :            :         /* Number of TCs supported (1 octet) */
     428                 :          0 :         etscfg->maxtcs = buf[offset];
     429                 :          0 : }
     430                 :            : 
     431                 :            : /**
     432                 :            :  * ice_parse_cee_pfccfg_tlv
     433                 :            :  * @tlv: CEE DCBX PFC CFG TLV
     434                 :            :  * @dcbcfg: Local store to update PFC CFG data
     435                 :            :  *
     436                 :            :  * Parses CEE DCBX PFC CFG TLV
     437                 :            :  */
     438                 :            : static void
     439                 :            : ice_parse_cee_pfccfg_tlv(struct ice_cee_feat_tlv *tlv,
     440                 :            :                          struct ice_dcbx_cfg *dcbcfg)
     441                 :            : {
     442                 :            :         u8 *buf = tlv->tlvinfo;
     443                 :            : 
     444         [ #  # ]:          0 :         if (tlv->en_will_err & ICE_CEE_FEAT_TLV_WILLING_M)
     445                 :          0 :                 dcbcfg->pfc.willing = 1;
     446                 :            : 
     447                 :            :         /* ------------------------
     448                 :            :          * | PFC Enable | PFC TCs |
     449                 :            :          * ------------------------
     450                 :            :          * | 1 octet    | 1 octet |
     451                 :            :          */
     452                 :          0 :         dcbcfg->pfc.pfcena = buf[0];
     453                 :          0 :         dcbcfg->pfc.pfccap = buf[1];
     454                 :          0 : }
     455                 :            : 
     456                 :            : /**
     457                 :            :  * ice_parse_cee_app_tlv
     458                 :            :  * @tlv: CEE DCBX APP TLV
     459                 :            :  * @dcbcfg: Local store to update APP PRIO data
     460                 :            :  *
     461                 :            :  * Parses CEE DCBX APP PRIO TLV
     462                 :            :  */
     463                 :            : static void
     464                 :          0 : ice_parse_cee_app_tlv(struct ice_cee_feat_tlv *tlv, struct ice_dcbx_cfg *dcbcfg)
     465                 :            : {
     466                 :            :         u16 len, typelen, offset = 0;
     467                 :            :         struct ice_cee_app_prio *app;
     468                 :            :         u8 i;
     469                 :            : 
     470         [ #  # ]:          0 :         typelen = NTOHS(tlv->hdr.typelen);
     471                 :          0 :         len = ((typelen & ICE_LLDP_TLV_LEN_M) >> ICE_LLDP_TLV_LEN_S);
     472                 :            : 
     473                 :          0 :         dcbcfg->numapps = len / sizeof(*app);
     474         [ #  # ]:          0 :         if (!dcbcfg->numapps)
     475                 :            :                 return;
     476         [ #  # ]:          0 :         if (dcbcfg->numapps > ICE_DCBX_MAX_APPS)
     477                 :          0 :                 dcbcfg->numapps = ICE_DCBX_MAX_APPS;
     478                 :            : 
     479         [ #  # ]:          0 :         for (i = 0; i < dcbcfg->numapps; i++) {
     480                 :            :                 u8 up, selector;
     481                 :            : 
     482                 :          0 :                 app = (struct ice_cee_app_prio *)(tlv->tlvinfo + offset);
     483         [ #  # ]:          0 :                 for (up = 0; up < ICE_MAX_USER_PRIORITY; up++)
     484         [ #  # ]:          0 :                         if (app->prio_map & BIT(up))
     485                 :            :                                 break;
     486                 :            : 
     487                 :          0 :                 dcbcfg->app[i].priority = up;
     488                 :            : 
     489                 :            :                 /* Get Selector from lower 2 bits, and convert to IEEE */
     490                 :          0 :                 selector = (app->upper_oui_sel & ICE_CEE_APP_SELECTOR_M);
     491      [ #  #  # ]:          0 :                 switch (selector) {
     492                 :          0 :                 case ICE_CEE_APP_SEL_ETHTYPE:
     493                 :          0 :                         dcbcfg->app[i].selector = ICE_APP_SEL_ETHTYPE;
     494                 :          0 :                         break;
     495                 :          0 :                 case ICE_CEE_APP_SEL_TCPIP:
     496                 :          0 :                         dcbcfg->app[i].selector = ICE_APP_SEL_TCPIP;
     497                 :          0 :                         break;
     498                 :          0 :                 default:
     499                 :            :                         /* Keep selector as it is for unknown types */
     500                 :          0 :                         dcbcfg->app[i].selector = selector;
     501                 :            :                 }
     502                 :            : 
     503         [ #  # ]:          0 :                 dcbcfg->app[i].prot_id = NTOHS(app->protocol);
     504                 :            :                 /* Move to next app */
     505                 :          0 :                 offset += sizeof(*app);
     506                 :            :         }
     507                 :            : }
     508                 :            : 
     509                 :            : /**
     510                 :            :  * ice_parse_cee_tlv
     511                 :            :  * @tlv: CEE DCBX TLV
     512                 :            :  * @dcbcfg: Local store to update DCBX config data
     513                 :            :  *
     514                 :            :  * Get the TLV subtype and send it to parsing function
     515                 :            :  * based on the subtype value
     516                 :            :  */
     517                 :            : static void
     518                 :          0 : ice_parse_cee_tlv(struct ice_lldp_org_tlv *tlv, struct ice_dcbx_cfg *dcbcfg)
     519                 :            : {
     520                 :            :         struct ice_cee_feat_tlv *sub_tlv;
     521                 :            :         u8 subtype, feat_tlv_count = 0;
     522                 :            :         u16 len, tlvlen, typelen;
     523                 :            :         u32 ouisubtype;
     524                 :            : 
     525         [ #  # ]:          0 :         ouisubtype = NTOHL(tlv->ouisubtype);
     526                 :          0 :         subtype = (u8)((ouisubtype & ICE_LLDP_TLV_SUBTYPE_M) >>
     527                 :            :                        ICE_LLDP_TLV_SUBTYPE_S);
     528                 :            :         /* Return if not CEE DCBX */
     529         [ #  # ]:          0 :         if (subtype != ICE_CEE_DCBX_TYPE)
     530                 :            :                 return;
     531                 :            : 
     532         [ #  # ]:          0 :         typelen = NTOHS(tlv->typelen);
     533                 :          0 :         tlvlen = ((typelen & ICE_LLDP_TLV_LEN_M) >> ICE_LLDP_TLV_LEN_S);
     534                 :            :         len = sizeof(tlv->typelen) + sizeof(ouisubtype) +
     535                 :            :                 sizeof(struct ice_cee_ctrl_tlv);
     536                 :            :         /* Return if no CEE DCBX Feature TLVs */
     537         [ #  # ]:          0 :         if (tlvlen <= len)
     538                 :            :                 return;
     539                 :            : 
     540                 :          0 :         sub_tlv = (struct ice_cee_feat_tlv *)((char *)tlv + len);
     541         [ #  # ]:          0 :         while (feat_tlv_count < ICE_CEE_MAX_FEAT_TYPE) {
     542                 :            :                 u16 sublen;
     543                 :            : 
     544         [ #  # ]:          0 :                 typelen = NTOHS(sub_tlv->hdr.typelen);
     545                 :          0 :                 sublen = ((typelen & ICE_LLDP_TLV_LEN_M) >> ICE_LLDP_TLV_LEN_S);
     546                 :          0 :                 subtype = (u8)((typelen & ICE_LLDP_TLV_TYPE_M) >>
     547                 :            :                                ICE_LLDP_TLV_TYPE_S);
     548   [ #  #  #  # ]:          0 :                 switch (subtype) {
     549                 :          0 :                 case ICE_CEE_SUBTYPE_PG_CFG:
     550                 :          0 :                         ice_parse_cee_pgcfg_tlv(sub_tlv, dcbcfg);
     551                 :          0 :                         break;
     552                 :            :                 case ICE_CEE_SUBTYPE_PFC_CFG:
     553                 :            :                         ice_parse_cee_pfccfg_tlv(sub_tlv, dcbcfg);
     554                 :            :                         break;
     555                 :          0 :                 case ICE_CEE_SUBTYPE_APP_PRI:
     556                 :          0 :                         ice_parse_cee_app_tlv(sub_tlv, dcbcfg);
     557                 :          0 :                         break;
     558                 :            :                 default:
     559                 :            :                         return; /* Invalid Sub-type return */
     560                 :            :                 }
     561                 :          0 :                 feat_tlv_count++;
     562                 :            :                 /* Move to next sub TLV */
     563                 :          0 :                 sub_tlv = (struct ice_cee_feat_tlv *)
     564                 :          0 :                           ((char *)sub_tlv + sizeof(sub_tlv->hdr.typelen) +
     565                 :            :                            sublen);
     566                 :            :         }
     567                 :            : }
     568                 :            : 
     569                 :            : /**
     570                 :            :  * ice_parse_org_tlv
     571                 :            :  * @tlv: Organization specific TLV
     572                 :            :  * @dcbcfg: Local store to update ETS REC data
     573                 :            :  *
     574                 :            :  * Currently only IEEE 802.1Qaz TLV is supported, all others
     575                 :            :  * will be returned
     576                 :            :  */
     577                 :            : static void
     578                 :          0 : ice_parse_org_tlv(struct ice_lldp_org_tlv *tlv, struct ice_dcbx_cfg *dcbcfg)
     579                 :            : {
     580                 :            :         u32 ouisubtype;
     581                 :            :         u32 oui;
     582                 :            : 
     583         [ #  # ]:          0 :         ouisubtype = NTOHL(tlv->ouisubtype);
     584                 :          0 :         oui = ((ouisubtype & ICE_LLDP_TLV_OUI_M) >> ICE_LLDP_TLV_OUI_S);
     585      [ #  #  # ]:          0 :         switch (oui) {
     586                 :          0 :         case ICE_IEEE_8021QAZ_OUI:
     587                 :          0 :                 ice_parse_ieee_tlv(tlv, dcbcfg);
     588                 :          0 :                 break;
     589                 :          0 :         case ICE_CEE_DCBX_OUI:
     590                 :          0 :                 ice_parse_cee_tlv(tlv, dcbcfg);
     591                 :          0 :                 break;
     592                 :            :         default:
     593                 :            :                 break;
     594                 :            :         }
     595                 :          0 : }
     596                 :            : 
     597                 :            : /**
     598                 :            :  * ice_lldp_to_dcb_cfg
     599                 :            :  * @lldpmib: LLDPDU to be parsed
     600                 :            :  * @dcbcfg: store for LLDPDU data
     601                 :            :  *
     602                 :            :  * Parse DCB configuration from the LLDPDU
     603                 :            :  */
     604                 :          0 : int ice_lldp_to_dcb_cfg(u8 *lldpmib, struct ice_dcbx_cfg *dcbcfg)
     605                 :            : {
     606                 :            :         struct ice_lldp_org_tlv *tlv;
     607                 :            :         u16 offset = 0;
     608                 :            :         int ret = 0;
     609                 :            :         u16 typelen;
     610                 :            :         u16 type;
     611                 :            :         u16 len;
     612                 :            : 
     613         [ #  # ]:          0 :         if (!lldpmib || !dcbcfg)
     614                 :            :                 return ICE_ERR_PARAM;
     615                 :            : 
     616                 :            :         /* set to the start of LLDPDU */
     617                 :          0 :         lldpmib += ETH_HEADER_LEN;
     618                 :            :         tlv = (struct ice_lldp_org_tlv *)lldpmib;
     619                 :            :         while (1) {
     620         [ #  # ]:          0 :                 typelen = NTOHS(tlv->typelen);
     621                 :          0 :                 type = ((typelen & ICE_LLDP_TLV_TYPE_M) >> ICE_LLDP_TLV_TYPE_S);
     622                 :          0 :                 len = ((typelen & ICE_LLDP_TLV_LEN_M) >> ICE_LLDP_TLV_LEN_S);
     623                 :          0 :                 offset += sizeof(typelen) + len;
     624                 :            : 
     625                 :            :                 /* END TLV or beyond LLDPDU size */
     626         [ #  # ]:          0 :                 if (type == ICE_TLV_TYPE_END || offset > ICE_LLDPDU_SIZE)
     627                 :            :                         break;
     628                 :            : 
     629         [ #  # ]:          0 :                 switch (type) {
     630                 :          0 :                 case ICE_TLV_TYPE_ORG:
     631                 :          0 :                         ice_parse_org_tlv(tlv, dcbcfg);
     632                 :          0 :                         break;
     633                 :            :                 default:
     634                 :            :                         break;
     635                 :            :                 }
     636                 :            : 
     637                 :            :                 /* Move to next TLV */
     638                 :          0 :                 tlv = (struct ice_lldp_org_tlv *)
     639                 :          0 :                       ((char *)tlv + sizeof(tlv->typelen) + len);
     640                 :            :         }
     641                 :            : 
     642                 :            :         return ret;
     643                 :            : }
     644                 :            : 
     645                 :            : /**
     646                 :            :  * ice_aq_get_dcb_cfg
     647                 :            :  * @hw: pointer to the HW struct
     648                 :            :  * @mib_type: MIB type for the query
     649                 :            :  * @bridgetype: bridge type for the query (remote)
     650                 :            :  * @dcbcfg: store for LLDPDU data
     651                 :            :  *
     652                 :            :  * Query DCB configuration from the firmware
     653                 :            :  */
     654                 :            : int
     655                 :          0 : ice_aq_get_dcb_cfg(struct ice_hw *hw, u8 mib_type, u8 bridgetype,
     656                 :            :                    struct ice_dcbx_cfg *dcbcfg)
     657                 :            : {
     658                 :            :         u8 *lldpmib;
     659                 :            :         int ret;
     660                 :            : 
     661                 :            :         /* Allocate the LLDPDU */
     662                 :          0 :         lldpmib = (u8 *)ice_malloc(hw, ICE_LLDPDU_SIZE);
     663         [ #  # ]:          0 :         if (!lldpmib)
     664                 :            :                 return ICE_ERR_NO_MEMORY;
     665                 :            : 
     666                 :          0 :         ret = ice_aq_get_lldp_mib(hw, bridgetype, mib_type, (void *)lldpmib,
     667                 :            :                                   ICE_LLDPDU_SIZE, NULL, NULL, NULL);
     668                 :            : 
     669         [ #  # ]:          0 :         if (!ret)
     670                 :            :                 /* Parse LLDP MIB to get DCB configuration */
     671                 :          0 :                 ret = ice_lldp_to_dcb_cfg(lldpmib, dcbcfg);
     672                 :            : 
     673                 :          0 :         ice_free(hw, lldpmib);
     674                 :            : 
     675                 :          0 :         return ret;
     676                 :            : }
     677                 :            : 
     678                 :            : /**
     679                 :            :  * ice_aq_start_stop_dcbx - Start/Stop DCBX service in FW
     680                 :            :  * @hw: pointer to the HW struct
     681                 :            :  * @start_dcbx_agent: True if DCBX Agent needs to be started
     682                 :            :  *                    False if DCBX Agent needs to be stopped
     683                 :            :  * @dcbx_agent_status: FW indicates back the DCBX agent status
     684                 :            :  *                     True if DCBX Agent is active
     685                 :            :  *                     False if DCBX Agent is stopped
     686                 :            :  * @cd: pointer to command details structure or NULL
     687                 :            :  *
     688                 :            :  * Start/Stop the embedded dcbx Agent. In case that this wrapper function
     689                 :            :  * returns 0, caller will need to check if FW returns back the same
     690                 :            :  * value as stated in dcbx_agent_status, and react accordingly. (0x0A09)
     691                 :            :  */
     692                 :            : int
     693                 :          0 : ice_aq_start_stop_dcbx(struct ice_hw *hw, bool start_dcbx_agent,
     694                 :            :                        bool *dcbx_agent_status, struct ice_sq_cd *cd)
     695                 :            : {
     696                 :            :         struct ice_aqc_lldp_stop_start_specific_agent *cmd;
     697                 :            :         enum ice_adminq_opc opcode;
     698                 :            :         struct ice_aq_desc desc;
     699                 :            :         int status;
     700                 :            : 
     701                 :            :         cmd = &desc.params.lldp_agent_ctrl;
     702                 :            : 
     703                 :            :         opcode = ice_aqc_opc_lldp_stop_start_specific_agent;
     704                 :            : 
     705                 :          0 :         ice_fill_dflt_direct_cmd_desc(&desc, opcode);
     706                 :            : 
     707         [ #  # ]:          0 :         if (start_dcbx_agent)
     708                 :          0 :                 cmd->command = ICE_AQC_START_STOP_AGENT_START_DCBX;
     709                 :            : 
     710                 :          0 :         status = ice_aq_send_cmd(hw, &desc, NULL, 0, cd);
     711                 :            : 
     712                 :          0 :         *dcbx_agent_status = false;
     713                 :            : 
     714         [ #  # ]:          0 :         if (!status &&
     715         [ #  # ]:          0 :             cmd->command == ICE_AQC_START_STOP_AGENT_START_DCBX)
     716                 :          0 :                 *dcbx_agent_status = true;
     717                 :            : 
     718                 :          0 :         return status;
     719                 :            : }
     720                 :            : 
     721                 :            : /**
     722                 :            :  * ice_aq_get_cee_dcb_cfg
     723                 :            :  * @hw: pointer to the HW struct
     724                 :            :  * @buff: response buffer that stores CEE operational configuration
     725                 :            :  * @cd: pointer to command details structure or NULL
     726                 :            :  *
     727                 :            :  * Get CEE DCBX mode operational configuration from firmware (0x0A07)
     728                 :            :  */
     729                 :            : int
     730                 :          0 : ice_aq_get_cee_dcb_cfg(struct ice_hw *hw,
     731                 :            :                        struct ice_aqc_get_cee_dcb_cfg_resp *buff,
     732                 :            :                        struct ice_sq_cd *cd)
     733                 :            : {
     734                 :            :         struct ice_aq_desc desc;
     735                 :            : 
     736                 :          0 :         ice_fill_dflt_direct_cmd_desc(&desc, ice_aqc_opc_get_cee_dcb_cfg);
     737                 :            : 
     738                 :          0 :         return ice_aq_send_cmd(hw, &desc, (void *)buff, sizeof(*buff), cd);
     739                 :            : }
     740                 :            : 
     741                 :            : /**
     742                 :            :  * ice_aq_set_pfc_mode - Set PFC mode
     743                 :            :  * @hw: pointer to the HW struct
     744                 :            :  * @pfc_mode: value of PFC mode to set
     745                 :            :  * @cd: pointer to command details structure or NULL
     746                 :            :  *
     747                 :            :  * This AQ call configures the PFC mdoe to DSCP-based PFC mode or VLAN
     748                 :            :  * -based PFC (0x0303)
     749                 :            :  */
     750                 :            : int
     751                 :          0 : ice_aq_set_pfc_mode(struct ice_hw *hw, u8 pfc_mode, struct ice_sq_cd *cd)
     752                 :            : {
     753                 :            :         struct ice_aqc_set_query_pfc_mode *cmd;
     754                 :            :         struct ice_aq_desc desc;
     755                 :            :         int status;
     756                 :            : 
     757         [ #  # ]:          0 :         if (pfc_mode > ICE_AQC_PFC_DSCP_BASED_PFC)
     758                 :            :                 return ICE_ERR_PARAM;
     759                 :            : 
     760                 :            :         cmd = &desc.params.set_query_pfc_mode;
     761                 :            : 
     762                 :          0 :         ice_fill_dflt_direct_cmd_desc(&desc, ice_aqc_opc_set_pfc_mode);
     763                 :            : 
     764                 :          0 :         cmd->pfc_mode = pfc_mode;
     765                 :            : 
     766                 :          0 :         status = ice_aq_send_cmd(hw, &desc, NULL, 0, cd);
     767         [ #  # ]:          0 :         if (status)
     768                 :            :                 return status;
     769                 :            : 
     770                 :            :         /* FW will write the PFC mode set back into cmd->pfc_mode, but if DCB is
     771                 :            :          * disabled, FW will write back 0 to cmd->pfc_mode. After the AQ has
     772                 :            :          * been executed, check if cmd->pfc_mode is what was requested. If not,
     773                 :            :          * return an error.
     774                 :            :          */
     775         [ #  # ]:          0 :         if (cmd->pfc_mode != pfc_mode)
     776                 :          0 :                 return ICE_ERR_NOT_SUPPORTED;
     777                 :            : 
     778                 :            :         return 0;
     779                 :            : }
     780                 :            : 
     781                 :            : /**
     782                 :            :  * ice_cee_to_dcb_cfg
     783                 :            :  * @cee_cfg: pointer to CEE configuration struct
     784                 :            :  * @pi: port information structure
     785                 :            :  *
     786                 :            :  * Convert CEE configuration from firmware to DCB configuration
     787                 :            :  */
     788                 :            : static void
     789                 :          0 : ice_cee_to_dcb_cfg(struct ice_aqc_get_cee_dcb_cfg_resp *cee_cfg,
     790                 :            :                    struct ice_port_info *pi)
     791                 :            : {
     792                 :          0 :         u32 status, tlv_status = LE32_TO_CPU(cee_cfg->tlv_status);
     793                 :            :         u32 ice_aqc_cee_status_mask, ice_aqc_cee_status_shift;
     794                 :            :         u8 i, j, err, sync, oper, app_index, ice_app_sel_type;
     795                 :          0 :         u16 app_prio = LE16_TO_CPU(cee_cfg->oper_app_prio);
     796                 :            :         u16 ice_aqc_cee_app_mask, ice_aqc_cee_app_shift;
     797                 :            :         struct ice_dcbx_cfg *cmp_dcbcfg, *dcbcfg;
     798                 :            :         u16 ice_app_prot_id_type;
     799                 :            : 
     800                 :            :         dcbcfg = &pi->qos_cfg.local_dcbx_cfg;
     801                 :          0 :         dcbcfg->dcbx_mode = ICE_DCBX_MODE_CEE;
     802                 :          0 :         dcbcfg->tlv_status = tlv_status;
     803                 :            : 
     804                 :            :         /* CEE PG data */
     805                 :          0 :         dcbcfg->etscfg.maxtcs = cee_cfg->oper_num_tc;
     806                 :            : 
     807                 :            :         /* Note that the FW creates the oper_prio_tc nibbles reversed
     808                 :            :          * from those in the CEE Priority Group sub-TLV.
     809                 :            :          */
     810         [ #  # ]:          0 :         for (i = 0; i < ICE_MAX_TRAFFIC_CLASS / 2; i++) {
     811                 :          0 :                 dcbcfg->etscfg.prio_table[i * 2] =
     812                 :          0 :                         ((cee_cfg->oper_prio_tc[i] & ICE_CEE_PGID_PRIO_0_M) >>
     813                 :            :                          ICE_CEE_PGID_PRIO_0_S);
     814                 :          0 :                 dcbcfg->etscfg.prio_table[i * 2 + 1] =
     815                 :          0 :                         ((cee_cfg->oper_prio_tc[i] & ICE_CEE_PGID_PRIO_1_M) >>
     816                 :            :                          ICE_CEE_PGID_PRIO_1_S);
     817                 :            :         }
     818                 :            : 
     819         [ #  # ]:          0 :         ice_for_each_traffic_class(i) {
     820                 :          0 :                 dcbcfg->etscfg.tcbwtable[i] = cee_cfg->oper_tc_bw[i];
     821                 :            : 
     822         [ #  # ]:          0 :                 if (dcbcfg->etscfg.prio_table[i] == ICE_CEE_PGID_STRICT) {
     823                 :            :                         /* Map it to next empty TC */
     824                 :          0 :                         dcbcfg->etscfg.prio_table[i] = cee_cfg->oper_num_tc - 1;
     825                 :          0 :                         dcbcfg->etscfg.tsatable[i] = ICE_IEEE_TSA_STRICT;
     826                 :            :                 } else {
     827                 :          0 :                         dcbcfg->etscfg.tsatable[i] = ICE_IEEE_TSA_ETS;
     828                 :            :                 }
     829                 :            :         }
     830                 :            : 
     831                 :            :         /* CEE PFC data */
     832                 :          0 :         dcbcfg->pfc.pfcena = cee_cfg->oper_pfc_en;
     833                 :          0 :         dcbcfg->pfc.pfccap = ICE_MAX_TRAFFIC_CLASS;
     834                 :            : 
     835                 :            :         /* CEE APP TLV data */
     836         [ #  # ]:          0 :         if (dcbcfg->app_mode == ICE_DCBX_APPS_NON_WILLING)
     837                 :          0 :                 cmp_dcbcfg = &pi->qos_cfg.desired_dcbx_cfg;
     838                 :            :         else
     839                 :          0 :                 cmp_dcbcfg = &pi->qos_cfg.remote_dcbx_cfg;
     840                 :            : 
     841                 :            :         app_index = 0;
     842         [ #  # ]:          0 :         for (i = 0; i < 3; i++) {
     843         [ #  # ]:          0 :                 if (i == 0) {
     844                 :            :                         /* FCoE APP */
     845                 :            :                         ice_aqc_cee_status_mask = ICE_AQC_CEE_FCOE_STATUS_M;
     846                 :            :                         ice_aqc_cee_status_shift = ICE_AQC_CEE_FCOE_STATUS_S;
     847                 :            :                         ice_aqc_cee_app_mask = ICE_AQC_CEE_APP_FCOE_M;
     848                 :            :                         ice_aqc_cee_app_shift = ICE_AQC_CEE_APP_FCOE_S;
     849                 :            :                         ice_app_sel_type = ICE_APP_SEL_ETHTYPE;
     850                 :            :                         ice_app_prot_id_type = ICE_APP_PROT_ID_FCOE;
     851         [ #  # ]:          0 :                 } else if (i == 1) {
     852                 :            :                         /* iSCSI APP */
     853                 :            :                         ice_aqc_cee_status_mask = ICE_AQC_CEE_ISCSI_STATUS_M;
     854                 :            :                         ice_aqc_cee_status_shift = ICE_AQC_CEE_ISCSI_STATUS_S;
     855                 :            :                         ice_aqc_cee_app_mask = ICE_AQC_CEE_APP_ISCSI_M;
     856                 :            :                         ice_aqc_cee_app_shift = ICE_AQC_CEE_APP_ISCSI_S;
     857                 :            :                         ice_app_sel_type = ICE_APP_SEL_TCPIP;
     858                 :            :                         ice_app_prot_id_type = ICE_APP_PROT_ID_ISCSI;
     859                 :            : 
     860         [ #  # ]:          0 :                         for (j = 0; j < cmp_dcbcfg->numapps; j++) {
     861                 :          0 :                                 u16 prot_id = cmp_dcbcfg->app[j].prot_id;
     862                 :          0 :                                 u8 sel = cmp_dcbcfg->app[j].selector;
     863                 :            : 
     864         [ #  # ]:          0 :                                 if  (sel == ICE_APP_SEL_TCPIP &&
     865                 :          0 :                                      (prot_id == ICE_APP_PROT_ID_ISCSI ||
     866         [ #  # ]:          0 :                                       prot_id == ICE_APP_PROT_ID_ISCSI_860)) {
     867                 :            :                                         ice_app_prot_id_type = prot_id;
     868                 :            :                                         break;
     869                 :            :                                 }
     870                 :            :                         }
     871                 :            :                 } else {
     872                 :            :                         /* FIP APP */
     873                 :            :                         ice_aqc_cee_status_mask = ICE_AQC_CEE_FIP_STATUS_M;
     874                 :            :                         ice_aqc_cee_status_shift = ICE_AQC_CEE_FIP_STATUS_S;
     875                 :            :                         ice_aqc_cee_app_mask = ICE_AQC_CEE_APP_FIP_M;
     876                 :            :                         ice_aqc_cee_app_shift = ICE_AQC_CEE_APP_FIP_S;
     877                 :            :                         ice_app_sel_type = ICE_APP_SEL_ETHTYPE;
     878                 :            :                         ice_app_prot_id_type = ICE_APP_PROT_ID_FIP;
     879                 :            :                 }
     880                 :            : 
     881                 :          0 :                 status = (tlv_status & ice_aqc_cee_status_mask) >>
     882                 :            :                          ice_aqc_cee_status_shift;
     883                 :          0 :                 err = (status & ICE_TLV_STATUS_ERR) ? 1 : 0;
     884                 :          0 :                 sync = (status & ICE_TLV_STATUS_SYNC) ? 1 : 0;
     885                 :          0 :                 oper = (status & ICE_TLV_STATUS_OPER) ? 1 : 0;
     886                 :            :                 /* Add FCoE/iSCSI/FIP APP if Error is False and
     887                 :            :                  * Oper/Sync is True
     888                 :            :                  */
     889   [ #  #  #  # ]:          0 :                 if (!err && sync && oper) {
     890                 :          0 :                         dcbcfg->app[app_index].priority =
     891                 :          0 :                                 (u8)((app_prio & ice_aqc_cee_app_mask) >>
     892                 :            :                                      ice_aqc_cee_app_shift);
     893                 :          0 :                         dcbcfg->app[app_index].selector = ice_app_sel_type;
     894                 :          0 :                         dcbcfg->app[app_index].prot_id = ice_app_prot_id_type;
     895                 :          0 :                         app_index++;
     896                 :            :                 }
     897                 :            :         }
     898                 :            : 
     899                 :          0 :         dcbcfg->numapps = app_index;
     900                 :          0 : }
     901                 :            : 
     902                 :            : /**
     903                 :            :  * ice_get_ieee_or_cee_dcb_cfg
     904                 :            :  * @pi: port information structure
     905                 :            :  * @dcbx_mode: mode of DCBX (IEEE or CEE)
     906                 :            :  *
     907                 :            :  * Get IEEE or CEE mode DCB configuration from the Firmware
     908                 :            :  */
     909                 :            : STATIC int
     910                 :          0 : ice_get_ieee_or_cee_dcb_cfg(struct ice_port_info *pi, u8 dcbx_mode)
     911                 :            : {
     912                 :            :         struct ice_dcbx_cfg *dcbx_cfg = NULL;
     913                 :            :         int ret;
     914                 :            : 
     915         [ #  # ]:          0 :         if (!pi)
     916                 :            :                 return ICE_ERR_PARAM;
     917                 :            : 
     918         [ #  # ]:          0 :         if (dcbx_mode == ICE_DCBX_MODE_IEEE)
     919                 :          0 :                 dcbx_cfg = &pi->qos_cfg.local_dcbx_cfg;
     920         [ #  # ]:          0 :         else if (dcbx_mode == ICE_DCBX_MODE_CEE)
     921                 :          0 :                 dcbx_cfg = &pi->qos_cfg.desired_dcbx_cfg;
     922                 :            : 
     923                 :            :         /* Get Local DCB Config in case of ICE_DCBX_MODE_IEEE
     924                 :            :          * or get CEE DCB Desired Config in case of ICE_DCBX_MODE_CEE
     925                 :            :          */
     926                 :          0 :         ret = ice_aq_get_dcb_cfg(pi->hw, ICE_AQ_LLDP_MIB_LOCAL,
     927                 :            :                                  ICE_AQ_LLDP_BRID_TYPE_NEAREST_BRID, dcbx_cfg);
     928         [ #  # ]:          0 :         if (ret)
     929                 :          0 :                 goto out;
     930                 :            : 
     931                 :            :         /* Get Remote DCB Config */
     932                 :          0 :         dcbx_cfg = &pi->qos_cfg.remote_dcbx_cfg;
     933                 :          0 :         ret = ice_aq_get_dcb_cfg(pi->hw, ICE_AQ_LLDP_MIB_REMOTE,
     934                 :            :                                  ICE_AQ_LLDP_BRID_TYPE_NEAREST_BRID, dcbx_cfg);
     935                 :            :         /* Don't treat ENOENT as an error for Remote MIBs */
     936         [ #  # ]:          0 :         if (pi->hw->adminq.sq_last_status == ICE_AQ_RC_ENOENT)
     937                 :            :                 ret = 0;
     938                 :            : 
     939                 :          0 : out:
     940                 :            :         return ret;
     941                 :            : }
     942                 :            : 
     943                 :            : /**
     944                 :            :  * ice_get_dcb_cfg
     945                 :            :  * @pi: port information structure
     946                 :            :  *
     947                 :            :  * Get DCB configuration from the Firmware
     948                 :            :  */
     949                 :          0 : int ice_get_dcb_cfg(struct ice_port_info *pi)
     950                 :            : {
     951                 :            :         struct ice_aqc_get_cee_dcb_cfg_resp cee_cfg;
     952                 :            :         struct ice_dcbx_cfg *dcbx_cfg;
     953                 :            :         int ret;
     954                 :            : 
     955         [ #  # ]:          0 :         if (!pi)
     956                 :            :                 return ICE_ERR_PARAM;
     957                 :            : 
     958                 :          0 :         ret = ice_aq_get_cee_dcb_cfg(pi->hw, &cee_cfg, NULL);
     959         [ #  # ]:          0 :         if (!ret) {
     960                 :            :                 /* CEE mode */
     961                 :          0 :                 ret = ice_get_ieee_or_cee_dcb_cfg(pi, ICE_DCBX_MODE_CEE);
     962                 :          0 :                 ice_cee_to_dcb_cfg(&cee_cfg, pi);
     963         [ #  # ]:          0 :         } else if (pi->hw->adminq.sq_last_status == ICE_AQ_RC_ENOENT) {
     964                 :            :                 /* CEE mode not enabled try querying IEEE data */
     965                 :            :                 dcbx_cfg = &pi->qos_cfg.local_dcbx_cfg;
     966                 :          0 :                 dcbx_cfg->dcbx_mode = ICE_DCBX_MODE_IEEE;
     967                 :          0 :                 ret = ice_get_ieee_or_cee_dcb_cfg(pi, ICE_DCBX_MODE_IEEE);
     968                 :            :         }
     969                 :            : 
     970                 :            :         return ret;
     971                 :            : }
     972                 :            : 
     973                 :            : /**
     974                 :            :  * ice_get_dcb_cfg_from_mib_change
     975                 :            :  * @pi: port information structure
     976                 :            :  * @event: pointer to the admin queue receive event
     977                 :            :  *
     978                 :            :  * Set DCB configuration from received MIB Change event
     979                 :            :  */
     980                 :          0 : void ice_get_dcb_cfg_from_mib_change(struct ice_port_info *pi,
     981                 :            :                                      struct ice_rq_event_info *event)
     982                 :            : {
     983                 :          0 :         struct ice_dcbx_cfg *dcbx_cfg = &pi->qos_cfg.local_dcbx_cfg;
     984                 :            :         struct ice_aqc_lldp_get_mib *mib;
     985                 :            :         u8 change_type, dcbx_mode;
     986                 :            : 
     987                 :            :         mib = (struct ice_aqc_lldp_get_mib *)&event->desc.params.raw;
     988                 :            : 
     989                 :          0 :         change_type = mib->type & ICE_AQ_LLDP_MIB_TYPE_M;
     990         [ #  # ]:          0 :         if (change_type == ICE_AQ_LLDP_MIB_REMOTE)
     991                 :          0 :                 dcbx_cfg = &pi->qos_cfg.remote_dcbx_cfg;
     992                 :            : 
     993                 :          0 :         dcbx_mode = ((mib->type & ICE_AQ_LLDP_DCBX_M) >>
     994                 :            :                      ICE_AQ_LLDP_DCBX_S);
     995                 :            : 
     996      [ #  #  # ]:          0 :         switch (dcbx_mode) {
     997                 :          0 :         case ICE_AQ_LLDP_DCBX_IEEE:
     998                 :          0 :                 dcbx_cfg->dcbx_mode = ICE_DCBX_MODE_IEEE;
     999                 :          0 :                 ice_lldp_to_dcb_cfg(event->msg_buf, dcbx_cfg);
    1000                 :          0 :                 break;
    1001                 :            : 
    1002                 :          0 :         case ICE_AQ_LLDP_DCBX_CEE:
    1003                 :          0 :                 pi->qos_cfg.desired_dcbx_cfg = pi->qos_cfg.local_dcbx_cfg;
    1004                 :          0 :                 ice_cee_to_dcb_cfg((struct ice_aqc_get_cee_dcb_cfg_resp *)
    1005                 :          0 :                                    event->msg_buf, pi);
    1006                 :          0 :                 break;
    1007                 :            :         }
    1008                 :          0 : }
    1009                 :            : 
    1010                 :            : /**
    1011                 :            :  * ice_init_dcb
    1012                 :            :  * @hw: pointer to the HW struct
    1013                 :            :  * @enable_mib_change: enable MIB change event
    1014                 :            :  *
    1015                 :            :  * Update DCB configuration from the Firmware
    1016                 :            :  */
    1017                 :          0 : int ice_init_dcb(struct ice_hw *hw, bool enable_mib_change)
    1018                 :            : {
    1019                 :          0 :         struct ice_qos_cfg *qos_cfg = &hw->port_info->qos_cfg;
    1020                 :            :         int ret = 0;
    1021                 :            : 
    1022         [ #  # ]:          0 :         if (!hw->func_caps.common_cap.dcb)
    1023                 :            :                 return ICE_ERR_NOT_SUPPORTED;
    1024                 :            : 
    1025                 :          0 :         qos_cfg->is_sw_lldp = true;
    1026                 :            : 
    1027                 :            :         /* Get DCBX status */
    1028                 :          0 :         qos_cfg->dcbx_status = ice_get_dcbx_status(hw);
    1029                 :            : 
    1030                 :          0 :         if (qos_cfg->dcbx_status == ICE_DCBX_STATUS_DONE ||
    1031         [ #  # ]:          0 :             qos_cfg->dcbx_status == ICE_DCBX_STATUS_IN_PROGRESS ||
    1032                 :            :             qos_cfg->dcbx_status == ICE_DCBX_STATUS_NOT_STARTED) {
    1033                 :            :                 /* Get current DCBX configuration */
    1034                 :          0 :                 ret = ice_get_dcb_cfg(hw->port_info);
    1035         [ #  # ]:          0 :                 if (ret)
    1036                 :            :                         return ret;
    1037                 :          0 :                 qos_cfg->is_sw_lldp = false;
    1038         [ #  # ]:          0 :         } else if (qos_cfg->dcbx_status == ICE_DCBX_STATUS_DIS) {
    1039                 :            :                 return ICE_ERR_NOT_READY;
    1040                 :            :         }
    1041                 :            : 
    1042                 :            :         /* Configure the LLDP MIB change event */
    1043         [ #  # ]:          0 :         if (enable_mib_change) {
    1044                 :          0 :                 ret = ice_aq_cfg_lldp_mib_change(hw, true, NULL);
    1045         [ #  # ]:          0 :                 if (ret)
    1046                 :          0 :                         qos_cfg->is_sw_lldp = true;
    1047                 :            :         }
    1048                 :            : 
    1049                 :            :         return ret;
    1050                 :            : }
    1051                 :            : 
    1052                 :            : /**
    1053                 :            :  * ice_cfg_lldp_mib_change
    1054                 :            :  * @hw: pointer to the HW struct
    1055                 :            :  * @ena_mib: enable/disable MIB change event
    1056                 :            :  *
    1057                 :            :  * Configure (disable/enable) MIB
    1058                 :            :  */
    1059                 :          0 : int ice_cfg_lldp_mib_change(struct ice_hw *hw, bool ena_mib)
    1060                 :            : {
    1061                 :          0 :         struct ice_qos_cfg *qos_cfg = &hw->port_info->qos_cfg;
    1062                 :            :         int ret;
    1063                 :            : 
    1064         [ #  # ]:          0 :         if (!hw->func_caps.common_cap.dcb)
    1065                 :            :                 return ICE_ERR_NOT_SUPPORTED;
    1066                 :            : 
    1067                 :            :         /* Get DCBX status */
    1068                 :          0 :         qos_cfg->dcbx_status = ice_get_dcbx_status(hw);
    1069                 :            : 
    1070         [ #  # ]:          0 :         if (qos_cfg->dcbx_status == ICE_DCBX_STATUS_DIS)
    1071                 :            :                 return ICE_ERR_NOT_READY;
    1072                 :            : 
    1073                 :          0 :         ret = ice_aq_cfg_lldp_mib_change(hw, ena_mib, NULL);
    1074         [ #  # ]:          0 :         if (!ret)
    1075                 :          0 :                 qos_cfg->is_sw_lldp = !ena_mib;
    1076                 :            : 
    1077                 :            :         return ret;
    1078                 :            : }
    1079                 :            : 
    1080                 :            : /**
    1081                 :            :  * ice_add_ieee_ets_common_tlv
    1082                 :            :  * @buf: Data buffer to be populated with ice_dcb_ets_cfg data
    1083                 :            :  * @ets_cfg: Container for ice_dcb_ets_cfg data
    1084                 :            :  *
    1085                 :            :  * Populate the TLV buffer with ice_dcb_ets_cfg data
    1086                 :            :  */
    1087                 :            : static void
    1088                 :          0 : ice_add_ieee_ets_common_tlv(u8 *buf, struct ice_dcb_ets_cfg *ets_cfg)
    1089                 :            : {
    1090                 :            :         u8 priority0, priority1;
    1091                 :            :         u8 offset = 0;
    1092                 :            :         int i;
    1093                 :            : 
    1094                 :            :         /* Priority Assignment Table (4 octets)
    1095                 :            :          * Octets:|    1    |    2    |    3    |    4    |
    1096                 :            :          *        -----------------------------------------
    1097                 :            :          *        |pri0|pri1|pri2|pri3|pri4|pri5|pri6|pri7|
    1098                 :            :          *        -----------------------------------------
    1099                 :            :          *   Bits:|7  4|3  0|7  4|3  0|7  4|3  0|7  4|3  0|
    1100                 :            :          *        -----------------------------------------
    1101                 :            :          */
    1102         [ #  # ]:          0 :         for (i = 0; i < ICE_MAX_TRAFFIC_CLASS / 2; i++) {
    1103                 :          0 :                 priority0 = ets_cfg->prio_table[i * 2] & 0xF;
    1104                 :          0 :                 priority1 = ets_cfg->prio_table[i * 2 + 1] & 0xF;
    1105                 :          0 :                 buf[offset] = (priority0 << ICE_IEEE_ETS_PRIO_1_S) | priority1;
    1106                 :          0 :                 offset++;
    1107                 :            :         }
    1108                 :            : 
    1109                 :            :         /* TC Bandwidth Table (8 octets)
    1110                 :            :          * Octets:| 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 |
    1111                 :            :          *        ---------------------------------
    1112                 :            :          *        |tc0|tc1|tc2|tc3|tc4|tc5|tc6|tc7|
    1113                 :            :          *        ---------------------------------
    1114                 :            :          *
    1115                 :            :          * TSA Assignment Table (8 octets)
    1116                 :            :          * Octets:| 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 |
    1117                 :            :          *        ---------------------------------
    1118                 :            :          *        |tc0|tc1|tc2|tc3|tc4|tc5|tc6|tc7|
    1119                 :            :          *        ---------------------------------
    1120                 :            :          */
    1121         [ #  # ]:          0 :         ice_for_each_traffic_class(i) {
    1122                 :          0 :                 buf[offset] = ets_cfg->tcbwtable[i];
    1123                 :          0 :                 buf[ICE_MAX_TRAFFIC_CLASS + offset] = ets_cfg->tsatable[i];
    1124                 :          0 :                 offset++;
    1125                 :            :         }
    1126                 :          0 : }
    1127                 :            : 
    1128                 :            : /**
    1129                 :            :  * ice_add_ieee_ets_tlv - Prepare ETS TLV in IEEE format
    1130                 :            :  * @tlv: Fill the ETS config data in IEEE format
    1131                 :            :  * @dcbcfg: Local store which holds the DCB Config
    1132                 :            :  *
    1133                 :            :  * Prepare IEEE 802.1Qaz ETS CFG TLV
    1134                 :            :  */
    1135                 :            : static void
    1136                 :            : ice_add_ieee_ets_tlv(struct ice_lldp_org_tlv *tlv, struct ice_dcbx_cfg *dcbcfg)
    1137                 :            : {
    1138                 :            :         struct ice_dcb_ets_cfg *etscfg;
    1139                 :            :         u8 *buf = tlv->tlvinfo;
    1140                 :            :         u8 maxtcwilling = 0;
    1141                 :            :         u32 ouisubtype;
    1142                 :            :         u16 typelen;
    1143                 :            : 
    1144                 :            :         typelen = ((ICE_TLV_TYPE_ORG << ICE_LLDP_TLV_TYPE_S) |
    1145                 :            :                    ICE_IEEE_ETS_TLV_LEN);
    1146                 :          0 :         tlv->typelen = HTONS(typelen);
    1147                 :            : 
    1148                 :            :         ouisubtype = ((ICE_IEEE_8021QAZ_OUI << ICE_LLDP_TLV_OUI_S) |
    1149                 :            :                       ICE_IEEE_SUBTYPE_ETS_CFG);
    1150                 :          0 :         tlv->ouisubtype = HTONL(ouisubtype);
    1151                 :            : 
    1152                 :            :         /* First Octet post subtype
    1153                 :            :          * --------------------------
    1154                 :            :          * |will-|CBS  | Re-  | Max |
    1155                 :            :          * |ing  |     |served| TCs |
    1156                 :            :          * --------------------------
    1157                 :            :          * |1bit | 1bit|3 bits|3bits|
    1158                 :            :          */
    1159                 :          0 :         etscfg = &dcbcfg->etscfg;
    1160         [ #  # ]:          0 :         if (etscfg->willing)
    1161                 :            :                 maxtcwilling = BIT(ICE_IEEE_ETS_WILLING_S);
    1162                 :          0 :         maxtcwilling |= etscfg->maxtcs & ICE_IEEE_ETS_MAXTC_M;
    1163                 :          0 :         buf[0] = maxtcwilling;
    1164                 :            : 
    1165                 :            :         /* Begin adding at Priority Assignment Table (offset 1 in buf) */
    1166                 :          0 :         ice_add_ieee_ets_common_tlv(&buf[1], etscfg);
    1167                 :          0 : }
    1168                 :            : 
    1169                 :            : /**
    1170                 :            :  * ice_add_ieee_etsrec_tlv - Prepare ETS Recommended TLV in IEEE format
    1171                 :            :  * @tlv: Fill ETS Recommended TLV in IEEE format
    1172                 :            :  * @dcbcfg: Local store which holds the DCB Config
    1173                 :            :  *
    1174                 :            :  * Prepare IEEE 802.1Qaz ETS REC TLV
    1175                 :            :  */
    1176                 :            : static void
    1177                 :            : ice_add_ieee_etsrec_tlv(struct ice_lldp_org_tlv *tlv,
    1178                 :            :                         struct ice_dcbx_cfg *dcbcfg)
    1179                 :            : {
    1180                 :            :         struct ice_dcb_ets_cfg *etsrec;
    1181                 :            :         u8 *buf = tlv->tlvinfo;
    1182                 :            :         u32 ouisubtype;
    1183                 :            :         u16 typelen;
    1184                 :            : 
    1185                 :            :         typelen = ((ICE_TLV_TYPE_ORG << ICE_LLDP_TLV_TYPE_S) |
    1186                 :            :                    ICE_IEEE_ETS_TLV_LEN);
    1187                 :          0 :         tlv->typelen = HTONS(typelen);
    1188                 :            : 
    1189                 :            :         ouisubtype = ((ICE_IEEE_8021QAZ_OUI << ICE_LLDP_TLV_OUI_S) |
    1190                 :            :                       ICE_IEEE_SUBTYPE_ETS_REC);
    1191                 :          0 :         tlv->ouisubtype = HTONL(ouisubtype);
    1192                 :            : 
    1193                 :          0 :         etsrec = &dcbcfg->etsrec;
    1194                 :            : 
    1195                 :            :         /* First Octet is reserved */
    1196                 :            :         /* Begin adding at Priority Assignment Table (offset 1 in buf) */
    1197                 :          0 :         ice_add_ieee_ets_common_tlv(&buf[1], etsrec);
    1198                 :          0 : }
    1199                 :            : 
    1200                 :            : /**
    1201                 :            :  * ice_add_ieee_pfc_tlv - Prepare PFC TLV in IEEE format
    1202                 :            :  * @tlv: Fill PFC TLV in IEEE format
    1203                 :            :  * @dcbcfg: Local store which holds the PFC CFG data
    1204                 :            :  *
    1205                 :            :  * Prepare IEEE 802.1Qaz PFC CFG TLV
    1206                 :            :  */
    1207                 :            : static void
    1208                 :            : ice_add_ieee_pfc_tlv(struct ice_lldp_org_tlv *tlv, struct ice_dcbx_cfg *dcbcfg)
    1209                 :            : {
    1210                 :            :         u8 *buf = tlv->tlvinfo;
    1211                 :            :         u32 ouisubtype;
    1212                 :            :         u16 typelen;
    1213                 :            : 
    1214                 :            :         typelen = ((ICE_TLV_TYPE_ORG << ICE_LLDP_TLV_TYPE_S) |
    1215                 :            :                    ICE_IEEE_PFC_TLV_LEN);
    1216                 :          0 :         tlv->typelen = HTONS(typelen);
    1217                 :            : 
    1218                 :            :         ouisubtype = ((ICE_IEEE_8021QAZ_OUI << ICE_LLDP_TLV_OUI_S) |
    1219                 :            :                       ICE_IEEE_SUBTYPE_PFC_CFG);
    1220                 :          0 :         tlv->ouisubtype = HTONL(ouisubtype);
    1221                 :            : 
    1222                 :            :         /* ----------------------------------------
    1223                 :            :          * |will-|MBC  | Re-  | PFC |  PFC Enable  |
    1224                 :            :          * |ing  |     |served| cap |              |
    1225                 :            :          * -----------------------------------------
    1226                 :            :          * |1bit | 1bit|2 bits|4bits| 1 octet      |
    1227                 :            :          */
    1228         [ #  # ]:          0 :         if (dcbcfg->pfc.willing)
    1229                 :          0 :                 buf[0] = BIT(ICE_IEEE_PFC_WILLING_S);
    1230                 :            : 
    1231         [ #  # ]:          0 :         if (dcbcfg->pfc.mbc)
    1232                 :          0 :                 buf[0] |= BIT(ICE_IEEE_PFC_MBC_S);
    1233                 :            : 
    1234                 :          0 :         buf[0] |= dcbcfg->pfc.pfccap & 0xF;
    1235                 :          0 :         buf[1] = dcbcfg->pfc.pfcena;
    1236                 :          0 : }
    1237                 :            : 
    1238                 :            : /**
    1239                 :            :  * ice_add_ieee_app_pri_tlv -  Prepare APP TLV in IEEE format
    1240                 :            :  * @tlv: Fill APP TLV in IEEE format
    1241                 :            :  * @dcbcfg: Local store which holds the APP CFG data
    1242                 :            :  *
    1243                 :            :  * Prepare IEEE 802.1Qaz APP CFG TLV
    1244                 :            :  */
    1245                 :            : static void
    1246                 :          0 : ice_add_ieee_app_pri_tlv(struct ice_lldp_org_tlv *tlv,
    1247                 :            :                          struct ice_dcbx_cfg *dcbcfg)
    1248                 :            : {
    1249                 :            :         u16 typelen, len, offset = 0;
    1250                 :            :         u8 priority, selector, i = 0;
    1251                 :          0 :         u8 *buf = tlv->tlvinfo;
    1252                 :            :         u32 ouisubtype;
    1253                 :            : 
    1254                 :            :         /* No APP TLVs then just return */
    1255         [ #  # ]:          0 :         if (dcbcfg->numapps == 0)
    1256                 :            :                 return;
    1257                 :            :         ouisubtype = ((ICE_IEEE_8021QAZ_OUI << ICE_LLDP_TLV_OUI_S) |
    1258                 :            :                       ICE_IEEE_SUBTYPE_APP_PRI);
    1259                 :          0 :         tlv->ouisubtype = HTONL(ouisubtype);
    1260                 :            : 
    1261                 :            :         /* Move offset to App Priority Table */
    1262                 :            :         offset++;
    1263                 :            :         /* Application Priority Table (3 octets)
    1264                 :            :          * Octets:|         1          |    2    |    3    |
    1265                 :            :          *        -----------------------------------------
    1266                 :            :          *        |Priority|Rsrvd| Sel |    Protocol ID    |
    1267                 :            :          *        -----------------------------------------
    1268                 :            :          *   Bits:|23    21|20 19|18 16|15                0|
    1269                 :            :          *        -----------------------------------------
    1270                 :            :          */
    1271         [ #  # ]:          0 :         while (i < dcbcfg->numapps) {
    1272                 :          0 :                 priority = dcbcfg->app[i].priority & 0x7;
    1273                 :          0 :                 selector = dcbcfg->app[i].selector & 0x7;
    1274                 :          0 :                 buf[offset] = (priority << ICE_IEEE_APP_PRIO_S) | selector;
    1275                 :          0 :                 buf[offset + 1] = (dcbcfg->app[i].prot_id >> 0x8) & 0xFF;
    1276                 :          0 :                 buf[offset + 2] = dcbcfg->app[i].prot_id & 0xFF;
    1277                 :            :                 /* Move to next app */
    1278                 :          0 :                 offset += 3;
    1279                 :          0 :                 i++;
    1280         [ #  # ]:          0 :                 if (i >= ICE_DCBX_MAX_APPS)
    1281                 :            :                         break;
    1282                 :            :         }
    1283                 :            :         /* len includes size of ouisubtype + 1 reserved + 3*numapps */
    1284                 :          0 :         len = sizeof(tlv->ouisubtype) + 1 + (i * 3);
    1285                 :          0 :         typelen = ((ICE_TLV_TYPE_ORG << ICE_LLDP_TLV_TYPE_S) | (len & 0x1FF));
    1286         [ #  # ]:          0 :         tlv->typelen = HTONS(typelen);
    1287                 :            : }
    1288                 :            : 
    1289                 :            : /**
    1290                 :            :  * ice_add_dscp_up_tlv - Prepare DSCP to UP TLV
    1291                 :            :  * @tlv: location to build the TLV data
    1292                 :            :  * @dcbcfg: location of data to convert to TLV
    1293                 :            :  */
    1294                 :            : static void
    1295                 :            : ice_add_dscp_up_tlv(struct ice_lldp_org_tlv *tlv, struct ice_dcbx_cfg *dcbcfg)
    1296                 :            : {
    1297                 :          0 :         u8 *buf = tlv->tlvinfo;
    1298                 :            :         u32 ouisubtype;
    1299                 :            :         u16 typelen;
    1300                 :            :         int i;
    1301                 :            : 
    1302                 :            :         typelen = ((ICE_TLV_TYPE_ORG << ICE_LLDP_TLV_TYPE_S) |
    1303                 :            :                    ICE_DSCP_UP_TLV_LEN);
    1304                 :          0 :         tlv->typelen = HTONS(typelen);
    1305                 :            : 
    1306                 :            :         ouisubtype = (u32)((ICE_DSCP_OUI << ICE_LLDP_TLV_OUI_S) |
    1307                 :            :                            ICE_DSCP_SUBTYPE_DSCP2UP);
    1308                 :          0 :         tlv->ouisubtype = HTONL(ouisubtype);
    1309                 :            : 
    1310                 :            :         /* bytes 0 - 63 - IPv4 DSCP2UP LUT */
    1311         [ #  # ]:          0 :         for (i = 0; i < ICE_DSCP_NUM_VAL; i++) {
    1312                 :            :                 /* IPv4 mapping */
    1313                 :          0 :                 buf[i] = dcbcfg->dscp_map[i];
    1314                 :            :                 /* IPv6 mapping */
    1315                 :          0 :                 buf[i + ICE_DSCP_IPV6_OFFSET] = dcbcfg->dscp_map[i];
    1316                 :            :         }
    1317                 :            : 
    1318                 :            :         /* byte 64 - IPv4 untagged traffic */
    1319                 :          0 :         buf[i] = 0;
    1320                 :            : 
    1321                 :            :         /* byte 144 - IPv6 untagged traffic */
    1322                 :          0 :         buf[i + ICE_DSCP_IPV6_OFFSET] = 0;
    1323                 :          0 : }
    1324                 :            : 
    1325                 :            : #define ICE_BYTES_PER_TC        8
    1326                 :            : /**
    1327                 :            :  * ice_add_dscp_enf_tlv - Prepare DSCP Enforcement TLV
    1328                 :            :  * @tlv: location to build the TLV data
    1329                 :            :  */
    1330                 :            : static void
    1331                 :            : ice_add_dscp_enf_tlv(struct ice_lldp_org_tlv *tlv)
    1332                 :            : {
    1333                 :          0 :         u8 *buf = tlv->tlvinfo;
    1334                 :            :         u32 ouisubtype;
    1335                 :            :         u16 typelen;
    1336                 :            : 
    1337                 :            :         typelen = ((ICE_TLV_TYPE_ORG << ICE_LLDP_TLV_TYPE_S) |
    1338                 :            :                    ICE_DSCP_ENF_TLV_LEN);
    1339                 :          0 :         tlv->typelen = HTONS(typelen);
    1340                 :            : 
    1341                 :            :         ouisubtype = (u32)((ICE_DSCP_OUI << ICE_LLDP_TLV_OUI_S) |
    1342                 :            :                            ICE_DSCP_SUBTYPE_ENFORCE);
    1343                 :          0 :         tlv->ouisubtype = HTONL(ouisubtype);
    1344                 :            : 
    1345                 :            :         /* Allow all DSCP values to be valid for all TC's (IPv4 and IPv6) */
    1346                 :            :         memset(buf, 0, 2 * (ICE_MAX_TRAFFIC_CLASS * ICE_BYTES_PER_TC));
    1347                 :          0 : }
    1348                 :            : 
    1349                 :            : /**
    1350                 :            :  * ice_add_dscp_tc_bw_tlv - Prepare DSCP BW for TC TLV
    1351                 :            :  * @tlv: location to build the TLV data
    1352                 :            :  * @dcbcfg: location of the data to convert to TLV
    1353                 :            :  */
    1354                 :            : static void
    1355                 :            : ice_add_dscp_tc_bw_tlv(struct ice_lldp_org_tlv *tlv,
    1356                 :            :                        struct ice_dcbx_cfg *dcbcfg)
    1357                 :            : {
    1358                 :            :         struct ice_dcb_ets_cfg *etscfg;
    1359                 :          0 :         u8 *buf = tlv->tlvinfo;
    1360                 :            :         u32 ouisubtype;
    1361                 :            :         u8 offset = 0;
    1362                 :            :         u16 typelen;
    1363                 :            :         int i;
    1364                 :            : 
    1365                 :            :         typelen = ((ICE_TLV_TYPE_ORG << ICE_LLDP_TLV_TYPE_S) |
    1366                 :            :                    ICE_DSCP_TC_BW_TLV_LEN);
    1367                 :          0 :         tlv->typelen = HTONS(typelen);
    1368                 :            : 
    1369                 :            :         ouisubtype = (u32)((ICE_DSCP_OUI << ICE_LLDP_TLV_OUI_S) |
    1370                 :            :                            ICE_DSCP_SUBTYPE_TCBW);
    1371                 :          0 :         tlv->ouisubtype = HTONL(ouisubtype);
    1372                 :            : 
    1373                 :            :         /* First Octet after subtype
    1374                 :            :          * ----------------------------
    1375                 :            :          * | RSV | CBS | RSV | Max TCs |
    1376                 :            :          * | 1b  | 1b  | 3b  | 3b      |
    1377                 :            :          * ----------------------------
    1378                 :            :          */
    1379                 :            :         etscfg = &dcbcfg->etscfg;
    1380                 :          0 :         buf[0] = etscfg->maxtcs & ICE_IEEE_ETS_MAXTC_M;
    1381                 :            : 
    1382                 :            :         /* bytes 1 - 4 reserved */
    1383                 :            :         offset = 5;
    1384                 :            : 
    1385                 :            :         /* TC BW table
    1386                 :            :          * bytes 0 - 7 for TC 0 - 7
    1387                 :            :          *
    1388                 :            :          * TSA Assignment table
    1389                 :            :          * bytes 8 - 15 for TC 0 - 7
    1390                 :            :          */
    1391         [ #  # ]:          0 :         for (i = 0; i < ICE_MAX_TRAFFIC_CLASS; i++) {
    1392                 :          0 :                 buf[offset] = etscfg->tcbwtable[i];
    1393                 :          0 :                 buf[offset + ICE_MAX_TRAFFIC_CLASS] = etscfg->tsatable[i];
    1394                 :          0 :                 offset++;
    1395                 :            :         }
    1396                 :            : }
    1397                 :            : 
    1398                 :            : /**
    1399                 :            :  * ice_add_dscp_pfc_tlv - Prepare DSCP PFC TLV
    1400                 :            :  * @tlv: Fill PFC TLV in IEEE format
    1401                 :            :  * @dcbcfg: Local store which holds the PFC CFG data
    1402                 :            :  */
    1403                 :            : static void
    1404                 :            : ice_add_dscp_pfc_tlv(struct ice_lldp_org_tlv *tlv, struct ice_dcbx_cfg *dcbcfg)
    1405                 :            : {
    1406                 :            :         u8 *buf = tlv->tlvinfo;
    1407                 :            :         u32 ouisubtype;
    1408                 :            :         u16 typelen;
    1409                 :            : 
    1410                 :            :         typelen = ((ICE_TLV_TYPE_ORG << ICE_LLDP_TLV_TYPE_S) |
    1411                 :            :                    ICE_DSCP_PFC_TLV_LEN);
    1412                 :          0 :         tlv->typelen = HTONS(typelen);
    1413                 :            : 
    1414                 :            :         ouisubtype = (u32)((ICE_DSCP_OUI << ICE_LLDP_TLV_OUI_S) |
    1415                 :            :                            ICE_DSCP_SUBTYPE_PFC);
    1416                 :          0 :         tlv->ouisubtype = HTONL(ouisubtype);
    1417                 :            : 
    1418                 :          0 :         buf[0] = dcbcfg->pfc.pfccap & 0xF;
    1419                 :          0 :         buf[1] = dcbcfg->pfc.pfcena;
    1420                 :          0 : }
    1421                 :            : 
    1422                 :            : /**
    1423                 :            :  * ice_add_dcb_tlv - Add all IEEE or DSCP TLVs
    1424                 :            :  * @tlv: Fill TLV data in IEEE format
    1425                 :            :  * @dcbcfg: Local store which holds the DCB Config
    1426                 :            :  * @tlvid: Type of IEEE TLV
    1427                 :            :  *
    1428                 :            :  * Add tlv information
    1429                 :            :  */
    1430                 :            : static void
    1431                 :          0 : ice_add_dcb_tlv(struct ice_lldp_org_tlv *tlv, struct ice_dcbx_cfg *dcbcfg,
    1432                 :            :                 u16 tlvid)
    1433                 :            : {
    1434         [ #  # ]:          0 :         if (dcbcfg->pfc_mode == ICE_QOS_MODE_VLAN) {
    1435   [ #  #  #  #  :          0 :                 switch (tlvid) {
                      # ]
    1436                 :            :                 case ICE_IEEE_TLV_ID_ETS_CFG:
    1437                 :            :                         ice_add_ieee_ets_tlv(tlv, dcbcfg);
    1438                 :            :                         break;
    1439                 :            :                 case ICE_IEEE_TLV_ID_ETS_REC:
    1440                 :            :                         ice_add_ieee_etsrec_tlv(tlv, dcbcfg);
    1441                 :            :                         break;
    1442                 :            :                 case ICE_IEEE_TLV_ID_PFC_CFG:
    1443                 :            :                         ice_add_ieee_pfc_tlv(tlv, dcbcfg);
    1444                 :            :                         break;
    1445                 :          0 :                 case ICE_IEEE_TLV_ID_APP_PRI:
    1446                 :          0 :                         ice_add_ieee_app_pri_tlv(tlv, dcbcfg);
    1447                 :          0 :                         break;
    1448                 :            :                 default:
    1449                 :            :                         break;
    1450                 :            :                 }
    1451                 :            :         } else {
    1452                 :            :                 /* pfc_mode == ICE_QOS_MODE_DSCP */
    1453   [ #  #  #  #  :          0 :                 switch (tlvid) {
                      # ]
    1454                 :            :                 case ICE_TLV_ID_DSCP_UP:
    1455                 :            :                         ice_add_dscp_up_tlv(tlv, dcbcfg);
    1456                 :            :                         break;
    1457                 :            :                 case ICE_TLV_ID_DSCP_ENF:
    1458                 :            :                         ice_add_dscp_enf_tlv(tlv);
    1459                 :            :                         break;
    1460                 :            :                 case ICE_TLV_ID_DSCP_TC_BW:
    1461                 :            :                         ice_add_dscp_tc_bw_tlv(tlv, dcbcfg);
    1462                 :            :                         break;
    1463                 :            :                 case ICE_TLV_ID_DSCP_TO_PFC:
    1464                 :            :                         ice_add_dscp_pfc_tlv(tlv, dcbcfg);
    1465                 :            :                         break;
    1466                 :            :                 default:
    1467                 :            :                         break;
    1468                 :            :                 }
    1469                 :            :         }
    1470                 :          0 : }
    1471                 :            : 
    1472                 :            : /**
    1473                 :            :  * ice_dcb_cfg_to_lldp - Convert DCB configuration to MIB format
    1474                 :            :  * @lldpmib: pointer to the HW struct
    1475                 :            :  * @miblen: length of LLDP MIB
    1476                 :            :  * @dcbcfg: Local store which holds the DCB Config
    1477                 :            :  *
    1478                 :            :  * Convert the DCB configuration to MIB format
    1479                 :            :  */
    1480                 :          0 : void ice_dcb_cfg_to_lldp(u8 *lldpmib, u16 *miblen, struct ice_dcbx_cfg *dcbcfg)
    1481                 :            : {
    1482                 :            :         u16 len, offset = 0, tlvid = ICE_TLV_ID_START;
    1483                 :            :         struct ice_lldp_org_tlv *tlv;
    1484                 :            :         u16 typelen;
    1485                 :            : 
    1486                 :            :         tlv = (struct ice_lldp_org_tlv *)lldpmib;
    1487                 :            :         while (1) {
    1488                 :          0 :                 ice_add_dcb_tlv(tlv, dcbcfg, tlvid++);
    1489         [ #  # ]:          0 :                 typelen = NTOHS(tlv->typelen);
    1490                 :          0 :                 len = (typelen & ICE_LLDP_TLV_LEN_M) >> ICE_LLDP_TLV_LEN_S;
    1491         [ #  # ]:          0 :                 if (len)
    1492                 :          0 :                         offset += len + 2;
    1493                 :            :                 /* END TLV or beyond LLDPDU size */
    1494                 :          0 :                 if (tlvid >= ICE_TLV_ID_END_OF_LLDPPDU ||
    1495         [ #  # ]:          0 :                     offset > ICE_LLDPDU_SIZE)
    1496                 :            :                         break;
    1497                 :            :                 /* Move to next TLV */
    1498         [ #  # ]:          0 :                 if (len)
    1499                 :          0 :                         tlv = (struct ice_lldp_org_tlv *)
    1500                 :          0 :                                 ((char *)tlv + sizeof(tlv->typelen) + len);
    1501                 :            :         }
    1502                 :          0 :         *miblen = offset;
    1503                 :          0 : }
    1504                 :            : 
    1505                 :            : /**
    1506                 :            :  * ice_set_dcb_cfg - Set the local LLDP MIB to FW
    1507                 :            :  * @pi: port information structure
    1508                 :            :  *
    1509                 :            :  * Set DCB configuration to the Firmware
    1510                 :            :  */
    1511                 :          0 : int ice_set_dcb_cfg(struct ice_port_info *pi)
    1512                 :            : {
    1513                 :            :         u8 mib_type, *lldpmib = NULL;
    1514                 :            :         struct ice_dcbx_cfg *dcbcfg;
    1515                 :            :         struct ice_hw *hw;
    1516                 :            :         u16 miblen;
    1517                 :            :         int ret;
    1518                 :            : 
    1519         [ #  # ]:          0 :         if (!pi)
    1520                 :            :                 return ICE_ERR_PARAM;
    1521                 :            : 
    1522                 :          0 :         hw = pi->hw;
    1523                 :            : 
    1524                 :            :         /* update the HW local config */
    1525                 :          0 :         dcbcfg = &pi->qos_cfg.local_dcbx_cfg;
    1526                 :            :         /* Allocate the LLDPDU */
    1527                 :          0 :         lldpmib = (u8 *)ice_malloc(hw, ICE_LLDPDU_SIZE);
    1528         [ #  # ]:          0 :         if (!lldpmib)
    1529                 :            :                 return ICE_ERR_NO_MEMORY;
    1530                 :            : 
    1531                 :            :         mib_type = SET_LOCAL_MIB_TYPE_LOCAL_MIB;
    1532         [ #  # ]:          0 :         if (dcbcfg->app_mode == ICE_DCBX_APPS_NON_WILLING)
    1533                 :            :                 mib_type |= SET_LOCAL_MIB_TYPE_CEE_NON_WILLING;
    1534                 :            : 
    1535                 :          0 :         ice_dcb_cfg_to_lldp(lldpmib, &miblen, dcbcfg);
    1536                 :          0 :         ret = ice_aq_set_lldp_mib(hw, mib_type, (void *)lldpmib, miblen,
    1537                 :            :                                   NULL);
    1538                 :            : 
    1539                 :          0 :         ice_free(hw, lldpmib);
    1540                 :            : 
    1541                 :          0 :         return ret;
    1542                 :            : }
    1543                 :            : 
    1544                 :            : /**
    1545                 :            :  * ice_aq_query_port_ets - query port ETS configuration
    1546                 :            :  * @pi: port information structure
    1547                 :            :  * @buf: pointer to buffer
    1548                 :            :  * @buf_size: buffer size in bytes
    1549                 :            :  * @cd: pointer to command details structure or NULL
    1550                 :            :  *
    1551                 :            :  * query current port ETS configuration
    1552                 :            :  */
    1553                 :            : int
    1554                 :          0 : ice_aq_query_port_ets(struct ice_port_info *pi,
    1555                 :            :                       struct ice_aqc_port_ets_elem *buf, u16 buf_size,
    1556                 :            :                       struct ice_sq_cd *cd)
    1557                 :            : {
    1558                 :            :         struct ice_aqc_query_port_ets *cmd;
    1559                 :            :         struct ice_aq_desc desc;
    1560                 :            :         int status;
    1561                 :            : 
    1562         [ #  # ]:          0 :         if (!pi)
    1563                 :            :                 return ICE_ERR_PARAM;
    1564                 :            :         cmd = &desc.params.port_ets;
    1565                 :          0 :         ice_fill_dflt_direct_cmd_desc(&desc, ice_aqc_opc_query_port_ets);
    1566         [ #  # ]:          0 :         if (pi->root)
    1567                 :          0 :                 cmd->port_teid = pi->root->info.node_teid;
    1568                 :            : 
    1569                 :          0 :         status = ice_aq_send_cmd(pi->hw, &desc, buf, buf_size, cd);
    1570                 :          0 :         return status;
    1571                 :            : }
    1572                 :            : 
    1573                 :            : /**
    1574                 :            :  * ice_update_port_tc_tree_cfg - update TC tree configuration
    1575                 :            :  * @pi: port information structure
    1576                 :            :  * @buf: pointer to buffer
    1577                 :            :  *
    1578                 :            :  * update the SW DB with the new TC changes
    1579                 :            :  */
    1580                 :            : int
    1581                 :          0 : ice_update_port_tc_tree_cfg(struct ice_port_info *pi,
    1582                 :            :                             struct ice_aqc_port_ets_elem *buf)
    1583                 :            : {
    1584                 :            :         struct ice_sched_node *node, *tc_node;
    1585                 :            :         struct ice_aqc_txsched_elem_data elem;
    1586                 :            :         u32 teid1, teid2;
    1587                 :            :         int status = 0;
    1588                 :            :         u16 i;
    1589                 :            :         u8 j;
    1590                 :            : 
    1591         [ #  # ]:          0 :         if (!pi)
    1592                 :            :                 return ICE_ERR_PARAM;
    1593                 :            :         /* suspend the missing TC nodes */
    1594         [ #  # ]:          0 :         for (i = 0; i < pi->root->num_children; i++) {
    1595                 :          0 :                 teid1 = LE32_TO_CPU(pi->root->children[i]->info.node_teid);
    1596         [ #  # ]:          0 :                 ice_for_each_traffic_class(j) {
    1597                 :          0 :                         teid2 = LE32_TO_CPU(buf->tc_node_teid[j]);
    1598         [ #  # ]:          0 :                         if (teid1 == teid2)
    1599                 :            :                                 break;
    1600                 :            :                 }
    1601         [ #  # ]:          0 :                 if (j < ICE_MAX_TRAFFIC_CLASS)
    1602                 :          0 :                         continue;
    1603                 :            :                 /* TC is missing */
    1604                 :          0 :                 pi->root->children[i]->in_use = false;
    1605                 :            :         }
    1606                 :            :         /* add the new TC nodes */
    1607         [ #  # ]:          0 :         ice_for_each_traffic_class(j) {
    1608                 :          0 :                 teid2 = LE32_TO_CPU(buf->tc_node_teid[j]);
    1609         [ #  # ]:          0 :                 if (teid2 == ICE_INVAL_TEID)
    1610                 :          0 :                         continue;
    1611                 :            :                 /* Is it already present in the tree ? */
    1612         [ #  # ]:          0 :                 for (i = 0; i < pi->root->num_children; i++) {
    1613                 :          0 :                         tc_node = pi->root->children[i];
    1614         [ #  # ]:          0 :                         if (!tc_node)
    1615                 :          0 :                                 continue;
    1616                 :          0 :                         teid1 = LE32_TO_CPU(tc_node->info.node_teid);
    1617         [ #  # ]:          0 :                         if (teid1 == teid2) {
    1618                 :          0 :                                 tc_node->tc_num = j;
    1619                 :          0 :                                 tc_node->in_use = true;
    1620                 :          0 :                                 break;
    1621                 :            :                         }
    1622                 :            :                 }
    1623         [ #  # ]:          0 :                 if (i < pi->root->num_children)
    1624                 :          0 :                         continue;
    1625                 :            :                 /* new TC */
    1626                 :          0 :                 status = ice_sched_query_elem(pi->hw, teid2, &elem);
    1627         [ #  # ]:          0 :                 if (!status)
    1628                 :          0 :                         status = ice_sched_add_node(pi, 1, &elem, NULL);
    1629         [ #  # ]:          0 :                 if (status)
    1630                 :            :                         break;
    1631                 :            :                 /* update the TC number */
    1632                 :          0 :                 node = ice_sched_find_node_by_teid(pi->root, teid2);
    1633         [ #  # ]:          0 :                 if (node)
    1634                 :          0 :                         node->tc_num = j;
    1635                 :            :         }
    1636                 :            :         return status;
    1637                 :            : }
    1638                 :            : 
    1639                 :            : /**
    1640                 :            :  * ice_query_port_ets - query port ETS configuration
    1641                 :            :  * @pi: port information structure
    1642                 :            :  * @buf: pointer to buffer
    1643                 :            :  * @buf_size: buffer size in bytes
    1644                 :            :  * @cd: pointer to command details structure or NULL
    1645                 :            :  *
    1646                 :            :  * query current port ETS configuration and update the
    1647                 :            :  * SW DB with the TC changes
    1648                 :            :  */
    1649                 :            : int
    1650                 :          0 : ice_query_port_ets(struct ice_port_info *pi,
    1651                 :            :                    struct ice_aqc_port_ets_elem *buf, u16 buf_size,
    1652                 :            :                    struct ice_sq_cd *cd)
    1653                 :            : {
    1654                 :            :         int status;
    1655                 :            : 
    1656                 :          0 :         ice_acquire_lock(&pi->sched_lock);
    1657                 :          0 :         status = ice_aq_query_port_ets(pi, buf, buf_size, cd);
    1658         [ #  # ]:          0 :         if (!status)
    1659                 :          0 :                 status = ice_update_port_tc_tree_cfg(pi, buf);
    1660                 :            :         ice_release_lock(&pi->sched_lock);
    1661                 :          0 :         return status;
    1662                 :            : }

Generated by: LCOV version 1.14