LCOV - code coverage report
Current view: top level - drivers/common/cnxk - roc_nix_mac.c (source / functions) Hit Total Coverage
Test: Code coverage Lines: 0 173 0.0 %
Date: 2024-12-01 18:57:19 Functions: 0 18 0.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 0 68 0.0 %

           Branch data     Line data    Source code
       1                 :            : /* SPDX-License-Identifier: BSD-3-Clause
       2                 :            :  * Copyright(C) 2021 Marvell.
       3                 :            :  */
       4                 :            : 
       5                 :            : #include "roc_api.h"
       6                 :            : #include "roc_priv.h"
       7                 :            : 
       8                 :            : int
       9                 :          0 : roc_nix_mac_rxtx_start_stop(struct roc_nix *roc_nix, bool start)
      10                 :            : {
      11                 :            :         struct nix *nix = roc_nix_to_nix_priv(roc_nix);
      12                 :            :         struct dev *dev = &nix->dev;
      13                 :          0 :         struct mbox *mbox = mbox_get(dev->mbox);
      14                 :            :         int rc;
      15                 :            : 
      16         [ #  # ]:          0 :         if (roc_nix_is_vf_or_sdp(roc_nix)) {
      17                 :            :                 rc = NIX_ERR_OP_NOTSUP;
      18                 :          0 :                 goto exit;
      19                 :            :         }
      20                 :            : 
      21         [ #  # ]:          0 :         if (start)
      22                 :          0 :                 mbox_alloc_msg_cgx_start_rxtx(mbox);
      23                 :            :         else
      24                 :          0 :                 mbox_alloc_msg_cgx_stop_rxtx(mbox);
      25                 :            : 
      26                 :          0 :         rc = mbox_process(mbox);
      27                 :          0 : exit:
      28                 :            :         mbox_put(mbox);
      29                 :          0 :         return rc;
      30                 :            : }
      31                 :            : 
      32                 :            : int
      33                 :          0 : roc_nix_mac_link_event_start_stop(struct roc_nix *roc_nix, bool start)
      34                 :            : {
      35                 :            :         struct nix *nix = roc_nix_to_nix_priv(roc_nix);
      36                 :            :         struct dev *dev = &nix->dev;
      37                 :          0 :         struct mbox *mbox = mbox_get(dev->mbox);
      38                 :            :         int rc;
      39                 :            : 
      40         [ #  # ]:          0 :         if (roc_nix_is_vf_or_sdp(roc_nix)) {
      41                 :            :                 rc = NIX_ERR_OP_NOTSUP;
      42                 :          0 :                 goto exit;
      43                 :            :         }
      44                 :            : 
      45         [ #  # ]:          0 :         if (start)
      46                 :          0 :                 mbox_alloc_msg_cgx_start_linkevents(mbox);
      47                 :            :         else
      48                 :          0 :                 mbox_alloc_msg_cgx_stop_linkevents(mbox);
      49                 :            : 
      50                 :          0 :         rc = mbox_process(mbox);
      51                 :          0 : exit:
      52                 :            :         mbox_put(mbox);
      53                 :          0 :         return rc;
      54                 :            : }
      55                 :            : 
      56                 :            : int
      57                 :          0 : roc_nix_mac_loopback_enable(struct roc_nix *roc_nix, bool enable)
      58                 :            : {
      59                 :            :         struct nix *nix = roc_nix_to_nix_priv(roc_nix);
      60                 :            :         struct dev *dev = &nix->dev;
      61                 :          0 :         struct mbox *mbox = mbox_get(dev->mbox);
      62                 :            :         int rc;
      63                 :            : 
      64   [ #  #  #  # ]:          0 :         if (enable && roc_nix_is_vf_or_sdp(roc_nix)) {
      65                 :            :                 rc = NIX_ERR_OP_NOTSUP;
      66                 :          0 :                 goto exit;
      67                 :            :         }
      68                 :            : 
      69         [ #  # ]:          0 :         if (enable)
      70                 :          0 :                 mbox_alloc_msg_cgx_intlbk_enable(mbox);
      71                 :            :         else
      72                 :          0 :                 mbox_alloc_msg_cgx_intlbk_disable(mbox);
      73                 :            : 
      74                 :          0 :         rc = mbox_process(mbox);
      75                 :          0 : exit:
      76                 :            :         mbox_put(mbox);
      77                 :          0 :         return rc;
      78                 :            : }
      79                 :            : 
      80                 :            : int
      81                 :          0 : roc_nix_mac_addr_set(struct roc_nix *roc_nix, const uint8_t addr[])
      82                 :            : {
      83                 :            :         struct nix *nix = roc_nix_to_nix_priv(roc_nix);
      84                 :            :         struct cgx_mac_addr_set_or_get *req, *rsp;
      85                 :            :         struct dev *dev = &nix->dev;
      86                 :          0 :         struct mbox *mbox = mbox_get(dev->mbox);
      87                 :            :         int rc = -ENOSPC;
      88                 :            : 
      89         [ #  # ]:          0 :         if (roc_nix_is_vf_or_sdp(roc_nix)) {
      90                 :            :                 rc = NIX_ERR_OP_NOTSUP;
      91                 :          0 :                 goto exit;
      92                 :            :         }
      93                 :            : 
      94                 :          0 :         req = mbox_alloc_msg_cgx_mac_addr_set(mbox);
      95         [ #  # ]:          0 :         if (req == NULL)
      96                 :          0 :                 goto exit;
      97                 :            : 
      98                 :          0 :         req->index = nix->dmac_flt_idx;
      99         [ #  # ]:          0 :         mbox_memcpy(req->mac_addr, addr, PLT_ETHER_ADDR_LEN);
     100                 :            : 
     101                 :            :         rc = mbox_process_msg(mbox, (void *)&rsp);
     102         [ #  # ]:          0 :         if (rc)
     103                 :          0 :                 goto exit;
     104                 :          0 :         nix->dmac_flt_idx = rsp->index;
     105                 :          0 : exit:
     106                 :            :         mbox_put(mbox);
     107                 :          0 :         return rc;
     108                 :            : }
     109                 :            : 
     110                 :            : int
     111                 :          0 : roc_nix_mac_max_entries_get(struct roc_nix *roc_nix)
     112                 :            : {
     113                 :            :         struct nix *nix = roc_nix_to_nix_priv(roc_nix);
     114                 :            :         struct cgx_max_dmac_entries_get_rsp *rsp;
     115                 :            :         struct dev *dev = &nix->dev;
     116                 :          0 :         struct mbox *mbox = mbox_get(dev->mbox);
     117                 :            :         int rc;
     118                 :            : 
     119         [ #  # ]:          0 :         if (roc_nix_is_vf_or_sdp(roc_nix)) {
     120                 :            :                 rc = NIX_ERR_OP_NOTSUP;
     121                 :          0 :                 goto exit;
     122                 :            :         }
     123                 :            : 
     124                 :          0 :         mbox_alloc_msg_cgx_mac_max_entries_get(mbox);
     125                 :            :         rc = mbox_process_msg(mbox, (void *)&rsp);
     126         [ #  # ]:          0 :         if (rc)
     127                 :          0 :                 goto exit;
     128                 :            : 
     129         [ #  # ]:          0 :         rc = rsp->max_dmac_filters ? rsp->max_dmac_filters : 1;
     130                 :          0 : exit:
     131                 :            :         mbox_put(mbox);
     132                 :          0 :         return rc;
     133                 :            : }
     134                 :            : 
     135                 :            : int
     136                 :          0 : roc_nix_mac_addr_add(struct roc_nix *roc_nix, uint8_t addr[])
     137                 :            : {
     138                 :            :         struct nix *nix = roc_nix_to_nix_priv(roc_nix);
     139                 :            :         struct cgx_mac_addr_add_req *req;
     140                 :            :         struct cgx_mac_addr_add_rsp *rsp;
     141                 :            :         struct dev *dev = &nix->dev;
     142                 :          0 :         struct mbox *mbox = mbox_get(dev->mbox);
     143                 :            :         int rc;
     144                 :            : 
     145         [ #  # ]:          0 :         if (roc_nix_is_vf_or_sdp(roc_nix)) {
     146                 :            :                 rc = NIX_ERR_OP_NOTSUP;
     147                 :          0 :                 goto exit;
     148                 :            :         }
     149                 :            : 
     150                 :          0 :         req = mbox_alloc_msg_cgx_mac_addr_add(mbox);
     151         [ #  # ]:          0 :         mbox_memcpy(req->mac_addr, addr, PLT_ETHER_ADDR_LEN);
     152                 :            : 
     153                 :            :         rc = mbox_process_msg(mbox, (void *)&rsp);
     154         [ #  # ]:          0 :         if (rc < 0)
     155                 :          0 :                 goto exit;
     156                 :            : 
     157                 :          0 :         rc = rsp->index;
     158                 :          0 : exit:
     159                 :            :         mbox_put(mbox);
     160                 :          0 :         return rc;
     161                 :            : }
     162                 :            : 
     163                 :            : int
     164                 :          0 : roc_nix_mac_addr_del(struct roc_nix *roc_nix, uint32_t index)
     165                 :            : {
     166                 :            :         struct nix *nix = roc_nix_to_nix_priv(roc_nix);
     167                 :            :         struct dev *dev = &nix->dev;
     168                 :          0 :         struct mbox *mbox = mbox_get(dev->mbox);
     169                 :            :         struct cgx_mac_addr_del_req *req;
     170                 :            :         int rc = -ENOSPC;
     171                 :            : 
     172         [ #  # ]:          0 :         if (roc_nix_is_vf_or_sdp(roc_nix)) {
     173                 :            :                 rc = NIX_ERR_OP_NOTSUP;
     174                 :          0 :                 goto exit;
     175                 :            :         }
     176                 :            : 
     177                 :          0 :         req = mbox_alloc_msg_cgx_mac_addr_del(mbox);
     178         [ #  # ]:          0 :         if (req == NULL)
     179                 :          0 :                 goto exit;
     180                 :          0 :         req->index = index;
     181                 :            : 
     182                 :          0 :         rc = mbox_process(mbox);
     183                 :          0 : exit:
     184                 :            :         mbox_put(mbox);
     185                 :          0 :         return rc;
     186                 :            : }
     187                 :            : 
     188                 :            : int
     189                 :          0 : roc_nix_mac_promisc_mode_enable(struct roc_nix *roc_nix, int enable)
     190                 :            : {
     191                 :            :         struct nix *nix = roc_nix_to_nix_priv(roc_nix);
     192                 :            :         struct dev *dev = &nix->dev;
     193                 :          0 :         struct mbox *mbox = mbox_get(dev->mbox);
     194                 :            :         int rc;
     195                 :            : 
     196         [ #  # ]:          0 :         if (roc_nix_is_vf_or_sdp(roc_nix)) {
     197                 :            :                 rc = NIX_ERR_OP_NOTSUP;
     198                 :          0 :                 goto exit;
     199                 :            :         }
     200                 :            : 
     201         [ #  # ]:          0 :         if (enable)
     202                 :          0 :                 mbox_alloc_msg_cgx_promisc_enable(mbox);
     203                 :            :         else
     204                 :          0 :                 mbox_alloc_msg_cgx_promisc_disable(mbox);
     205                 :            : 
     206                 :          0 :         rc = mbox_process(mbox);
     207                 :          0 : exit:
     208                 :            :         mbox_put(mbox);
     209                 :          0 :         return rc;
     210                 :            : }
     211                 :            : 
     212                 :            : int
     213                 :          0 : roc_nix_mac_link_info_get(struct roc_nix *roc_nix,
     214                 :            :                           struct roc_nix_link_info *link_info)
     215                 :            : {
     216                 :            :         struct nix *nix = roc_nix_to_nix_priv(roc_nix);
     217                 :            :         struct dev *dev = &nix->dev;
     218                 :          0 :         struct mbox *mbox = mbox_get(dev->mbox);
     219                 :            :         struct cgx_link_info_msg *rsp;
     220                 :            :         int rc;
     221                 :            : 
     222                 :          0 :         mbox_alloc_msg_cgx_get_linkinfo(mbox);
     223                 :            :         rc = mbox_process_msg(mbox, (void *)&rsp);
     224         [ #  # ]:          0 :         if (rc)
     225                 :          0 :                 goto exit;
     226                 :            : 
     227                 :          0 :         link_info->status = rsp->link_info.link_up;
     228                 :          0 :         link_info->full_duplex = rsp->link_info.full_duplex;
     229                 :          0 :         link_info->lmac_type_id = rsp->link_info.lmac_type_id;
     230                 :          0 :         link_info->speed = rsp->link_info.speed;
     231                 :          0 :         link_info->autoneg = rsp->link_info.an;
     232                 :          0 :         link_info->fec = rsp->link_info.fec;
     233                 :          0 :         link_info->port = rsp->link_info.port;
     234                 :            : 
     235                 :            :         rc = 0;
     236                 :          0 : exit:
     237                 :            :         mbox_put(mbox);
     238                 :          0 :         return rc;
     239                 :            : }
     240                 :            : 
     241                 :            : int
     242                 :          0 : roc_nix_mac_link_state_set(struct roc_nix *roc_nix, uint8_t up)
     243                 :            : {
     244                 :            :         struct nix *nix = roc_nix_to_nix_priv(roc_nix);
     245                 :            :         struct dev *dev = &nix->dev;
     246                 :          0 :         struct mbox *mbox = mbox_get(dev->mbox);
     247                 :            :         struct cgx_set_link_state_msg *req;
     248                 :            :         int rc = -ENOSPC;
     249                 :            : 
     250                 :          0 :         req = mbox_alloc_msg_cgx_set_link_state(mbox);
     251         [ #  # ]:          0 :         if (req == NULL)
     252                 :          0 :                 goto exit;
     253                 :          0 :         req->enable = up;
     254                 :          0 :         rc = mbox_process(mbox);
     255                 :          0 : exit:
     256                 :            :         mbox_put(mbox);
     257                 :          0 :         return rc;
     258                 :            : }
     259                 :            : 
     260                 :            : int
     261                 :          0 : roc_nix_mac_link_info_set(struct roc_nix *roc_nix,
     262                 :            :                           struct roc_nix_link_info *link_info)
     263                 :            : {
     264                 :            :         struct nix *nix = roc_nix_to_nix_priv(roc_nix);
     265                 :            :         struct dev *dev = &nix->dev;
     266                 :          0 :         struct mbox *mbox = mbox_get(dev->mbox);
     267                 :            :         struct cgx_set_link_mode_req *req;
     268                 :            :         int rc;
     269                 :            : 
     270                 :          0 :         rc = roc_nix_mac_link_state_set(roc_nix, link_info->status);
     271         [ #  # ]:          0 :         if (rc)
     272                 :          0 :                 goto exit;
     273                 :            : 
     274                 :          0 :         req = mbox_alloc_msg_cgx_set_link_mode(mbox);
     275         [ #  # ]:          0 :         if (req == NULL) {
     276                 :            :                 rc =  -ENOSPC;
     277                 :          0 :                 goto exit;
     278                 :            :         }
     279                 :          0 :         req->args.speed = link_info->speed;
     280                 :          0 :         req->args.duplex = link_info->full_duplex;
     281                 :          0 :         req->args.an = link_info->autoneg;
     282                 :            : 
     283                 :          0 :         rc = mbox_process(mbox);
     284                 :          0 : exit:
     285                 :            :         mbox_put(mbox);
     286                 :          0 :         return rc;
     287                 :            : 
     288                 :            : }
     289                 :            : 
     290                 :            : int
     291                 :          0 : roc_nix_mac_mtu_set(struct roc_nix *roc_nix, uint16_t mtu)
     292                 :            : {
     293                 :            :         struct nix *nix = roc_nix_to_nix_priv(roc_nix);
     294                 :            :         struct dev *dev = &nix->dev;
     295                 :          0 :         struct mbox *mbox = mbox_get(dev->mbox);
     296                 :            :         struct nix_frs_cfg *req;
     297                 :            :         bool sdp_link = false;
     298                 :            :         int rc = -ENOSPC;
     299                 :            : 
     300         [ #  # ]:          0 :         if (roc_nix_is_sdp(roc_nix))
     301                 :            :                 sdp_link = true;
     302                 :            : 
     303                 :          0 :         req = mbox_alloc_msg_nix_set_hw_frs(mbox);
     304         [ #  # ]:          0 :         if (req == NULL)
     305                 :          0 :                 goto exit;
     306                 :          0 :         req->maxlen = mtu;
     307                 :          0 :         req->update_smq = true;
     308                 :          0 :         req->sdp_link = sdp_link;
     309                 :            : 
     310                 :          0 :         rc = mbox_process(mbox);
     311         [ #  # ]:          0 :         if (rc)
     312                 :          0 :                 goto exit;
     313                 :            : 
     314                 :            :         /* Save MTU for later use */
     315                 :          0 :         nix->mtu = mtu;
     316                 :            :         rc = 0;
     317                 :          0 : exit:
     318                 :            :         mbox_put(mbox);
     319                 :          0 :         return rc;
     320                 :            : }
     321                 :            : 
     322                 :            : int
     323                 :          0 : roc_nix_mac_max_rx_len_set(struct roc_nix *roc_nix, uint16_t maxlen)
     324                 :            : {
     325                 :            :         struct nix *nix = roc_nix_to_nix_priv(roc_nix);
     326                 :            :         struct dev *dev = &nix->dev;
     327                 :          0 :         struct mbox *mbox = mbox_get(dev->mbox);
     328                 :            :         struct nix_frs_cfg *req;
     329                 :            :         bool sdp_link = false;
     330                 :            :         int rc = -ENOSPC;
     331                 :            : 
     332         [ #  # ]:          0 :         if (roc_nix_is_sdp(roc_nix))
     333                 :            :                 sdp_link = true;
     334                 :            : 
     335                 :          0 :         req = mbox_alloc_msg_nix_set_hw_frs(mbox);
     336         [ #  # ]:          0 :         if (req == NULL)
     337                 :          0 :                 goto exit;
     338                 :          0 :         req->sdp_link = sdp_link;
     339                 :          0 :         req->maxlen = maxlen;
     340                 :            : 
     341                 :          0 :         rc = mbox_process(mbox);
     342                 :          0 : exit:
     343                 :            :         mbox_put(mbox);
     344                 :          0 :         return rc;
     345                 :            : }
     346                 :            : 
     347                 :            : int
     348                 :          0 : roc_nix_mac_stats_reset(struct roc_nix *roc_nix)
     349                 :            : {
     350                 :            :         struct nix *nix = roc_nix_to_nix_priv(roc_nix);
     351                 :            :         struct dev *dev = &nix->dev;
     352                 :          0 :         struct mbox *mbox = mbox_get(dev->mbox);
     353                 :            :         struct msg_req *req;
     354                 :            :         int rc = -ENOSPC;
     355                 :            : 
     356         [ #  # ]:          0 :         if (roc_nix_is_vf_or_sdp(roc_nix)) {
     357                 :            :                 rc = 0;
     358                 :          0 :                 goto exit;
     359                 :            :         }
     360                 :            : 
     361                 :          0 :         req = mbox_alloc_msg_cgx_stats_rst(mbox);
     362         [ #  # ]:          0 :         if (req == NULL)
     363                 :          0 :                 goto exit;
     364                 :            : 
     365                 :          0 :         rc = mbox_process(mbox);
     366                 :          0 : exit:
     367                 :            :         mbox_put(mbox);
     368                 :          0 :         return rc;
     369                 :            : }
     370                 :            : 
     371                 :            : int
     372                 :          0 : roc_nix_mac_link_cb_register(struct roc_nix *roc_nix, link_status_t link_update)
     373                 :            : {
     374                 :            :         struct nix *nix = roc_nix_to_nix_priv(roc_nix);
     375                 :            :         struct dev *dev = &nix->dev;
     376                 :            : 
     377         [ #  # ]:          0 :         if (link_update == NULL)
     378                 :            :                 return NIX_ERR_PARAM;
     379                 :            : 
     380                 :          0 :         dev->ops->link_status_update = (link_info_t)link_update;
     381                 :          0 :         return 0;
     382                 :            : }
     383                 :            : 
     384                 :            : void
     385                 :          0 : roc_nix_mac_link_cb_unregister(struct roc_nix *roc_nix)
     386                 :            : {
     387                 :            :         struct nix *nix = roc_nix_to_nix_priv(roc_nix);
     388                 :            :         struct dev *dev = &nix->dev;
     389                 :            : 
     390                 :          0 :         dev->ops->link_status_update = NULL;
     391                 :          0 : }
     392                 :            : 
     393                 :            : int
     394                 :          0 : roc_nix_mac_link_info_get_cb_register(struct roc_nix *roc_nix,
     395                 :            :                                       link_info_get_t link_info_get)
     396                 :            : {
     397                 :            :         struct nix *nix = roc_nix_to_nix_priv(roc_nix);
     398                 :            :         struct dev *dev = &nix->dev;
     399                 :            : 
     400         [ #  # ]:          0 :         if (link_info_get == NULL)
     401                 :            :                 return NIX_ERR_PARAM;
     402                 :            : 
     403                 :          0 :         dev->ops->link_status_get = (link_info_t)link_info_get;
     404                 :          0 :         return 0;
     405                 :            : }
     406                 :            : 
     407                 :            : void
     408                 :          0 : roc_nix_mac_link_info_get_cb_unregister(struct roc_nix *roc_nix)
     409                 :            : {
     410                 :            :         struct nix *nix = roc_nix_to_nix_priv(roc_nix);
     411                 :            :         struct dev *dev = &nix->dev;
     412                 :            : 
     413                 :          0 :         dev->ops->link_status_get = NULL;
     414                 :          0 : }

Generated by: LCOV version 1.14