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 167 0.0 %
Date: 2024-02-14 00:53:57 Functions: 0 17 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 :         if (dev_active_vfs(&nix->dev)) {
      95                 :            :                 rc = NIX_ERR_OP_NOTSUP;
      96                 :          0 :                 goto exit;
      97                 :            :         }
      98                 :            : 
      99                 :          0 :         req = mbox_alloc_msg_cgx_mac_addr_set(mbox);
     100         [ #  # ]:          0 :         if (req == NULL)
     101                 :          0 :                 goto exit;
     102                 :            : 
     103                 :          0 :         req->index = nix->dmac_flt_idx;
     104         [ #  # ]:          0 :         mbox_memcpy(req->mac_addr, addr, PLT_ETHER_ADDR_LEN);
     105                 :            : 
     106                 :            :         rc = mbox_process_msg(mbox, (void *)&rsp);
     107         [ #  # ]:          0 :         if (rc)
     108                 :          0 :                 goto exit;
     109                 :          0 :         nix->dmac_flt_idx = rsp->index;
     110                 :          0 : exit:
     111                 :            :         mbox_put(mbox);
     112                 :          0 :         return rc;
     113                 :            : }
     114                 :            : 
     115                 :            : int
     116                 :          0 : roc_nix_mac_max_entries_get(struct roc_nix *roc_nix)
     117                 :            : {
     118                 :            :         struct nix *nix = roc_nix_to_nix_priv(roc_nix);
     119                 :            :         struct cgx_max_dmac_entries_get_rsp *rsp;
     120                 :            :         struct dev *dev = &nix->dev;
     121                 :          0 :         struct mbox *mbox = mbox_get(dev->mbox);
     122                 :            :         int rc;
     123                 :            : 
     124         [ #  # ]:          0 :         if (roc_nix_is_vf_or_sdp(roc_nix)) {
     125                 :            :                 rc = NIX_ERR_OP_NOTSUP;
     126                 :          0 :                 goto exit;
     127                 :            :         }
     128                 :            : 
     129                 :          0 :         mbox_alloc_msg_cgx_mac_max_entries_get(mbox);
     130                 :            :         rc = mbox_process_msg(mbox, (void *)&rsp);
     131         [ #  # ]:          0 :         if (rc)
     132                 :          0 :                 goto exit;
     133                 :            : 
     134         [ #  # ]:          0 :         rc = rsp->max_dmac_filters ? rsp->max_dmac_filters : 1;
     135                 :          0 : exit:
     136                 :            :         mbox_put(mbox);
     137                 :          0 :         return rc;
     138                 :            : }
     139                 :            : 
     140                 :            : int
     141                 :          0 : roc_nix_mac_addr_add(struct roc_nix *roc_nix, uint8_t addr[])
     142                 :            : {
     143                 :            :         struct nix *nix = roc_nix_to_nix_priv(roc_nix);
     144                 :            :         struct cgx_mac_addr_add_req *req;
     145                 :            :         struct cgx_mac_addr_add_rsp *rsp;
     146                 :            :         struct dev *dev = &nix->dev;
     147                 :          0 :         struct mbox *mbox = mbox_get(dev->mbox);
     148                 :            :         int rc;
     149                 :            : 
     150         [ #  # ]:          0 :         if (roc_nix_is_vf_or_sdp(roc_nix)) {
     151                 :            :                 rc = NIX_ERR_OP_NOTSUP;
     152                 :          0 :                 goto exit;
     153                 :            :         }
     154                 :            : 
     155         [ #  # ]:          0 :         if (dev_active_vfs(&nix->dev)) {
     156                 :            :                 rc = NIX_ERR_OP_NOTSUP;
     157                 :          0 :                 goto exit;
     158                 :            :         }
     159                 :            : 
     160                 :          0 :         req = mbox_alloc_msg_cgx_mac_addr_add(mbox);
     161         [ #  # ]:          0 :         mbox_memcpy(req->mac_addr, addr, PLT_ETHER_ADDR_LEN);
     162                 :            : 
     163                 :            :         rc = mbox_process_msg(mbox, (void *)&rsp);
     164         [ #  # ]:          0 :         if (rc < 0)
     165                 :          0 :                 goto exit;
     166                 :            : 
     167                 :          0 :         rc = rsp->index;
     168                 :          0 : exit:
     169                 :            :         mbox_put(mbox);
     170                 :          0 :         return rc;
     171                 :            : }
     172                 :            : 
     173                 :            : int
     174                 :          0 : roc_nix_mac_addr_del(struct roc_nix *roc_nix, uint32_t index)
     175                 :            : {
     176                 :            :         struct nix *nix = roc_nix_to_nix_priv(roc_nix);
     177                 :            :         struct dev *dev = &nix->dev;
     178                 :          0 :         struct mbox *mbox = mbox_get(dev->mbox);
     179                 :            :         struct cgx_mac_addr_del_req *req;
     180                 :            :         int rc = -ENOSPC;
     181                 :            : 
     182         [ #  # ]:          0 :         if (roc_nix_is_vf_or_sdp(roc_nix)) {
     183                 :            :                 rc = NIX_ERR_OP_NOTSUP;
     184                 :          0 :                 goto exit;
     185                 :            :         }
     186                 :            : 
     187                 :          0 :         req = mbox_alloc_msg_cgx_mac_addr_del(mbox);
     188         [ #  # ]:          0 :         if (req == NULL)
     189                 :          0 :                 goto exit;
     190                 :          0 :         req->index = index;
     191                 :            : 
     192                 :          0 :         rc = mbox_process(mbox);
     193                 :          0 : exit:
     194                 :            :         mbox_put(mbox);
     195                 :          0 :         return rc;
     196                 :            : }
     197                 :            : 
     198                 :            : int
     199                 :          0 : roc_nix_mac_promisc_mode_enable(struct roc_nix *roc_nix, int enable)
     200                 :            : {
     201                 :            :         struct nix *nix = roc_nix_to_nix_priv(roc_nix);
     202                 :            :         struct dev *dev = &nix->dev;
     203                 :          0 :         struct mbox *mbox = mbox_get(dev->mbox);
     204                 :            :         int rc;
     205                 :            : 
     206         [ #  # ]:          0 :         if (roc_nix_is_vf_or_sdp(roc_nix)) {
     207                 :            :                 rc = NIX_ERR_OP_NOTSUP;
     208                 :          0 :                 goto exit;
     209                 :            :         }
     210                 :            : 
     211         [ #  # ]:          0 :         if (enable)
     212                 :          0 :                 mbox_alloc_msg_cgx_promisc_enable(mbox);
     213                 :            :         else
     214                 :          0 :                 mbox_alloc_msg_cgx_promisc_disable(mbox);
     215                 :            : 
     216                 :          0 :         rc = mbox_process(mbox);
     217                 :          0 : exit:
     218                 :            :         mbox_put(mbox);
     219                 :          0 :         return rc;
     220                 :            : }
     221                 :            : 
     222                 :            : int
     223                 :          0 : roc_nix_mac_link_info_get(struct roc_nix *roc_nix,
     224                 :            :                           struct roc_nix_link_info *link_info)
     225                 :            : {
     226                 :            :         struct nix *nix = roc_nix_to_nix_priv(roc_nix);
     227                 :            :         struct dev *dev = &nix->dev;
     228                 :          0 :         struct mbox *mbox = mbox_get(dev->mbox);
     229                 :            :         struct cgx_link_info_msg *rsp;
     230                 :            :         int rc;
     231                 :            : 
     232                 :          0 :         mbox_alloc_msg_cgx_get_linkinfo(mbox);
     233                 :            :         rc = mbox_process_msg(mbox, (void *)&rsp);
     234         [ #  # ]:          0 :         if (rc)
     235                 :          0 :                 goto exit;
     236                 :            : 
     237                 :          0 :         link_info->status = rsp->link_info.link_up;
     238                 :          0 :         link_info->full_duplex = rsp->link_info.full_duplex;
     239                 :          0 :         link_info->lmac_type_id = rsp->link_info.lmac_type_id;
     240                 :          0 :         link_info->speed = rsp->link_info.speed;
     241                 :          0 :         link_info->autoneg = rsp->link_info.an;
     242                 :          0 :         link_info->fec = rsp->link_info.fec;
     243                 :          0 :         link_info->port = rsp->link_info.port;
     244                 :            : 
     245                 :            :         rc = 0;
     246                 :          0 : exit:
     247                 :            :         mbox_put(mbox);
     248                 :          0 :         return rc;
     249                 :            : }
     250                 :            : 
     251                 :            : int
     252                 :          0 : roc_nix_mac_link_state_set(struct roc_nix *roc_nix, uint8_t up)
     253                 :            : {
     254                 :            :         struct nix *nix = roc_nix_to_nix_priv(roc_nix);
     255                 :            :         struct dev *dev = &nix->dev;
     256                 :          0 :         struct mbox *mbox = mbox_get(dev->mbox);
     257                 :            :         struct cgx_set_link_state_msg *req;
     258                 :            :         int rc = -ENOSPC;
     259                 :            : 
     260                 :          0 :         req = mbox_alloc_msg_cgx_set_link_state(mbox);
     261         [ #  # ]:          0 :         if (req == NULL)
     262                 :          0 :                 goto exit;
     263                 :          0 :         req->enable = up;
     264                 :          0 :         rc = mbox_process(mbox);
     265                 :          0 : exit:
     266                 :            :         mbox_put(mbox);
     267                 :          0 :         return rc;
     268                 :            : }
     269                 :            : 
     270                 :            : int
     271                 :          0 : roc_nix_mac_link_info_set(struct roc_nix *roc_nix,
     272                 :            :                           struct roc_nix_link_info *link_info)
     273                 :            : {
     274                 :            :         struct nix *nix = roc_nix_to_nix_priv(roc_nix);
     275                 :            :         struct dev *dev = &nix->dev;
     276                 :          0 :         struct mbox *mbox = mbox_get(dev->mbox);
     277                 :            :         struct cgx_set_link_mode_req *req;
     278                 :            :         int rc;
     279                 :            : 
     280                 :          0 :         rc = roc_nix_mac_link_state_set(roc_nix, link_info->status);
     281         [ #  # ]:          0 :         if (rc)
     282                 :          0 :                 goto exit;
     283                 :            : 
     284                 :          0 :         req = mbox_alloc_msg_cgx_set_link_mode(mbox);
     285         [ #  # ]:          0 :         if (req == NULL) {
     286                 :            :                 rc =  -ENOSPC;
     287                 :          0 :                 goto exit;
     288                 :            :         }
     289                 :          0 :         req->args.speed = link_info->speed;
     290                 :          0 :         req->args.duplex = link_info->full_duplex;
     291                 :          0 :         req->args.an = link_info->autoneg;
     292                 :            : 
     293                 :          0 :         rc = mbox_process(mbox);
     294                 :          0 : exit:
     295                 :            :         mbox_put(mbox);
     296                 :          0 :         return rc;
     297                 :            : 
     298                 :            : }
     299                 :            : 
     300                 :            : int
     301                 :          0 : roc_nix_mac_mtu_set(struct roc_nix *roc_nix, uint16_t mtu)
     302                 :            : {
     303                 :            :         struct nix *nix = roc_nix_to_nix_priv(roc_nix);
     304                 :            :         struct dev *dev = &nix->dev;
     305                 :          0 :         struct mbox *mbox = mbox_get(dev->mbox);
     306                 :            :         struct nix_frs_cfg *req;
     307                 :            :         bool sdp_link = false;
     308                 :            :         int rc = -ENOSPC;
     309                 :            : 
     310         [ #  # ]:          0 :         if (roc_nix_is_sdp(roc_nix))
     311                 :            :                 sdp_link = true;
     312                 :            : 
     313                 :          0 :         req = mbox_alloc_msg_nix_set_hw_frs(mbox);
     314         [ #  # ]:          0 :         if (req == NULL)
     315                 :          0 :                 goto exit;
     316                 :          0 :         req->maxlen = mtu;
     317                 :          0 :         req->update_smq = true;
     318                 :          0 :         req->sdp_link = sdp_link;
     319                 :            : 
     320                 :          0 :         rc = mbox_process(mbox);
     321         [ #  # ]:          0 :         if (rc)
     322                 :          0 :                 goto exit;
     323                 :            : 
     324                 :            :         /* Save MTU for later use */
     325                 :          0 :         nix->mtu = mtu;
     326                 :            :         rc = 0;
     327                 :          0 : exit:
     328                 :            :         mbox_put(mbox);
     329                 :          0 :         return rc;
     330                 :            : }
     331                 :            : 
     332                 :            : int
     333                 :          0 : roc_nix_mac_max_rx_len_set(struct roc_nix *roc_nix, uint16_t maxlen)
     334                 :            : {
     335                 :            :         struct nix *nix = roc_nix_to_nix_priv(roc_nix);
     336                 :            :         struct dev *dev = &nix->dev;
     337                 :          0 :         struct mbox *mbox = mbox_get(dev->mbox);
     338                 :            :         struct nix_frs_cfg *req;
     339                 :            :         bool sdp_link = false;
     340                 :            :         int rc = -ENOSPC;
     341                 :            : 
     342         [ #  # ]:          0 :         if (roc_nix_is_sdp(roc_nix))
     343                 :            :                 sdp_link = true;
     344                 :            : 
     345                 :          0 :         req = mbox_alloc_msg_nix_set_hw_frs(mbox);
     346         [ #  # ]:          0 :         if (req == NULL)
     347                 :          0 :                 goto exit;
     348                 :          0 :         req->sdp_link = sdp_link;
     349                 :          0 :         req->maxlen = maxlen;
     350                 :            : 
     351                 :          0 :         rc = mbox_process(mbox);
     352                 :          0 : exit:
     353                 :            :         mbox_put(mbox);
     354                 :          0 :         return rc;
     355                 :            : }
     356                 :            : 
     357                 :            : int
     358                 :          0 : roc_nix_mac_link_cb_register(struct roc_nix *roc_nix, link_status_t link_update)
     359                 :            : {
     360                 :            :         struct nix *nix = roc_nix_to_nix_priv(roc_nix);
     361                 :            :         struct dev *dev = &nix->dev;
     362                 :            : 
     363         [ #  # ]:          0 :         if (link_update == NULL)
     364                 :            :                 return NIX_ERR_PARAM;
     365                 :            : 
     366                 :          0 :         dev->ops->link_status_update = (link_info_t)link_update;
     367                 :          0 :         return 0;
     368                 :            : }
     369                 :            : 
     370                 :            : void
     371                 :          0 : roc_nix_mac_link_cb_unregister(struct roc_nix *roc_nix)
     372                 :            : {
     373                 :            :         struct nix *nix = roc_nix_to_nix_priv(roc_nix);
     374                 :            :         struct dev *dev = &nix->dev;
     375                 :            : 
     376                 :          0 :         dev->ops->link_status_update = NULL;
     377                 :          0 : }
     378                 :            : 
     379                 :            : int
     380                 :          0 : roc_nix_mac_link_info_get_cb_register(struct roc_nix *roc_nix,
     381                 :            :                                       link_info_get_t link_info_get)
     382                 :            : {
     383                 :            :         struct nix *nix = roc_nix_to_nix_priv(roc_nix);
     384                 :            :         struct dev *dev = &nix->dev;
     385                 :            : 
     386         [ #  # ]:          0 :         if (link_info_get == NULL)
     387                 :            :                 return NIX_ERR_PARAM;
     388                 :            : 
     389                 :          0 :         dev->ops->link_status_get = (link_info_t)link_info_get;
     390                 :          0 :         return 0;
     391                 :            : }
     392                 :            : 
     393                 :            : void
     394                 :          0 : roc_nix_mac_link_info_get_cb_unregister(struct roc_nix *roc_nix)
     395                 :            : {
     396                 :            :         struct nix *nix = roc_nix_to_nix_priv(roc_nix);
     397                 :            :         struct dev *dev = &nix->dev;
     398                 :            : 
     399                 :          0 :         dev->ops->link_status_get = NULL;
     400                 :          0 : }

Generated by: LCOV version 1.14