LCOV - code coverage report
Current view: top level - drivers/bus/fslmc/mc - dpcon.c (source / functions) Hit Total Coverage
Test: Code coverage Lines: 0 61 0.0 %
Date: 2025-05-01 17:49:45 Functions: 0 10 0.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 0 10 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 2017-2019 NXP
       5                 :            :  *
       6                 :            :  */
       7                 :            : #include <fsl_mc_sys.h>
       8                 :            : #include <fsl_mc_cmd.h>
       9                 :            : #include <fsl_dpcon.h>
      10                 :            : #include <fsl_dpcon_cmd.h>
      11                 :            : 
      12                 :            : #include <eal_export.h>
      13                 :            : 
      14                 :            : /**
      15                 :            :  * dpcon_open() - Open a control session for the specified object
      16                 :            :  * @mc_io:      Pointer to MC portal's I/O object
      17                 :            :  * @cmd_flags:  Command flags; one or more of 'MC_CMD_FLAG_'
      18                 :            :  * @dpcon_id:   DPCON unique ID
      19                 :            :  * @token:      Returned token; use in subsequent API calls
      20                 :            :  *
      21                 :            :  * This function can be used to open a control session for an
      22                 :            :  * already created object; an object may have been declared in
      23                 :            :  * the DPL or by calling the dpcon_create() function.
      24                 :            :  * This function returns a unique authentication token,
      25                 :            :  * associated with the specific object ID and the specific MC
      26                 :            :  * portal; this token must be used in all subsequent commands for
      27                 :            :  * this specific object.
      28                 :            :  *
      29                 :            :  * Return:      '0' on Success; Error code otherwise.
      30                 :            :  */
      31                 :            : RTE_EXPORT_INTERNAL_SYMBOL(dpcon_open)
      32                 :          0 : int dpcon_open(struct fsl_mc_io *mc_io,
      33                 :            :                uint32_t cmd_flags,
      34                 :            :                int dpcon_id,
      35                 :            :                uint16_t *token)
      36                 :            : {
      37                 :          0 :         struct mc_command cmd = { 0 };
      38                 :            :         struct dpcon_cmd_open *dpcon_cmd;
      39                 :            :         int err;
      40                 :            : 
      41                 :            :         /* prepare command */
      42                 :          0 :         cmd.header = mc_encode_cmd_header(DPCON_CMDID_OPEN,
      43                 :            :                                           cmd_flags,
      44                 :            :                                           0);
      45                 :            :         dpcon_cmd = (struct dpcon_cmd_open *)cmd.params;
      46                 :          0 :         dpcon_cmd->dpcon_id = cpu_to_le32(dpcon_id);
      47                 :            : 
      48                 :            :         /* send command to mc*/
      49                 :          0 :         err = mc_send_command(mc_io, &cmd);
      50         [ #  # ]:          0 :         if (err)
      51                 :            :                 return err;
      52                 :            : 
      53                 :            :         /* retrieve response parameters */
      54                 :          0 :         *token = mc_cmd_hdr_read_token(&cmd);
      55                 :            : 
      56                 :          0 :         return 0;
      57                 :            : }
      58                 :            : 
      59                 :            : /**
      60                 :            :  * dpcon_close() - Close the control session of the object
      61                 :            :  * @mc_io:      Pointer to MC portal's I/O object
      62                 :            :  * @cmd_flags:  Command flags; one or more of 'MC_CMD_FLAG_'
      63                 :            :  * @token:      Token of DPCON object
      64                 :            :  *
      65                 :            :  * After this function is called, no further operations are
      66                 :            :  * allowed on the object without opening a new control session.
      67                 :            :  *
      68                 :            :  * Return:      '0' on Success; Error code otherwise.
      69                 :            :  */
      70                 :            : RTE_EXPORT_INTERNAL_SYMBOL(dpcon_close)
      71                 :          0 : int dpcon_close(struct fsl_mc_io *mc_io,
      72                 :            :                 uint32_t cmd_flags,
      73                 :            :                 uint16_t token)
      74                 :            : {
      75                 :          0 :         struct mc_command cmd = { 0 };
      76                 :            : 
      77                 :            :         /* prepare command */
      78                 :          0 :         cmd.header = mc_encode_cmd_header(DPCON_CMDID_CLOSE,
      79                 :            :                                           cmd_flags,
      80                 :            :                                           token);
      81                 :            : 
      82                 :            :         /* send command to mc*/
      83                 :          0 :         return mc_send_command(mc_io, &cmd);
      84                 :            : }
      85                 :            : 
      86                 :            : /**
      87                 :            :  * dpcon_create() - Create the DPCON object.
      88                 :            :  * @mc_io:      Pointer to MC portal's I/O object
      89                 :            :  * @dprc_token: Parent container token; '0' for default container
      90                 :            :  * @cmd_flags:  Command flags; one or more of 'MC_CMD_FLAG_'
      91                 :            :  * @cfg:        Configuration structure
      92                 :            :  * @obj_id:     Returned object id; use in subsequent API calls
      93                 :            :  *
      94                 :            :  * Create the DPCON object, allocate required resources and
      95                 :            :  * perform required initialization.
      96                 :            :  *
      97                 :            :  * The object can be created either by declaring it in the
      98                 :            :  * DPL file, or by calling this function.
      99                 :            :  *
     100                 :            :  * This function accepts an authentication token of a parent
     101                 :            :  * container that this object should be assigned to and returns
     102                 :            :  * an object id. This object_id will be used in all subsequent calls to
     103                 :            :  * this specific object.
     104                 :            :  *
     105                 :            :  * Return:      '0' on Success; Error code otherwise.
     106                 :            :  */
     107                 :          0 : int dpcon_create(struct fsl_mc_io *mc_io,
     108                 :            :                  uint16_t dprc_token,
     109                 :            :                  uint32_t cmd_flags,
     110                 :            :                  const struct dpcon_cfg *cfg,
     111                 :            :                  uint32_t *obj_id)
     112                 :            : {
     113                 :            :         struct dpcon_cmd_create *dpcon_cmd;
     114                 :          0 :         struct mc_command cmd = { 0 };
     115                 :            :         int err;
     116                 :            : 
     117                 :            :         /* prepare command */
     118                 :          0 :         cmd.header = mc_encode_cmd_header(DPCON_CMDID_CREATE,
     119                 :            :                                           cmd_flags,
     120                 :            :                                           dprc_token);
     121                 :            :         dpcon_cmd = (struct dpcon_cmd_create *)cmd.params;
     122                 :          0 :         dpcon_cmd->num_priorities = cfg->num_priorities;
     123                 :            : 
     124                 :            :         /* send command to mc*/
     125                 :          0 :         err = mc_send_command(mc_io, &cmd);
     126         [ #  # ]:          0 :         if (err)
     127                 :            :                 return err;
     128                 :            : 
     129                 :            :         /* retrieve response parameters */
     130                 :          0 :         *obj_id = mc_cmd_read_object_id(&cmd);
     131                 :            : 
     132                 :          0 :         return 0;
     133                 :            : }
     134                 :            : 
     135                 :            : /**
     136                 :            :  * dpcon_destroy() - Destroy the DPCON object and release all its resources.
     137                 :            :  * @mc_io:      Pointer to MC portal's I/O object
     138                 :            :  * @dprc_token: Parent container token; '0' for default container
     139                 :            :  * @cmd_flags:  Command flags; one or more of 'MC_CMD_FLAG_'
     140                 :            :  * @obj_id:     ID of DPCON object
     141                 :            :  *
     142                 :            :  * Return:      '0' on Success; error code otherwise.
     143                 :            :  */
     144                 :          0 : int dpcon_destroy(struct fsl_mc_io *mc_io,
     145                 :            :                   uint16_t dprc_token,
     146                 :            :                   uint32_t cmd_flags,
     147                 :            :                   uint32_t obj_id)
     148                 :            : {
     149                 :            :         struct dpcon_cmd_destroy *cmd_params;
     150                 :          0 :         struct mc_command cmd = { 0 };
     151                 :            : 
     152                 :            :         /* prepare command */
     153                 :          0 :         cmd.header = mc_encode_cmd_header(DPCON_CMDID_DESTROY,
     154                 :            :                                           cmd_flags,
     155                 :            :                                           dprc_token);
     156                 :            :         cmd_params = (struct dpcon_cmd_destroy *)cmd.params;
     157                 :          0 :         cmd_params->object_id = cpu_to_le32(obj_id);
     158                 :            : 
     159                 :            :         /* send command to mc*/
     160                 :          0 :         return mc_send_command(mc_io, &cmd);
     161                 :            : }
     162                 :            : 
     163                 :            : /**
     164                 :            :  * dpcon_enable() - Enable the DPCON
     165                 :            :  * @mc_io:      Pointer to MC portal's I/O object
     166                 :            :  * @cmd_flags:  Command flags; one or more of 'MC_CMD_FLAG_'
     167                 :            :  * @token:      Token of DPCON object
     168                 :            :  *
     169                 :            :  * Return:      '0' on Success; Error code otherwise
     170                 :            :  */
     171                 :            : RTE_EXPORT_INTERNAL_SYMBOL(dpcon_enable)
     172                 :          0 : int dpcon_enable(struct fsl_mc_io *mc_io,
     173                 :            :                  uint32_t cmd_flags,
     174                 :            :                  uint16_t token)
     175                 :            : {
     176                 :          0 :         struct mc_command cmd = { 0 };
     177                 :            : 
     178                 :            :         /* prepare command */
     179                 :          0 :         cmd.header = mc_encode_cmd_header(DPCON_CMDID_ENABLE,
     180                 :            :                                           cmd_flags,
     181                 :            :                                           token);
     182                 :            : 
     183                 :            :         /* send command to mc*/
     184                 :          0 :         return mc_send_command(mc_io, &cmd);
     185                 :            : }
     186                 :            : 
     187                 :            : /**
     188                 :            :  * dpcon_disable() - Disable the DPCON
     189                 :            :  * @mc_io:      Pointer to MC portal's I/O object
     190                 :            :  * @cmd_flags:  Command flags; one or more of 'MC_CMD_FLAG_'
     191                 :            :  * @token:      Token of DPCON object
     192                 :            :  *
     193                 :            :  * Return:      '0' on Success; Error code otherwise
     194                 :            :  */
     195                 :            : RTE_EXPORT_INTERNAL_SYMBOL(dpcon_disable)
     196                 :          0 : int dpcon_disable(struct fsl_mc_io *mc_io,
     197                 :            :                   uint32_t cmd_flags,
     198                 :            :                   uint16_t token)
     199                 :            : {
     200                 :          0 :         struct mc_command cmd = { 0 };
     201                 :            : 
     202                 :            :         /* prepare command */
     203                 :          0 :         cmd.header = mc_encode_cmd_header(DPCON_CMDID_DISABLE,
     204                 :            :                                           cmd_flags,
     205                 :            :                                           token);
     206                 :            : 
     207                 :            :         /* send command to mc*/
     208                 :          0 :         return mc_send_command(mc_io, &cmd);
     209                 :            : }
     210                 :            : 
     211                 :            : /**
     212                 :            :  * dpcon_is_enabled() - Check if the DPCON is enabled.
     213                 :            :  * @mc_io:      Pointer to MC portal's I/O object
     214                 :            :  * @cmd_flags:  Command flags; one or more of 'MC_CMD_FLAG_'
     215                 :            :  * @token:      Token of DPCON object
     216                 :            :  * @en:         Returns '1' if object is enabled; '0' otherwise
     217                 :            :  *
     218                 :            :  * Return:      '0' on Success; Error code otherwise.
     219                 :            :  */
     220                 :          0 : int dpcon_is_enabled(struct fsl_mc_io *mc_io,
     221                 :            :                      uint32_t cmd_flags,
     222                 :            :                      uint16_t token,
     223                 :            :                      int *en)
     224                 :            : {
     225                 :            :         struct dpcon_rsp_is_enabled *dpcon_rsp;
     226                 :          0 :         struct mc_command cmd = { 0 };
     227                 :            :         int err;
     228                 :            : 
     229                 :            :         /* prepare command */
     230                 :          0 :         cmd.header = mc_encode_cmd_header(DPCON_CMDID_IS_ENABLED,
     231                 :            :                                           cmd_flags,
     232                 :            :                                           token);
     233                 :            : 
     234                 :            :         /* send command to mc*/
     235                 :          0 :         err = mc_send_command(mc_io, &cmd);
     236         [ #  # ]:          0 :         if (err)
     237                 :            :                 return err;
     238                 :            : 
     239                 :            :         /* retrieve response parameters */
     240                 :            :         dpcon_rsp = (struct dpcon_rsp_is_enabled *)cmd.params;
     241                 :          0 :         *en = dpcon_rsp->enabled & DPCON_ENABLE;
     242                 :            : 
     243                 :          0 :         return 0;
     244                 :            : }
     245                 :            : 
     246                 :            : /**
     247                 :            :  * dpcon_reset() - Reset the DPCON, returns the object to initial state.
     248                 :            :  * @mc_io:      Pointer to MC portal's I/O object
     249                 :            :  * @cmd_flags:  Command flags; one or more of 'MC_CMD_FLAG_'
     250                 :            :  * @token:      Token of DPCON object
     251                 :            :  *
     252                 :            :  * Return:      '0' on Success; Error code otherwise.
     253                 :            :  */
     254                 :            : RTE_EXPORT_INTERNAL_SYMBOL(dpcon_reset)
     255                 :          0 : int dpcon_reset(struct fsl_mc_io *mc_io,
     256                 :            :                 uint32_t cmd_flags,
     257                 :            :                 uint16_t token)
     258                 :            : {
     259                 :          0 :         struct mc_command cmd = { 0 };
     260                 :            : 
     261                 :            :         /* prepare command */
     262                 :          0 :         cmd.header = mc_encode_cmd_header(DPCON_CMDID_RESET,
     263                 :            :                                           cmd_flags, token);
     264                 :            : 
     265                 :            :         /* send command to mc*/
     266                 :          0 :         return mc_send_command(mc_io, &cmd);
     267                 :            : }
     268                 :            : 
     269                 :            : /**
     270                 :            :  * dpcon_get_attributes() - Retrieve DPCON attributes.
     271                 :            :  * @mc_io:      Pointer to MC portal's I/O object
     272                 :            :  * @cmd_flags:  Command flags; one or more of 'MC_CMD_FLAG_'
     273                 :            :  * @token:      Token of DPCON object
     274                 :            :  * @attr:       Object's attributes
     275                 :            :  *
     276                 :            :  * Return:      '0' on Success; Error code otherwise.
     277                 :            :  */
     278                 :            : RTE_EXPORT_INTERNAL_SYMBOL(dpcon_get_attributes)
     279                 :          0 : int dpcon_get_attributes(struct fsl_mc_io *mc_io,
     280                 :            :                          uint32_t cmd_flags,
     281                 :            :                          uint16_t token,
     282                 :            :                          struct dpcon_attr *attr)
     283                 :            : {
     284                 :            :         struct dpcon_rsp_get_attr *dpcon_rsp;
     285                 :          0 :         struct mc_command cmd = { 0 };
     286                 :            :         int err;
     287                 :            : 
     288                 :            :         /* prepare command */
     289                 :          0 :         cmd.header = mc_encode_cmd_header(DPCON_CMDID_GET_ATTR,
     290                 :            :                                           cmd_flags,
     291                 :            :                                           token);
     292                 :            : 
     293                 :            :         /* send command to mc*/
     294                 :          0 :         err = mc_send_command(mc_io, &cmd);
     295         [ #  # ]:          0 :         if (err)
     296                 :            :                 return err;
     297                 :            : 
     298                 :            :         /* retrieve response parameters */
     299                 :            :         dpcon_rsp = (struct dpcon_rsp_get_attr *)cmd.params;
     300                 :          0 :         attr->id = le32_to_cpu(dpcon_rsp->id);
     301                 :          0 :         attr->qbman_ch_id = le16_to_cpu(dpcon_rsp->qbman_ch_id);
     302                 :          0 :         attr->num_priorities = dpcon_rsp->num_priorities;
     303                 :            : 
     304                 :          0 :         return 0;
     305                 :            : }
     306                 :            : 
     307                 :            : /**
     308                 :            :  * dpcon_get_api_version - Get Data Path Concentrator API version
     309                 :            :  * @mc_io:      Pointer to MC portal's DPCON object
     310                 :            :  * @cmd_flags:  Command flags; one or more of 'MC_CMD_FLAG_'
     311                 :            :  * @major_ver:  Major version of DPCON API
     312                 :            :  * @minor_ver:  Minor version of DPCON API
     313                 :            :  *
     314                 :            :  * Return:      '0' on Success; Error code otherwise
     315                 :            :  */
     316                 :          0 : int dpcon_get_api_version(struct fsl_mc_io *mc_io,
     317                 :            :                           uint32_t cmd_flags,
     318                 :            :                           uint16_t *major_ver,
     319                 :            :                           uint16_t *minor_ver)
     320                 :            : {
     321                 :            :         struct dpcon_rsp_get_api_version *rsp_params;
     322                 :          0 :         struct mc_command cmd = { 0 };
     323                 :            :         int err;
     324                 :            : 
     325                 :            :         /* prepare command */
     326                 :          0 :         cmd.header = mc_encode_cmd_header(DPCON_CMDID_GET_API_VERSION,
     327                 :            :                                           cmd_flags, 0);
     328                 :            : 
     329                 :            :         /* send command to mc */
     330                 :          0 :         err = mc_send_command(mc_io, &cmd);
     331         [ #  # ]:          0 :         if (err)
     332                 :            :                 return err;
     333                 :            : 
     334                 :            :         /* retrieve response parameters */
     335                 :            :         rsp_params = (struct dpcon_rsp_get_api_version *)cmd.params;
     336                 :          0 :         *major_ver = le16_to_cpu(rsp_params->major);
     337                 :          0 :         *minor_ver = le16_to_cpu(rsp_params->minor);
     338                 :            : 
     339                 :          0 :         return 0;
     340                 :            : }

Generated by: LCOV version 1.14