LCOV - code coverage report
Current view: top level - drivers/bus/fslmc/mc - dpio.c (source / functions) Hit Total Coverage
Test: Code coverage Lines: 0 111 0.0 %
Date: 2025-03-01 20:23:48 Functions: 0 17 0.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 0 16 0.0 %

           Branch data     Line data    Source code
       1                 :            : /* SPDX-License-Identifier: (BSD-3-Clause OR GPL-2.0)
       2                 :            :  *
       3                 :            :  * Copyright 2013-2016 Freescale Semiconductor Inc.
       4                 :            :  * Copyright 2016-2023 NXP
       5                 :            :  *
       6                 :            :  */
       7                 :            : #include <fsl_mc_sys.h>
       8                 :            : #include <fsl_mc_cmd.h>
       9                 :            : #include <fsl_dpio.h>
      10                 :            : #include <fsl_dpio_cmd.h>
      11                 :            : 
      12                 :            : /**
      13                 :            :  * dpio_open() - Open a control session for the specified object
      14                 :            :  * @mc_io:      Pointer to MC portal's I/O object
      15                 :            :  * @cmd_flags:  Command flags; one or more of 'MC_CMD_FLAG_'
      16                 :            :  * @dpio_id:    DPIO unique ID
      17                 :            :  * @token:      Returned token; use in subsequent API calls
      18                 :            :  *
      19                 :            :  * This function can be used to open a control session for an
      20                 :            :  * already created object; an object may have been declared in
      21                 :            :  * the DPL or by calling the dpio_create() function.
      22                 :            :  * This function returns a unique authentication token,
      23                 :            :  * associated with the specific object ID and any MC portals
      24                 :            :  * assigned to the parent container; this token must be used in
      25                 :            :  * all subsequent commands for this specific object.
      26                 :            :  *
      27                 :            :  * Return:      '0' on Success; Error code otherwise.
      28                 :            :  */
      29                 :          0 : int dpio_open(struct fsl_mc_io *mc_io,
      30                 :            :               uint32_t cmd_flags,
      31                 :            :               int dpio_id,
      32                 :            :               uint16_t *token)
      33                 :            : {
      34                 :            :         struct dpio_cmd_open *cmd_params;
      35                 :          0 :         struct mc_command cmd = { 0 };
      36                 :            :         int err;
      37                 :            : 
      38                 :            :         /* prepare command */
      39                 :          0 :         cmd.header = mc_encode_cmd_header(DPIO_CMDID_OPEN,
      40                 :            :                                           cmd_flags,
      41                 :            :                                           0);
      42                 :            :         cmd_params = (struct dpio_cmd_open *)cmd.params;
      43                 :          0 :         cmd_params->dpio_id = cpu_to_le32(dpio_id);
      44                 :            : 
      45                 :            :         /* send command to mc*/
      46                 :          0 :         err = mc_send_command(mc_io, &cmd);
      47         [ #  # ]:          0 :         if (err)
      48                 :            :                 return err;
      49                 :            : 
      50                 :            :         /* retrieve response parameters */
      51                 :          0 :         *token = mc_cmd_hdr_read_token(&cmd);
      52                 :            : 
      53                 :          0 :         return 0;
      54                 :            : }
      55                 :            : 
      56                 :            : /**
      57                 :            :  * dpio_close() - Close the control session of the object
      58                 :            :  * @mc_io:      Pointer to MC portal's I/O object
      59                 :            :  * @cmd_flags:  Command flags; one or more of 'MC_CMD_FLAG_'
      60                 :            :  * @token:      Token of DPIO object
      61                 :            :  *
      62                 :            :  * Return:      '0' on Success; Error code otherwise.
      63                 :            :  */
      64                 :          0 : int dpio_close(struct fsl_mc_io *mc_io,
      65                 :            :                uint32_t cmd_flags,
      66                 :            :                uint16_t token)
      67                 :            : {
      68                 :          0 :         struct mc_command cmd = { 0 };
      69                 :            : 
      70                 :            :         /* prepare command */
      71                 :          0 :         cmd.header = mc_encode_cmd_header(DPIO_CMDID_CLOSE,
      72                 :            :                                           cmd_flags,
      73                 :            :                                           token);
      74                 :            : 
      75                 :            :         /* send command to mc*/
      76                 :          0 :         return mc_send_command(mc_io, &cmd);
      77                 :            : }
      78                 :            : 
      79                 :            : /**
      80                 :            :  * dpio_create() - Create the DPIO object.
      81                 :            :  * @mc_io:      Pointer to MC portal's I/O object
      82                 :            :  * @dprc_token: Parent container token; '0' for default container
      83                 :            :  * @cmd_flags:  Command flags; one or more of 'MC_CMD_FLAG_'
      84                 :            :  * @cfg:        Configuration structure
      85                 :            :  * @obj_id:     Returned object id
      86                 :            :  *
      87                 :            :  * Create the DPIO object, allocate required resources and
      88                 :            :  * perform required initialization.
      89                 :            :  *
      90                 :            :  * The object can be created either by declaring it in the
      91                 :            :  * DPL file, or by calling this function.
      92                 :            :  *
      93                 :            :  * The function accepts an authentication token of a parent
      94                 :            :  * container that this object should be assigned to. The token
      95                 :            :  * can be '0' so the object will be assigned to the default container.
      96                 :            :  * The newly created object can be opened with the returned
      97                 :            :  * object id and using the container's associated tokens and MC portals.
      98                 :            :  *
      99                 :            :  * Return:      '0' on Success; Error code otherwise.
     100                 :            :  */
     101                 :          0 : int dpio_create(struct fsl_mc_io *mc_io,
     102                 :            :                 uint16_t dprc_token,
     103                 :            :                 uint32_t cmd_flags,
     104                 :            :                 const struct dpio_cfg *cfg,
     105                 :            :                 uint32_t *obj_id)
     106                 :            : {
     107                 :            :         struct dpio_cmd_create *cmd_params;
     108                 :          0 :         struct mc_command cmd = { 0 };
     109                 :            :         int err;
     110                 :            : 
     111                 :            :         /* prepare command */
     112                 :          0 :         cmd.header = mc_encode_cmd_header(DPIO_CMDID_CREATE,
     113                 :            :                                           cmd_flags,
     114                 :            :                                           dprc_token);
     115                 :            :         cmd_params = (struct dpio_cmd_create *)cmd.params;
     116                 :          0 :         cmd_params->num_priorities = cfg->num_priorities;
     117                 :          0 :         dpio_set_field(cmd_params->channel_mode,
     118                 :            :                        CHANNEL_MODE,
     119                 :            :                        cfg->channel_mode);
     120                 :            : 
     121                 :            :         /* send command to mc*/
     122                 :          0 :         err = mc_send_command(mc_io, &cmd);
     123         [ #  # ]:          0 :         if (err)
     124                 :            :                 return err;
     125                 :            : 
     126                 :            :         /* retrieve response parameters */
     127                 :          0 :         *obj_id = mc_cmd_read_object_id(&cmd);
     128                 :            : 
     129                 :          0 :         return 0;
     130                 :            : }
     131                 :            : 
     132                 :            : /**
     133                 :            :  * dpio_destroy() - Destroy the DPIO object and release all its resources.
     134                 :            :  * @mc_io:      Pointer to MC portal's I/O object
     135                 :            :  * @dprc_token: Parent container token; '0' for default container
     136                 :            :  * @cmd_flags:  Command flags; one or more of 'MC_CMD_FLAG_'
     137                 :            :  * @object_id:  The object id; it must be a valid id within the container that
     138                 :            :  *              created this object;
     139                 :            :  *
     140                 :            :  * The function accepts the authentication token of the parent container that
     141                 :            :  * created the object (not the one that currently owns the object). The object
     142                 :            :  * is searched within parent using the provided 'object_id'.
     143                 :            :  * All tokens to the object must be closed before calling destroy.
     144                 :            :  *
     145                 :            :  * Return:      '0' on Success; Error code otherwise
     146                 :            :  */
     147                 :          0 : int dpio_destroy(struct fsl_mc_io *mc_io,
     148                 :            :                  uint16_t dprc_token,
     149                 :            :                  uint32_t cmd_flags,
     150                 :            :                  uint32_t object_id)
     151                 :            : {
     152                 :            :         struct dpio_cmd_destroy *cmd_params;
     153                 :          0 :         struct mc_command cmd = { 0 };
     154                 :            : 
     155                 :            :         /* prepare command */
     156                 :          0 :         cmd.header = mc_encode_cmd_header(DPIO_CMDID_DESTROY,
     157                 :            :                         cmd_flags,
     158                 :            :                         dprc_token);
     159                 :            : 
     160                 :            :         /* set object id to destroy */
     161                 :            :         cmd_params = (struct dpio_cmd_destroy *)cmd.params;
     162                 :          0 :         cmd_params->dpio_id = cpu_to_le32(object_id);
     163                 :            : 
     164                 :            :         /* send command to mc*/
     165                 :          0 :         return mc_send_command(mc_io, &cmd);
     166                 :            : }
     167                 :            : 
     168                 :            : /**
     169                 :            :  * dpio_enable() - Enable the DPIO, allow I/O portal operations.
     170                 :            :  * @mc_io:      Pointer to MC portal's I/O object
     171                 :            :  * @cmd_flags:  Command flags; one or more of 'MC_CMD_FLAG_'
     172                 :            :  * @token:      Token of DPIO object
     173                 :            :  *
     174                 :            :  * Return:      '0' on Success; Error code otherwise
     175                 :            :  */
     176                 :          0 : int dpio_enable(struct fsl_mc_io *mc_io,
     177                 :            :                 uint32_t cmd_flags,
     178                 :            :                 uint16_t token)
     179                 :            : {
     180                 :          0 :         struct mc_command cmd = { 0 };
     181                 :            : 
     182                 :            :         /* prepare command */
     183                 :          0 :         cmd.header = mc_encode_cmd_header(DPIO_CMDID_ENABLE,
     184                 :            :                                           cmd_flags,
     185                 :            :                                           token);
     186                 :            : 
     187                 :            :         /* send command to mc*/
     188                 :          0 :         return mc_send_command(mc_io, &cmd);
     189                 :            : }
     190                 :            : 
     191                 :            : /**
     192                 :            :  * dpio_disable() - Disable the DPIO, stop any I/O portal operation.
     193                 :            :  * @mc_io:      Pointer to MC portal's I/O object
     194                 :            :  * @cmd_flags:  Command flags; one or more of 'MC_CMD_FLAG_'
     195                 :            :  * @token:      Token of DPIO object
     196                 :            :  *
     197                 :            :  * Return:      '0' on Success; Error code otherwise
     198                 :            :  */
     199                 :          0 : int dpio_disable(struct fsl_mc_io *mc_io,
     200                 :            :                  uint32_t cmd_flags,
     201                 :            :                  uint16_t token)
     202                 :            : {
     203                 :          0 :         struct mc_command cmd = { 0 };
     204                 :            : 
     205                 :            :         /* prepare command */
     206                 :          0 :         cmd.header = mc_encode_cmd_header(DPIO_CMDID_DISABLE,
     207                 :            :                                           cmd_flags,
     208                 :            :                                           token);
     209                 :            : 
     210                 :            :         /* send command to mc*/
     211                 :          0 :         return mc_send_command(mc_io, &cmd);
     212                 :            : }
     213                 :            : 
     214                 :            : /**
     215                 :            :  * dpio_is_enabled() - Check if the DPIO is enabled.
     216                 :            :  * @mc_io:      Pointer to MC portal's I/O object
     217                 :            :  * @cmd_flags:  Command flags; one or more of 'MC_CMD_FLAG_'
     218                 :            :  * @token:      Token of DPIO object
     219                 :            :  * @en:         Returns '1' if object is enabled; '0' otherwise
     220                 :            :  *
     221                 :            :  * Return:      '0' on Success; Error code otherwise.
     222                 :            :  */
     223                 :          0 : int dpio_is_enabled(struct fsl_mc_io *mc_io,
     224                 :            :                     uint32_t cmd_flags,
     225                 :            :                     uint16_t token,
     226                 :            :                     int *en)
     227                 :            : {
     228                 :            :         struct dpio_rsp_is_enabled *rsp_params;
     229                 :          0 :         struct mc_command cmd = { 0 };
     230                 :            :         int err;
     231                 :            : 
     232                 :            :         /* prepare command */
     233                 :          0 :         cmd.header = mc_encode_cmd_header(DPIO_CMDID_IS_ENABLED, cmd_flags,
     234                 :            :                                           token);
     235                 :            : 
     236                 :            :         /* send command to mc*/
     237                 :          0 :         err = mc_send_command(mc_io, &cmd);
     238         [ #  # ]:          0 :         if (err)
     239                 :            :                 return err;
     240                 :            : 
     241                 :            :         /* retrieve response parameters */
     242                 :            :         rsp_params = (struct dpio_rsp_is_enabled *)cmd.params;
     243                 :          0 :         *en = dpio_get_field(rsp_params->en, ENABLE);
     244                 :            : 
     245                 :          0 :         return 0;
     246                 :            : }
     247                 :            : 
     248                 :            : /**
     249                 :            :  * dpio_reset() - Reset the DPIO, returns the object to initial state.
     250                 :            :  * @mc_io:      Pointer to MC portal's I/O object
     251                 :            :  * @cmd_flags:  Command flags; one or more of 'MC_CMD_FLAG_'
     252                 :            :  * @token:      Token of DPIO object
     253                 :            :  *
     254                 :            :  * Return:      '0' on Success; Error code otherwise.
     255                 :            :  */
     256                 :          0 : int dpio_reset(struct fsl_mc_io *mc_io,
     257                 :            :                uint32_t cmd_flags,
     258                 :            :                uint16_t token)
     259                 :            : {
     260                 :          0 :         struct mc_command cmd = { 0 };
     261                 :            : 
     262                 :            :         /* prepare command */
     263                 :          0 :         cmd.header = mc_encode_cmd_header(DPIO_CMDID_RESET,
     264                 :            :                                           cmd_flags,
     265                 :            :                                           token);
     266                 :            : 
     267                 :            :         /* send command to mc*/
     268                 :          0 :         return mc_send_command(mc_io, &cmd);
     269                 :            : }
     270                 :            : 
     271                 :            : /**
     272                 :            :  * dpio_get_attributes() - Retrieve DPIO attributes
     273                 :            :  * @mc_io:      Pointer to MC portal's I/O object
     274                 :            :  * @cmd_flags:  Command flags; one or more of 'MC_CMD_FLAG_'
     275                 :            :  * @token:      Token of DPIO object
     276                 :            :  * @attr:       Returned object's attributes
     277                 :            :  *
     278                 :            :  * Return:      '0' on Success; Error code otherwise
     279                 :            :  */
     280                 :          0 : int dpio_get_attributes(struct fsl_mc_io *mc_io,
     281                 :            :                         uint32_t cmd_flags,
     282                 :            :                         uint16_t token,
     283                 :            :                         struct dpio_attr *attr)
     284                 :            : {
     285                 :            :         struct dpio_rsp_get_attr *rsp_params;
     286                 :          0 :         struct mc_command cmd = { 0 };
     287                 :            :         int err;
     288                 :            : 
     289                 :            :         /* prepare command */
     290                 :          0 :         cmd.header = mc_encode_cmd_header(DPIO_CMDID_GET_ATTR,
     291                 :            :                                           cmd_flags,
     292                 :            :                                           token);
     293                 :            : 
     294                 :            :         /* send command to mc*/
     295                 :          0 :         err = mc_send_command(mc_io, &cmd);
     296         [ #  # ]:          0 :         if (err)
     297                 :            :                 return err;
     298                 :            : 
     299                 :            :         /* retrieve response parameters */
     300                 :            :         rsp_params = (struct dpio_rsp_get_attr *)cmd.params;
     301                 :          0 :         attr->id = le32_to_cpu(rsp_params->id);
     302                 :          0 :         attr->qbman_portal_id = le16_to_cpu(rsp_params->qbman_portal_id);
     303                 :          0 :         attr->num_priorities = rsp_params->num_priorities;
     304                 :          0 :         attr->qbman_portal_ce_offset =
     305                 :          0 :                                 le64_to_cpu(rsp_params->qbman_portal_ce_offset);
     306                 :          0 :         attr->qbman_portal_ci_offset =
     307                 :          0 :                                 le64_to_cpu(rsp_params->qbman_portal_ci_offset);
     308                 :          0 :         attr->qbman_version = le32_to_cpu(rsp_params->qbman_version);
     309                 :          0 :         attr->clk = le32_to_cpu(rsp_params->clk);
     310                 :          0 :         attr->channel_mode = dpio_get_field(rsp_params->channel_mode,
     311                 :            :                                             ATTR_CHANNEL_MODE);
     312                 :            : 
     313                 :          0 :         return 0;
     314                 :            : }
     315                 :            : 
     316                 :            : /**
     317                 :            :  * dpio_set_stashing_destination() - Set the stashing destination.
     318                 :            :  * @mc_io:      Pointer to MC portal's I/O object
     319                 :            :  * @cmd_flags:  Command flags; one or more of 'MC_CMD_FLAG_'
     320                 :            :  * @token:      Token of DPIO object
     321                 :            :  * @sdest:      Stashing destination value
     322                 :            :  *
     323                 :            :  * Return:      '0' on Success; Error code otherwise.
     324                 :            :  */
     325                 :          0 : int dpio_set_stashing_destination(struct fsl_mc_io *mc_io,
     326                 :            :                                   uint32_t cmd_flags,
     327                 :            :                                   uint16_t token,
     328                 :            :                                   uint8_t sdest)
     329                 :            : {
     330                 :            :         struct dpio_stashing_dest *cmd_params;
     331                 :          0 :         struct mc_command cmd = { 0 };
     332                 :            : 
     333                 :            :         /* prepare command */
     334                 :          0 :         cmd.header = mc_encode_cmd_header(DPIO_CMDID_SET_STASHING_DEST,
     335                 :            :                                           cmd_flags,
     336                 :            :                                           token);
     337                 :            :         cmd_params = (struct dpio_stashing_dest *)cmd.params;
     338                 :          0 :         cmd_params->sdest = sdest;
     339                 :            : 
     340                 :            :         /* send command to mc*/
     341                 :          0 :         return mc_send_command(mc_io, &cmd);
     342                 :            : }
     343                 :            : 
     344                 :            : /**
     345                 :            :  * dpio_get_stashing_destination() - Get the stashing destination..
     346                 :            :  * @mc_io:      Pointer to MC portal's I/O object
     347                 :            :  * @cmd_flags:  Command flags; one or more of 'MC_CMD_FLAG_'
     348                 :            :  * @token:      Token of DPIO object
     349                 :            :  * @sdest:      Returns the stashing destination value
     350                 :            :  *
     351                 :            :  * Return:      '0' on Success; Error code otherwise.
     352                 :            :  */
     353                 :          0 : int dpio_get_stashing_destination(struct fsl_mc_io *mc_io,
     354                 :            :                                   uint32_t cmd_flags,
     355                 :            :                                   uint16_t token,
     356                 :            :                                   uint8_t *sdest)
     357                 :            : {
     358                 :            :         struct dpio_stashing_dest *rsp_params;
     359                 :          0 :         struct mc_command cmd = { 0 };
     360                 :            :         int err;
     361                 :            : 
     362                 :            :         /* prepare command */
     363                 :          0 :         cmd.header = mc_encode_cmd_header(DPIO_CMDID_GET_STASHING_DEST,
     364                 :            :                                           cmd_flags,
     365                 :            :                                           token);
     366                 :            : 
     367                 :            :         /* send command to mc*/
     368                 :          0 :         err = mc_send_command(mc_io, &cmd);
     369         [ #  # ]:          0 :         if (err)
     370                 :            :                 return err;
     371                 :            : 
     372                 :            :         /* retrieve response parameters */
     373                 :            :         rsp_params = (struct dpio_stashing_dest *)cmd.params;
     374                 :          0 :         *sdest = rsp_params->sdest;
     375                 :            : 
     376                 :          0 :         return 0;
     377                 :            : }
     378                 :            : 
     379                 :            : /**
     380                 :            :  * dpio_set_stashing_destination_by_core_id() - Set the stashing destination source
     381                 :            :  * using the core id.
     382                 :            :  * @mc_io:      Pointer to MC portal's I/O object
     383                 :            :  * @cmd_flags:  Command flags; one or more of 'MC_CMD_FLAG_'
     384                 :            :  * @token:      Token of DPIO object
     385                 :            :  * @core_id:    Core id stashing destination
     386                 :            :  *
     387                 :            :  * Return:      '0' on Success; Error code otherwise.
     388                 :            :  */
     389                 :          0 : int dpio_set_stashing_destination_by_core_id(struct fsl_mc_io *mc_io,
     390                 :            :                                         uint32_t cmd_flags,
     391                 :            :                                         uint16_t token,
     392                 :            :                                         uint8_t core_id)
     393                 :            : {
     394                 :            :         struct dpio_stashing_dest_by_core_id *cmd_params;
     395                 :          0 :         struct mc_command cmd = { 0 };
     396                 :            : 
     397                 :            :         /* prepare command */
     398                 :          0 :         cmd.header = mc_encode_cmd_header(DPIO_CMDID_SET_STASHING_DEST_BY_CORE_ID,
     399                 :            :                                                                                 cmd_flags,
     400                 :            :                                                                                 token);
     401                 :            :         cmd_params = (struct dpio_stashing_dest_by_core_id  *)cmd.params;
     402                 :          0 :         cmd_params->core_id = core_id;
     403                 :            : 
     404                 :            :         /* send command to mc*/
     405                 :          0 :         return mc_send_command(mc_io, &cmd);
     406                 :            : }
     407                 :            : 
     408                 :            : /**
     409                 :            :  * dpio_set_stashing_destination_source() - Set the stashing destination source.
     410                 :            :  * @mc_io:      Pointer to MC portal's I/O object
     411                 :            :  * @cmd_flags:  Command flags; one or more of 'MC_CMD_FLAG_'
     412                 :            :  * @token:      Token of DPIO object
     413                 :            :  * @ss:         Stashing destination source (0 manual/1 automatic)
     414                 :            :  *
     415                 :            :  * Return:      '0' on Success; Error code otherwise.
     416                 :            :  */
     417                 :          0 : int dpio_set_stashing_destination_source(struct fsl_mc_io *mc_io,
     418                 :            :                                   uint32_t cmd_flags,
     419                 :            :                                   uint16_t token,
     420                 :            :                                   uint8_t ss)
     421                 :            : {
     422                 :            :         struct dpio_stashing_dest_source *cmd_params;
     423                 :          0 :         struct mc_command cmd = { 0 };
     424                 :            : 
     425                 :            :         /* prepare command */
     426                 :          0 :         cmd.header = mc_encode_cmd_header(DPIO_CMDID_SET_STASHING_DEST_SOURCE,
     427                 :            :                                           cmd_flags,
     428                 :            :                                           token);
     429                 :            :         cmd_params = (struct dpio_stashing_dest_source *)cmd.params;
     430                 :          0 :         cmd_params->ss = ss;
     431                 :            : 
     432                 :            :         /* send command to mc*/
     433                 :          0 :         return mc_send_command(mc_io, &cmd);
     434                 :            : }
     435                 :            : 
     436                 :            : /**
     437                 :            :  * dpio_get_stashing_destination_source() - Get the stashing destination source.
     438                 :            :  * @mc_io:      Pointer to MC portal's I/O object
     439                 :            :  * @cmd_flags:  Command flags; one or more of 'MC_CMD_FLAG_'
     440                 :            :  * @token:      Token of DPIO object
     441                 :            :  * @ss:         Returns the stashing destination source (0 manual/1 automatic)
     442                 :            :  *
     443                 :            :  * Return:      '0' on Success; Error code otherwise.
     444                 :            :  */
     445                 :          0 : int dpio_get_stashing_destination_source(struct fsl_mc_io *mc_io,
     446                 :            :                                   uint32_t cmd_flags,
     447                 :            :                                   uint16_t token,
     448                 :            :                                   uint8_t *ss)
     449                 :            : {
     450                 :            :         struct dpio_stashing_dest_source *rsp_params;
     451                 :          0 :         struct mc_command cmd = { 0 };
     452                 :            :         int err;
     453                 :            : 
     454                 :            :         /* prepare command */
     455                 :          0 :         cmd.header = mc_encode_cmd_header(DPIO_CMDID_GET_STASHING_DEST_SOURCE,
     456                 :            :                                           cmd_flags,
     457                 :            :                                           token);
     458                 :            : 
     459                 :            :         /* send command to mc*/
     460                 :          0 :         err = mc_send_command(mc_io, &cmd);
     461         [ #  # ]:          0 :         if (err)
     462                 :            :                 return err;
     463                 :            : 
     464                 :            :         /* retrieve response parameters */
     465                 :            :         rsp_params = (struct dpio_stashing_dest_source *)cmd.params;
     466                 :          0 :         *ss = rsp_params->ss;
     467                 :            : 
     468                 :          0 :         return 0;
     469                 :            : }
     470                 :            : 
     471                 :            : /**
     472                 :            :  * dpio_add_static_dequeue_channel() - Add a static dequeue channel.
     473                 :            :  * @mc_io:              Pointer to MC portal's I/O object
     474                 :            :  * @cmd_flags:          Command flags; one or more of 'MC_CMD_FLAG_'
     475                 :            :  * @token:              Token of DPIO object
     476                 :            :  * @dpcon_id:           DPCON object ID
     477                 :            :  * @channel_index:      Returned channel index to be used in qbman API
     478                 :            :  *
     479                 :            :  * Return:      '0' on Success; Error code otherwise.
     480                 :            :  */
     481                 :          0 : int dpio_add_static_dequeue_channel(struct fsl_mc_io *mc_io,
     482                 :            :                                     uint32_t cmd_flags,
     483                 :            :                                     uint16_t token,
     484                 :            :                                     int dpcon_id,
     485                 :            :                                     uint8_t *channel_index)
     486                 :            : {
     487                 :            :         struct dpio_rsp_add_static_dequeue_channel *rsp_params;
     488                 :            :         struct dpio_cmd_static_dequeue_channel *cmd_params;
     489                 :          0 :         struct mc_command cmd = { 0 };
     490                 :            :         int err;
     491                 :            : 
     492                 :            :         /* prepare command */
     493                 :          0 :         cmd.header = mc_encode_cmd_header(DPIO_CMDID_ADD_STATIC_DEQUEUE_CHANNEL,
     494                 :            :                                           cmd_flags,
     495                 :            :                                           token);
     496                 :            :         cmd_params = (struct dpio_cmd_static_dequeue_channel *)cmd.params;
     497                 :          0 :         cmd_params->dpcon_id = cpu_to_le32(dpcon_id);
     498                 :            : 
     499                 :            :         /* send command to mc*/
     500                 :          0 :         err = mc_send_command(mc_io, &cmd);
     501         [ #  # ]:          0 :         if (err)
     502                 :            :                 return err;
     503                 :            : 
     504                 :            :         /* retrieve response parameters */
     505                 :            :         rsp_params = (struct dpio_rsp_add_static_dequeue_channel *)cmd.params;
     506                 :          0 :         *channel_index = rsp_params->channel_index;
     507                 :            : 
     508                 :          0 :         return 0;
     509                 :            : }
     510                 :            : 
     511                 :            : /**
     512                 :            :  * dpio_remove_static_dequeue_channel() - Remove a static dequeue channel.
     513                 :            :  * @mc_io:      Pointer to MC portal's I/O object
     514                 :            :  * @cmd_flags:  Command flags; one or more of 'MC_CMD_FLAG_'
     515                 :            :  * @token:      Token of DPIO object
     516                 :            :  * @dpcon_id:   DPCON object ID
     517                 :            :  *
     518                 :            :  * Return:      '0' on Success; Error code otherwise.
     519                 :            :  */
     520                 :          0 : int dpio_remove_static_dequeue_channel(struct fsl_mc_io *mc_io,
     521                 :            :                                        uint32_t cmd_flags,
     522                 :            :                                        uint16_t token,
     523                 :            :                                        int dpcon_id)
     524                 :            : {
     525                 :            :         struct dpio_cmd_static_dequeue_channel *cmd_params;
     526                 :          0 :         struct mc_command cmd = { 0 };
     527                 :            : 
     528                 :            :         /* prepare command */
     529                 :          0 :         cmd.header = mc_encode_cmd_header(
     530                 :            :                                 DPIO_CMDID_REMOVE_STATIC_DEQUEUE_CHANNEL,
     531                 :            :                                 cmd_flags,
     532                 :            :                                 token);
     533                 :            :         cmd_params = (struct dpio_cmd_static_dequeue_channel *)cmd.params;
     534                 :          0 :         cmd_params->dpcon_id = cpu_to_le32(dpcon_id);
     535                 :            : 
     536                 :            :         /* send command to mc*/
     537                 :          0 :         return mc_send_command(mc_io, &cmd);
     538                 :            : }
     539                 :            : 
     540                 :            : /**
     541                 :            :  * dpio_get_api_version() - Get Data Path I/O API version
     542                 :            :  * @mc_io:      Pointer to MC portal's I/O object
     543                 :            :  * @cmd_flags:  Command flags; one or more of 'MC_CMD_FLAG_'
     544                 :            :  * @major_ver:  Major version of data path i/o API
     545                 :            :  * @minor_ver:  Minor version of data path i/o API
     546                 :            :  *
     547                 :            :  * Return:  '0' on Success; Error code otherwise.
     548                 :            :  */
     549                 :          0 : int dpio_get_api_version(struct fsl_mc_io *mc_io,
     550                 :            :                          uint32_t cmd_flags,
     551                 :            :                          uint16_t *major_ver,
     552                 :            :                          uint16_t *minor_ver)
     553                 :            : {
     554                 :            :         struct dpio_rsp_get_api_version *rsp_params;
     555                 :          0 :         struct mc_command cmd = { 0 };
     556                 :            :         int err;
     557                 :            : 
     558                 :          0 :         cmd.header = mc_encode_cmd_header(DPIO_CMDID_GET_API_VERSION,
     559                 :            :                                         cmd_flags,
     560                 :            :                                         0);
     561                 :            : 
     562                 :          0 :         err = mc_send_command(mc_io, &cmd);
     563         [ #  # ]:          0 :         if (err)
     564                 :            :                 return err;
     565                 :            : 
     566                 :            :         rsp_params = (struct dpio_rsp_get_api_version *)cmd.params;
     567                 :          0 :         *major_ver = le16_to_cpu(rsp_params->major);
     568                 :          0 :         *minor_ver = le16_to_cpu(rsp_params->minor);
     569                 :            : 
     570                 :          0 :         return 0;
     571                 :            : }

Generated by: LCOV version 1.14