LCOV - code coverage report
Current view: top level - drivers/common/cnxk - roc_nix_ops.c (source / functions) Hit Total Coverage
Test: Code coverage Lines: 0 322 0.0 %
Date: 2025-12-01 19:08:10 Functions: 0 11 0.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 0 132 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                 :            : #define NIX_LSO_FRMT_IPV4_OFFSET_SHFT 3
       9                 :            : 
      10                 :            : static void
      11                 :            : nix_lso_tcp(struct nix_lso_format_cfg *req, bool v4)
      12                 :            : {
      13                 :            :         __io struct nix_lso_format *field;
      14                 :            : 
      15                 :            :         /* Format works only with TCP packet marked by OL3/OL4 */
      16                 :            :         field = (__io struct nix_lso_format *)&req->fields[0];
      17                 :          0 :         req->field_mask = NIX_LSO_FIELD_MASK;
      18                 :            :         /* Outer IPv4/IPv6 */
      19                 :          0 :         field->layer = NIX_TXLAYER_OL3;
      20                 :          0 :         field->offset = v4 ? 2 : 4;
      21                 :          0 :         field->sizem1 = 1; /* 2B */
      22                 :          0 :         field->alg = NIX_LSOALG_ADD_PAYLEN;
      23                 :            :         field++;
      24                 :            :         if (v4) {
      25                 :            :                 /* IPID field */
      26                 :          0 :                 field->layer = NIX_TXLAYER_OL3;
      27                 :          0 :                 field->offset = 4;
      28                 :          0 :                 field->sizem1 = 1;
      29                 :            :                 /* Incremented linearly per segment */
      30                 :          0 :                 field->alg = NIX_LSOALG_ADD_SEGNUM;
      31                 :            :                 field++;
      32                 :            :         }
      33                 :            : 
      34                 :            :         /* TCP sequence number update */
      35                 :          0 :         field->layer = NIX_TXLAYER_OL4;
      36                 :          0 :         field->offset = 4;
      37                 :          0 :         field->sizem1 = 3; /* 4 bytes */
      38                 :          0 :         field->alg = NIX_LSOALG_ADD_OFFSET;
      39                 :            :         field++;
      40                 :            :         /* TCP flags field */
      41                 :          0 :         field->layer = NIX_TXLAYER_OL4;
      42                 :          0 :         field->offset = 12;
      43                 :          0 :         field->sizem1 = 1;
      44                 :          0 :         field->alg = NIX_LSOALG_TCP_FLAGS;
      45                 :            :         field++;
      46                 :            : }
      47                 :            : 
      48                 :            : static void
      49                 :          0 : nix_lso_udp_tun_tcp(struct nix_lso_format_cfg *req, bool outer_v4,
      50                 :            :                     bool inner_v4)
      51                 :            : {
      52                 :            :         __io struct nix_lso_format *field;
      53                 :            : 
      54                 :            :         field = (__io struct nix_lso_format *)&req->fields[0];
      55                 :          0 :         req->field_mask = NIX_LSO_FIELD_MASK;
      56                 :            :         /* Outer IPv4/IPv6 len */
      57                 :          0 :         field->layer = NIX_TXLAYER_OL3;
      58         [ #  # ]:          0 :         field->offset = outer_v4 ? 2 : 4;
      59                 :          0 :         field->sizem1 = 1; /* 2B */
      60                 :          0 :         field->alg = NIX_LSOALG_ADD_PAYLEN;
      61                 :          0 :         field++;
      62         [ #  # ]:          0 :         if (outer_v4) {
      63                 :            :                 /* IPID */
      64                 :          0 :                 field->layer = NIX_TXLAYER_OL3;
      65                 :          0 :                 field->offset = 4;
      66                 :          0 :                 field->sizem1 = 1;
      67                 :            :                 /* Incremented linearly per segment */
      68                 :          0 :                 field->alg = NIX_LSOALG_ADD_SEGNUM;
      69                 :          0 :                 field++;
      70                 :            :         }
      71                 :            : 
      72                 :            :         /* Outer UDP length */
      73                 :          0 :         field->layer = NIX_TXLAYER_OL4;
      74                 :          0 :         field->offset = 4;
      75                 :          0 :         field->sizem1 = 1;
      76                 :          0 :         field->alg = NIX_LSOALG_ADD_PAYLEN;
      77                 :            :         field++;
      78                 :            : 
      79                 :            :         /* Inner IPv4/IPv6 */
      80                 :          0 :         field->layer = NIX_TXLAYER_IL3;
      81         [ #  # ]:          0 :         field->offset = inner_v4 ? 2 : 4;
      82                 :          0 :         field->sizem1 = 1; /* 2B */
      83                 :          0 :         field->alg = NIX_LSOALG_ADD_PAYLEN;
      84                 :          0 :         field++;
      85         [ #  # ]:          0 :         if (inner_v4) {
      86                 :            :                 /* IPID field */
      87                 :          0 :                 field->layer = NIX_TXLAYER_IL3;
      88                 :          0 :                 field->offset = 4;
      89                 :          0 :                 field->sizem1 = 1;
      90                 :            :                 /* Incremented linearly per segment */
      91                 :          0 :                 field->alg = NIX_LSOALG_ADD_SEGNUM;
      92                 :          0 :                 field++;
      93                 :            :         }
      94                 :            : 
      95                 :            :         /* TCP sequence number update */
      96                 :          0 :         field->layer = NIX_TXLAYER_IL4;
      97                 :          0 :         field->offset = 4;
      98                 :          0 :         field->sizem1 = 3; /* 4 bytes */
      99                 :          0 :         field->alg = NIX_LSOALG_ADD_OFFSET;
     100                 :            :         field++;
     101                 :            : 
     102                 :            :         /* TCP flags field */
     103                 :          0 :         field->layer = NIX_TXLAYER_IL4;
     104                 :          0 :         field->offset = 12;
     105                 :          0 :         field->sizem1 = 1;
     106                 :          0 :         field->alg = NIX_LSOALG_TCP_FLAGS;
     107                 :            :         field++;
     108                 :          0 : }
     109                 :            : 
     110                 :            : static void
     111                 :          0 : nix_lso_tun_tcp(struct nix_lso_format_cfg *req, bool outer_v4, bool inner_v4)
     112                 :            : {
     113                 :            :         __io struct nix_lso_format *field;
     114                 :            : 
     115                 :            :         field = (__io struct nix_lso_format *)&req->fields[0];
     116                 :          0 :         req->field_mask = NIX_LSO_FIELD_MASK;
     117                 :            :         /* Outer IPv4/IPv6 len */
     118                 :          0 :         field->layer = NIX_TXLAYER_OL3;
     119         [ #  # ]:          0 :         field->offset = outer_v4 ? 2 : 4;
     120                 :          0 :         field->sizem1 = 1; /* 2B */
     121                 :          0 :         field->alg = NIX_LSOALG_ADD_PAYLEN;
     122                 :          0 :         field++;
     123         [ #  # ]:          0 :         if (outer_v4) {
     124                 :            :                 /* IPID */
     125                 :          0 :                 field->layer = NIX_TXLAYER_OL3;
     126                 :          0 :                 field->offset = 4;
     127                 :          0 :                 field->sizem1 = 1;
     128                 :            :                 /* Incremented linearly per segment */
     129                 :          0 :                 field->alg = NIX_LSOALG_ADD_SEGNUM;
     130                 :          0 :                 field++;
     131                 :            :         }
     132                 :            : 
     133                 :            :         /* Inner IPv4/IPv6 */
     134                 :          0 :         field->layer = NIX_TXLAYER_IL3;
     135         [ #  # ]:          0 :         field->offset = inner_v4 ? 2 : 4;
     136                 :          0 :         field->sizem1 = 1; /* 2B */
     137                 :          0 :         field->alg = NIX_LSOALG_ADD_PAYLEN;
     138                 :          0 :         field++;
     139         [ #  # ]:          0 :         if (inner_v4) {
     140                 :            :                 /* IPID field */
     141                 :          0 :                 field->layer = NIX_TXLAYER_IL3;
     142                 :          0 :                 field->offset = 4;
     143                 :          0 :                 field->sizem1 = 1;
     144                 :            :                 /* Incremented linearly per segment */
     145                 :          0 :                 field->alg = NIX_LSOALG_ADD_SEGNUM;
     146                 :          0 :                 field++;
     147                 :            :         }
     148                 :            : 
     149                 :            :         /* TCP sequence number update */
     150                 :          0 :         field->layer = NIX_TXLAYER_IL4;
     151                 :          0 :         field->offset = 4;
     152                 :          0 :         field->sizem1 = 3; /* 4 bytes */
     153                 :          0 :         field->alg = NIX_LSOALG_ADD_OFFSET;
     154                 :            :         field++;
     155                 :            : 
     156                 :            :         /* TCP flags field */
     157                 :          0 :         field->layer = NIX_TXLAYER_IL4;
     158                 :          0 :         field->offset = 12;
     159                 :          0 :         field->sizem1 = 1;
     160                 :          0 :         field->alg = NIX_LSOALG_TCP_FLAGS;
     161                 :            :         field++;
     162                 :          0 : }
     163                 :            : 
     164                 :            : int
     165                 :          0 : roc_nix_lso_alt_flags_profile_setup(struct roc_nix *roc_nix, nix_lso_alt_flg_format_t *fmt)
     166                 :            : {
     167                 :            :         struct nix *nix = roc_nix_to_nix_priv(roc_nix);
     168                 :            :         struct dev *dev = &nix->dev;
     169                 :          0 :         struct mbox *mbox = mbox_get(dev->mbox);
     170                 :            :         struct nix_lso_alt_flags_cfg_rsp *rsp;
     171                 :            :         struct nix_lso_alt_flags_cfg_req *req;
     172                 :            :         int rc = -ENOSPC;
     173                 :            : 
     174                 :          0 :         req = mbox_alloc_msg_nix_lso_alt_flags_cfg(mbox);
     175         [ #  # ]:          0 :         if (req == NULL)
     176                 :          0 :                 goto exit;
     177                 :            : 
     178                 :          0 :         req->cfg = fmt->u[0];
     179                 :          0 :         req->cfg1 = fmt->u[1];
     180                 :            : 
     181                 :            :         rc = mbox_process_msg(mbox, (void *)&rsp);
     182         [ #  # ]:          0 :         if (rc)
     183                 :          0 :                 goto exit;
     184                 :            : 
     185                 :          0 :         plt_nix_dbg("Setup alt flags format %u", rsp->lso_alt_flags_idx);
     186                 :          0 :         rc = rsp->lso_alt_flags_idx;
     187                 :          0 : exit:
     188                 :            :         mbox_put(mbox);
     189                 :          0 :         return rc;
     190                 :            : }
     191                 :            : 
     192                 :            : int
     193                 :          0 : roc_nix_lso_custom_fmt_setup(struct roc_nix *roc_nix,
     194                 :            :                              struct nix_lso_format *fields, uint16_t nb_fields)
     195                 :            : {
     196                 :            :         struct nix *nix = roc_nix_to_nix_priv(roc_nix);
     197                 :            :         struct dev *dev = &nix->dev;
     198                 :          0 :         struct mbox *mbox = mbox_get(dev->mbox);
     199                 :            :         struct nix_lso_format_cfg_rsp *rsp;
     200                 :            :         struct nix_lso_format_cfg *req;
     201                 :            :         int rc = -ENOSPC;
     202                 :            : 
     203         [ #  # ]:          0 :         if (nb_fields > NIX_LSO_FIELD_MAX) {
     204                 :            :                 rc = -EINVAL;
     205                 :          0 :                 goto exit;
     206                 :            :         }
     207                 :            : 
     208                 :          0 :         req = mbox_alloc_msg_nix_lso_format_cfg(mbox);
     209         [ #  # ]:          0 :         if (req == NULL)
     210                 :          0 :                 goto exit;
     211                 :            : 
     212                 :          0 :         req->field_mask = NIX_LSO_FIELD_MASK;
     213         [ #  # ]:          0 :         mbox_memcpy(req->fields, fields,
     214                 :            :                     sizeof(struct nix_lso_format) * nb_fields);
     215                 :            : 
     216                 :            :         rc = mbox_process_msg(mbox, (void *)&rsp);
     217         [ #  # ]:          0 :         if (rc)
     218                 :          0 :                 goto exit;
     219                 :            : 
     220                 :          0 :         plt_nix_dbg("Setup custom format %u", rsp->lso_format_idx);
     221                 :          0 :         rc = rsp->lso_format_idx;
     222                 :          0 : exit:
     223                 :            :         mbox_put(mbox);
     224                 :          0 :         return rc;
     225                 :            : }
     226                 :            : 
     227                 :            : static int
     228                 :          0 : nix_lso_ipv4(struct roc_nix *roc_nix)
     229                 :            : {
     230                 :            :         struct nix *nix = roc_nix_to_nix_priv(roc_nix);
     231                 :            :         struct nix_lso_format_cfg_rsp *rsp;
     232                 :            :         nix_lso_alt_flg_format_t alt_flags;
     233                 :            : 
     234                 :            :         __io struct nix_lso_format *field;
     235                 :            :         struct nix_lso_format_cfg *req;
     236                 :            :         int flag_idx = 0, rc = -ENOSPC;
     237                 :            :         struct dev *dev = &nix->dev;
     238                 :            :         struct mbox *mbox;
     239                 :            : 
     240                 :            :         /* First get flags profile to update v4 flags */
     241                 :            :         memset(&alt_flags, 0, sizeof(alt_flags));
     242                 :          0 :         alt_flags.s.alt_fsf_set = 0x2000;
     243                 :          0 :         alt_flags.s.alt_fsf_mask = 0x5FFF;
     244                 :          0 :         alt_flags.s.alt_msf_set = 0x2000;
     245                 :          0 :         alt_flags.s.alt_msf_mask = 0x5FFF;
     246                 :            :         alt_flags.s.alt_lsf_set = 0x0000;
     247                 :          0 :         alt_flags.s.alt_lsf_mask = 0x5FFF;
     248                 :          0 :         flag_idx = roc_nix_lso_alt_flags_profile_setup(roc_nix, &alt_flags);
     249         [ #  # ]:          0 :         if (flag_idx < 0)
     250                 :            :                 return rc;
     251                 :            : 
     252                 :          0 :         mbox = mbox_get(dev->mbox);
     253                 :            : 
     254                 :            :         /*
     255                 :            :          * IPv4 Fragmentation
     256                 :            :          */
     257                 :          0 :         req = mbox_alloc_msg_nix_lso_format_cfg(mbox);
     258         [ #  # ]:          0 :         if (req == NULL) {
     259                 :            :                 rc = -ENOSPC;
     260                 :          0 :                 goto exit;
     261                 :            :         }
     262                 :            : 
     263                 :            :         /* Format works only with TCP packet marked by OL3/OL4 */
     264                 :            :         field = (__io struct nix_lso_format *)&req->fields[0];
     265                 :          0 :         req->field_mask = NIX_LSO_FIELD_MASK;
     266                 :            :         /* Update Payload Length */
     267                 :          0 :         field->layer = NIX_TXLAYER_OL3;
     268                 :          0 :         field->offset = 2;
     269                 :          0 :         field->sizem1 = 1; /* 2B */
     270                 :          0 :         field->alg = NIX_LSOALG_ADD_PAYLEN;
     271                 :            :         field++;
     272                 :            : 
     273                 :            :         /* Update fragment offset and flags */
     274                 :          0 :         field->layer = NIX_TXLAYER_OL3;
     275                 :          0 :         field->offset = 6;
     276                 :          0 :         field->sizem1 = 1;
     277                 :          0 :         field->shift = NIX_LSO_FRMT_IPV4_OFFSET_SHFT;
     278                 :          0 :         field->alt_flags_index = flag_idx;
     279                 :          0 :         field->alt_flags = 1;
     280                 :            :         /* Cumulative length of previous segments */
     281                 :          0 :         field->alg = NIX_LSOALG_ADD_OFFSET;
     282                 :            :         field++;
     283                 :            :         rc = mbox_process_msg(mbox, (void *)&rsp);
     284         [ #  # ]:          0 :         if (rc)
     285                 :          0 :                 goto exit;
     286                 :            : 
     287                 :            :         /* IPv4 fragment offset shifted by 3 bits, store this value in profile ID */
     288                 :          0 :         nix->lso_ipv4_idx = (NIX_LSO_FRMT_IPV4_OFFSET_SHFT << 8) | (rsp->lso_format_idx & 0x1F);
     289                 :          0 :         plt_nix_dbg("ipv4 fmt=%u", rsp->lso_format_idx);
     290                 :          0 : exit:
     291                 :            :         mbox_put(mbox);
     292                 :          0 :         return rc;
     293                 :            : }
     294                 :            : 
     295                 :            : int
     296                 :          0 : roc_nix_lso_fmt_setup(struct roc_nix *roc_nix)
     297                 :            : {
     298                 :            :         struct nix *nix = roc_nix_to_nix_priv(roc_nix);
     299                 :            :         struct dev *dev = &nix->dev;
     300                 :          0 :         struct mbox *mbox = mbox_get(dev->mbox);
     301                 :            :         struct nix_lso_format_cfg_rsp *rsp;
     302                 :            :         struct nix_lso_format_cfg *req;
     303                 :            :         int rc = -ENOSPC;
     304                 :            : 
     305                 :            :         /*
     306                 :            :          * IPv4/TCP LSO
     307                 :            :          */
     308                 :          0 :         req = mbox_alloc_msg_nix_lso_format_cfg(mbox);
     309         [ #  # ]:          0 :         if (req == NULL)
     310                 :          0 :                 goto exit;
     311                 :            :         nix_lso_tcp(req, true);
     312                 :            :         rc = mbox_process_msg(mbox, (void *)&rsp);
     313         [ #  # ]:          0 :         if (rc)
     314                 :          0 :                 goto exit;
     315                 :            : 
     316         [ #  # ]:          0 :         if (rsp->lso_format_idx != NIX_LSO_FORMAT_IDX_TSOV4) {
     317                 :            :                 rc = NIX_ERR_INTERNAL;
     318                 :          0 :                 goto exit;
     319                 :            :         }
     320                 :            : 
     321                 :          0 :         plt_nix_dbg("tcpv4 lso fmt=%u", rsp->lso_format_idx);
     322                 :            : 
     323                 :            :         /*
     324                 :            :          * IPv6/TCP LSO
     325                 :            :          */
     326                 :          0 :         req = mbox_alloc_msg_nix_lso_format_cfg(mbox);
     327         [ #  # ]:          0 :         if (req == NULL) {
     328                 :            :                 rc =  -ENOSPC;
     329                 :          0 :                 goto exit;
     330                 :            :         }
     331                 :            :         nix_lso_tcp(req, false);
     332                 :            :         rc = mbox_process_msg(mbox, (void *)&rsp);
     333         [ #  # ]:          0 :         if (rc)
     334                 :          0 :                 goto exit;
     335                 :            : 
     336         [ #  # ]:          0 :         if (rsp->lso_format_idx != NIX_LSO_FORMAT_IDX_TSOV6) {
     337                 :            :                 rc = NIX_ERR_INTERNAL;
     338                 :          0 :                 goto exit;
     339                 :            :         }
     340                 :            : 
     341                 :          0 :         plt_nix_dbg("tcpv6 lso fmt=%u", rsp->lso_format_idx);
     342                 :            : 
     343                 :            :         /*
     344                 :            :          * IPv4/UDP/TUN HDR/IPv4/TCP LSO
     345                 :            :          */
     346                 :          0 :         req = mbox_alloc_msg_nix_lso_format_cfg(mbox);
     347         [ #  # ]:          0 :         if (req == NULL) {
     348                 :            :                 rc =  -ENOSPC;
     349                 :          0 :                 goto exit;
     350                 :            :         }
     351                 :          0 :         nix_lso_udp_tun_tcp(req, true, true);
     352                 :            :         rc = mbox_process_msg(mbox, (void *)&rsp);
     353         [ #  # ]:          0 :         if (rc)
     354                 :          0 :                 goto exit;
     355                 :            : 
     356                 :          0 :         nix->lso_udp_tun_idx[ROC_NIX_LSO_TUN_V4V4] = rsp->lso_format_idx;
     357                 :          0 :         plt_nix_dbg("udp tun v4v4 fmt=%u", rsp->lso_format_idx);
     358                 :            : 
     359                 :            :         /*
     360                 :            :          * IPv4/UDP/TUN HDR/IPv6/TCP LSO
     361                 :            :          */
     362                 :          0 :         req = mbox_alloc_msg_nix_lso_format_cfg(mbox);
     363         [ #  # ]:          0 :         if (req == NULL) {
     364                 :            :                 rc =  -ENOSPC;
     365                 :          0 :                 goto exit;
     366                 :            :         }
     367                 :          0 :         nix_lso_udp_tun_tcp(req, true, false);
     368                 :            :         rc = mbox_process_msg(mbox, (void *)&rsp);
     369         [ #  # ]:          0 :         if (rc)
     370                 :          0 :                 goto exit;
     371                 :            : 
     372                 :          0 :         nix->lso_udp_tun_idx[ROC_NIX_LSO_TUN_V4V6] = rsp->lso_format_idx;
     373                 :          0 :         plt_nix_dbg("udp tun v4v6 fmt=%u", rsp->lso_format_idx);
     374                 :            : 
     375                 :            :         /*
     376                 :            :          * IPv6/UDP/TUN HDR/IPv4/TCP LSO
     377                 :            :          */
     378                 :          0 :         req = mbox_alloc_msg_nix_lso_format_cfg(mbox);
     379         [ #  # ]:          0 :         if (req == NULL) {
     380                 :            :                 rc =  -ENOSPC;
     381                 :          0 :                 goto exit;
     382                 :            :         }
     383                 :          0 :         nix_lso_udp_tun_tcp(req, false, true);
     384                 :            :         rc = mbox_process_msg(mbox, (void *)&rsp);
     385         [ #  # ]:          0 :         if (rc)
     386                 :          0 :                 goto exit;
     387                 :            : 
     388                 :          0 :         nix->lso_udp_tun_idx[ROC_NIX_LSO_TUN_V6V4] = rsp->lso_format_idx;
     389                 :          0 :         plt_nix_dbg("udp tun v6v4 fmt=%u", rsp->lso_format_idx);
     390                 :            : 
     391                 :            :         /*
     392                 :            :          * IPv6/UDP/TUN HDR/IPv6/TCP LSO
     393                 :            :          */
     394                 :          0 :         req = mbox_alloc_msg_nix_lso_format_cfg(mbox);
     395         [ #  # ]:          0 :         if (req == NULL) {
     396                 :            :                 rc =  -ENOSPC;
     397                 :          0 :                 goto exit;
     398                 :            :         }
     399                 :          0 :         nix_lso_udp_tun_tcp(req, false, false);
     400                 :            :         rc = mbox_process_msg(mbox, (void *)&rsp);
     401         [ #  # ]:          0 :         if (rc)
     402                 :          0 :                 goto exit;
     403                 :            : 
     404                 :          0 :         nix->lso_udp_tun_idx[ROC_NIX_LSO_TUN_V6V6] = rsp->lso_format_idx;
     405                 :          0 :         plt_nix_dbg("udp tun v6v6 fmt=%u", rsp->lso_format_idx);
     406                 :            : 
     407                 :            :         /*
     408                 :            :          * IPv4/TUN HDR/IPv4/TCP LSO
     409                 :            :          */
     410                 :          0 :         req = mbox_alloc_msg_nix_lso_format_cfg(mbox);
     411         [ #  # ]:          0 :         if (req == NULL) {
     412                 :            :                 rc =  -ENOSPC;
     413                 :          0 :                 goto exit;
     414                 :            :         }
     415                 :          0 :         nix_lso_tun_tcp(req, true, true);
     416                 :            :         rc = mbox_process_msg(mbox, (void *)&rsp);
     417         [ #  # ]:          0 :         if (rc)
     418                 :          0 :                 goto exit;
     419                 :            : 
     420                 :          0 :         nix->lso_tun_idx[ROC_NIX_LSO_TUN_V4V4] = rsp->lso_format_idx;
     421                 :          0 :         plt_nix_dbg("tun v4v4 fmt=%u", rsp->lso_format_idx);
     422                 :            : 
     423                 :            :         /*
     424                 :            :          * IPv4/TUN HDR/IPv6/TCP LSO
     425                 :            :          */
     426                 :          0 :         req = mbox_alloc_msg_nix_lso_format_cfg(mbox);
     427         [ #  # ]:          0 :         if (req == NULL) {
     428                 :            :                 rc =  -ENOSPC;
     429                 :          0 :                 goto exit;
     430                 :            :         }
     431                 :          0 :         nix_lso_tun_tcp(req, true, false);
     432                 :            :         rc = mbox_process_msg(mbox, (void *)&rsp);
     433         [ #  # ]:          0 :         if (rc)
     434                 :          0 :                 goto exit;
     435                 :            : 
     436                 :          0 :         nix->lso_tun_idx[ROC_NIX_LSO_TUN_V4V6] = rsp->lso_format_idx;
     437                 :          0 :         plt_nix_dbg("tun v4v6 fmt=%u", rsp->lso_format_idx);
     438                 :            : 
     439                 :            :         /*
     440                 :            :          * IPv6/TUN HDR/IPv4/TCP LSO
     441                 :            :          */
     442                 :          0 :         req = mbox_alloc_msg_nix_lso_format_cfg(mbox);
     443         [ #  # ]:          0 :         if (req == NULL) {
     444                 :            :                 rc =  -ENOSPC;
     445                 :          0 :                 goto exit;
     446                 :            :         }
     447                 :          0 :         nix_lso_tun_tcp(req, false, true);
     448                 :            :         rc = mbox_process_msg(mbox, (void *)&rsp);
     449         [ #  # ]:          0 :         if (rc)
     450                 :          0 :                 goto exit;
     451                 :            : 
     452                 :          0 :         nix->lso_tun_idx[ROC_NIX_LSO_TUN_V6V4] = rsp->lso_format_idx;
     453                 :          0 :         plt_nix_dbg("tun v6v4 fmt=%u", rsp->lso_format_idx);
     454                 :            : 
     455                 :            :         /*
     456                 :            :          * IPv6/TUN HDR/IPv6/TCP LSO
     457                 :            :          */
     458                 :          0 :         req = mbox_alloc_msg_nix_lso_format_cfg(mbox);
     459         [ #  # ]:          0 :         if (req == NULL) {
     460                 :            :                 rc =  -ENOSPC;
     461                 :          0 :                 goto exit;
     462                 :            :         }
     463                 :            : 
     464                 :          0 :         nix_lso_tun_tcp(req, false, false);
     465                 :            :         rc = mbox_process_msg(mbox, (void *)&rsp);
     466         [ #  # ]:          0 :         if (rc)
     467                 :          0 :                 goto exit;
     468                 :            : 
     469                 :          0 :         nix->lso_tun_idx[ROC_NIX_LSO_TUN_V6V6] = rsp->lso_format_idx;
     470                 :          0 :         plt_nix_dbg("tun v6v6 fmt=%u", rsp->lso_format_idx);
     471                 :            : 
     472                 :          0 : exit:
     473                 :            :         mbox_put(mbox);
     474                 :            : 
     475                 :          0 :         nix->lso_ipv4_idx = 0; /* IPv4 fragmentation not supported */
     476   [ #  #  #  # ]:          0 :         if (!rc && roc_model_is_cn20k())
     477                 :          0 :                 return nix_lso_ipv4(roc_nix);
     478                 :            : 
     479                 :            :         return rc;
     480                 :            : }
     481                 :            : 
     482                 :            : int
     483                 :          0 : roc_nix_lso_fmt_ipv4_frag_get(struct roc_nix *roc_nix)
     484                 :            : {
     485                 :            :         struct nix *nix = roc_nix_to_nix_priv(roc_nix);
     486                 :            : 
     487                 :          0 :         return nix->lso_ipv4_idx;
     488                 :            : }
     489                 :            : 
     490                 :            : int
     491                 :          0 : roc_nix_lso_fmt_get(struct roc_nix *roc_nix,
     492                 :            :                     uint8_t udp_tun[ROC_NIX_LSO_TUN_MAX],
     493                 :            :                     uint8_t tun[ROC_NIX_LSO_TUN_MAX])
     494                 :            : {
     495                 :            :         struct nix *nix = roc_nix_to_nix_priv(roc_nix);
     496                 :            : 
     497                 :          0 :         memcpy(udp_tun, nix->lso_udp_tun_idx, ROC_NIX_LSO_TUN_MAX);
     498                 :          0 :         memcpy(tun, nix->lso_tun_idx, ROC_NIX_LSO_TUN_MAX);
     499                 :          0 :         return 0;
     500                 :            : }
     501                 :            : 
     502                 :            : int
     503                 :          0 : roc_nix_switch_hdr_set(struct roc_nix *roc_nix, uint64_t switch_header_type,
     504                 :            :                        uint8_t pre_l2_size_offset,
     505                 :            :                        uint8_t pre_l2_size_offset_mask,
     506                 :            :                        uint8_t pre_l2_size_shift_dir)
     507                 :            : {
     508                 :            :         struct nix *nix = roc_nix_to_nix_priv(roc_nix);
     509                 :            :         struct dev *dev = &nix->dev;
     510                 :          0 :         struct mbox *mbox = mbox_get(dev->mbox);
     511                 :            :         struct npc_set_pkind *req;
     512                 :            :         struct msg_resp *rsp;
     513                 :            :         int rc = -ENOSPC;
     514                 :            : 
     515                 :            :         if (switch_header_type == 0)
     516                 :            :                 switch_header_type = ROC_PRIV_FLAGS_DEFAULT;
     517                 :            : 
     518                 :          0 :         if (switch_header_type != ROC_PRIV_FLAGS_DEFAULT &&
     519                 :          0 :             switch_header_type != ROC_PRIV_FLAGS_EDSA &&
     520         [ #  # ]:          0 :             switch_header_type != ROC_PRIV_FLAGS_HIGIG &&
     521                 :          0 :             switch_header_type != ROC_PRIV_FLAGS_LEN_90B &&
     522         [ #  # ]:          0 :             switch_header_type != ROC_PRIV_FLAGS_EXDSA &&
     523                 :          0 :             switch_header_type != ROC_PRIV_FLAGS_VLAN_EXDSA &&
     524   [ #  #  #  # ]:          0 :             switch_header_type != ROC_PRIV_FLAGS_PRE_L2 &&
     525                 :            :             switch_header_type != ROC_PRIV_FLAGS_CUSTOM) {
     526                 :          0 :                 plt_err("switch header type is not supported");
     527                 :            :                 rc = NIX_ERR_PARAM;
     528                 :          0 :                 goto exit;
     529                 :            :         }
     530                 :            : 
     531   [ #  #  #  # ]:          0 :         if (switch_header_type == ROC_PRIV_FLAGS_LEN_90B &&
     532                 :          0 :             !roc_nix_is_sdp(roc_nix)) {
     533                 :          0 :                 plt_err("chlen90b is not supported on non-SDP device");
     534                 :            :                 rc = NIX_ERR_PARAM;
     535                 :          0 :                 goto exit;
     536                 :            :         }
     537                 :            : 
     538   [ #  #  #  # ]:          0 :         if (switch_header_type == ROC_PRIV_FLAGS_HIGIG &&
     539                 :          0 :             roc_nix_is_vf_or_sdp(roc_nix)) {
     540                 :          0 :                 plt_err("higig2 is supported on PF devices only");
     541                 :            :                 rc = NIX_ERR_PARAM;
     542                 :          0 :                 goto exit;
     543                 :            :         }
     544                 :            : 
     545                 :          0 :         req = mbox_alloc_msg_npc_set_pkind(mbox);
     546         [ #  # ]:          0 :         if (req == NULL)
     547                 :          0 :                 goto exit;
     548                 :          0 :         req->mode = switch_header_type;
     549                 :            : 
     550         [ #  # ]:          0 :         if (switch_header_type == ROC_PRIV_FLAGS_LEN_90B) {
     551                 :          0 :                 req->mode = ROC_PRIV_FLAGS_CUSTOM;
     552                 :          0 :                 req->pkind = NPC_RX_CHLEN90B_PKIND;
     553         [ #  # ]:          0 :         } else if (switch_header_type == ROC_PRIV_FLAGS_EXDSA) {
     554                 :          0 :                 req->mode = ROC_PRIV_FLAGS_CUSTOM;
     555                 :          0 :                 req->pkind = NPC_RX_EXDSA_PKIND;
     556         [ #  # ]:          0 :         } else if (switch_header_type == ROC_PRIV_FLAGS_VLAN_EXDSA) {
     557                 :          0 :                 req->mode = ROC_PRIV_FLAGS_CUSTOM;
     558                 :          0 :                 req->pkind = NPC_RX_VLAN_EXDSA_PKIND;
     559         [ #  # ]:          0 :         } else if (switch_header_type == ROC_PRIV_FLAGS_PRE_L2) {
     560                 :          0 :                 req->mode = ROC_PRIV_FLAGS_CUSTOM;
     561                 :          0 :                 req->pkind = NPC_RX_CUSTOM_PRE_L2_PKIND;
     562                 :          0 :                 req->var_len_off = pre_l2_size_offset;
     563                 :          0 :                 req->var_len_off_mask = pre_l2_size_offset_mask;
     564                 :          0 :                 req->shift_dir = pre_l2_size_shift_dir;
     565                 :            :         }
     566                 :            : 
     567                 :          0 :         req->dir = PKIND_RX;
     568                 :            :         rc = mbox_process_msg(mbox, (void *)&rsp);
     569         [ #  # ]:          0 :         if (rc)
     570                 :          0 :                 goto exit;
     571                 :            : 
     572                 :          0 :         req = mbox_alloc_msg_npc_set_pkind(mbox);
     573         [ #  # ]:          0 :         if (req == NULL) {
     574                 :            :                 rc = -ENOSPC;
     575                 :          0 :                 goto exit;
     576                 :            :         }
     577                 :          0 :         req->mode = switch_header_type;
     578                 :          0 :         req->dir = PKIND_TX;
     579                 :            :         rc = mbox_process_msg(mbox, (void *)&rsp);
     580                 :          0 : exit:
     581                 :            :         mbox_put(mbox);
     582                 :          0 :         return rc;
     583                 :            : }
     584                 :            : 
     585                 :            : int
     586                 :          0 : roc_nix_eeprom_info_get(struct roc_nix *roc_nix,
     587                 :            :                         struct roc_nix_eeprom_info *info)
     588                 :            : {
     589                 :            :         struct nix *nix = roc_nix_to_nix_priv(roc_nix);
     590                 :            :         struct dev *dev = &nix->dev;
     591                 :          0 :         struct mbox *mbox = mbox_get(dev->mbox);
     592                 :          0 :         struct cgx_fw_data *rsp = NULL;
     593                 :            :         int rc;
     594                 :            : 
     595         [ #  # ]:          0 :         if (!info) {
     596                 :          0 :                 plt_err("Input buffer is NULL");
     597                 :            :                 rc = NIX_ERR_PARAM;
     598                 :          0 :                 goto exit;
     599                 :            :         }
     600                 :            : 
     601                 :          0 :         mbox_alloc_msg_cgx_get_aux_link_info(mbox);
     602                 :            :         rc = mbox_process_msg(mbox, (void *)&rsp);
     603         [ #  # ]:          0 :         if (rc) {
     604                 :          0 :                 plt_err("Failed to get fw data: %d", rc);
     605                 :          0 :                 goto exit;
     606                 :            :         }
     607                 :            : 
     608                 :          0 :         info->sff_id = rsp->fwdata.sfp_eeprom.sff_id;
     609                 :          0 :         mbox_memcpy(info->buf, rsp->fwdata.sfp_eeprom.buf, SFP_EEPROM_SIZE);
     610                 :            :         rc = 0;
     611                 :          0 : exit:
     612                 :            :         mbox_put(mbox);
     613                 :          0 :         return rc;
     614                 :            : }
     615                 :            : 
     616                 :            : int
     617                 :          0 : roc_nix_rx_drop_re_set(struct roc_nix *roc_nix, bool ena)
     618                 :            : {
     619                 :            :         struct nix *nix = roc_nix_to_nix_priv(roc_nix);
     620                 :            :         struct dev *dev = &nix->dev;
     621                 :          0 :         struct mbox *mbox = mbox_get(dev->mbox);
     622                 :            :         struct nix_rx_cfg *req;
     623                 :            :         int rc = -EIO;
     624                 :            : 
     625                 :            :         /* No-op if no change */
     626         [ #  # ]:          0 :         if (ena == !!(nix->rx_cfg & ROC_NIX_LF_RX_CFG_DROP_RE)) {
     627                 :            :                 rc = 0;
     628                 :          0 :                 goto exit;
     629                 :            :         }
     630                 :            : 
     631                 :          0 :         req = mbox_alloc_msg_nix_set_rx_cfg(mbox);
     632         [ #  # ]:          0 :         if (req == NULL)
     633                 :          0 :                 goto exit;
     634                 :            : 
     635         [ #  # ]:          0 :         if (ena)
     636                 :          0 :                 req->len_verify |= NIX_RX_DROP_RE;
     637                 :            :         /* Keep other flags intact */
     638         [ #  # ]:          0 :         if (nix->rx_cfg & ROC_NIX_LF_RX_CFG_LEN_OL3)
     639                 :          0 :                 req->len_verify |= NIX_RX_OL3_VERIFY;
     640                 :            : 
     641         [ #  # ]:          0 :         if (nix->rx_cfg & ROC_NIX_LF_RX_CFG_LEN_OL4)
     642                 :          0 :                 req->len_verify |= NIX_RX_OL4_VERIFY;
     643                 :            : 
     644         [ #  # ]:          0 :         if (nix->rx_cfg & ROC_NIX_LF_RX_CFG_CSUM_OL4)
     645                 :          0 :                 req->csum_verify |= NIX_RX_CSUM_OL4_VERIFY;
     646                 :            : 
     647                 :          0 :         rc = mbox_process(mbox);
     648         [ #  # ]:          0 :         if (rc)
     649                 :          0 :                 goto exit;
     650                 :            : 
     651         [ #  # ]:          0 :         if (ena)
     652                 :          0 :                 nix->rx_cfg |= ROC_NIX_LF_RX_CFG_DROP_RE;
     653                 :            :         else
     654                 :          0 :                 nix->rx_cfg &= ~ROC_NIX_LF_RX_CFG_DROP_RE;
     655                 :            :         rc = 0;
     656                 :          0 : exit:
     657                 :            :         mbox_put(mbox);
     658                 :          0 :         return rc;
     659                 :            : }

Generated by: LCOV version 1.14