LCOV - code coverage report
Current view: top level - drivers/crypto/dpaa2_sec/mc - dpseci.c (source / functions) Hit Total Coverage
Test: Code coverage Lines: 0 229 0.0 %
Date: 2025-02-01 18:54:23 Functions: 0 21 0.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 0 30 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_dpopr.h>
      10                 :            : #include <fsl_dpseci.h>
      11                 :            : #include <fsl_dpseci_cmd.h>
      12                 :            : 
      13                 :            : /**
      14                 :            :  * dpseci_open() - Open a control session for the specified object
      15                 :            :  * @mc_io:      Pointer to MC portal's I/O object
      16                 :            :  * @cmd_flags:  Command flags; one or more of 'MC_CMD_FLAG_'
      17                 :            :  * @dpseci_id:  DPSECI unique ID
      18                 :            :  * @token:      Returned token; use in subsequent API calls
      19                 :            :  *
      20                 :            :  * This function can be used to open a control session for an
      21                 :            :  * already created object; an object may have been declared in
      22                 :            :  * the DPL or by calling the dpseci_create() function.
      23                 :            :  * This function returns a unique authentication token,
      24                 :            :  * associated with the specific object ID and the specific MC
      25                 :            :  * portal; this token must be used in all subsequent commands for
      26                 :            :  * this specific object.
      27                 :            :  *
      28                 :            :  * Return:      '0' on Success; Error code otherwise.
      29                 :            :  */
      30                 :          0 : int dpseci_open(struct fsl_mc_io *mc_io,
      31                 :            :                 uint32_t cmd_flags,
      32                 :            :                 int dpseci_id,
      33                 :            :                 uint16_t *token)
      34                 :            : {
      35                 :            :         struct dpseci_cmd_open *cmd_params;
      36                 :          0 :         struct mc_command cmd = { 0 };
      37                 :            :         int err;
      38                 :            : 
      39                 :            :         /* prepare command */
      40                 :          0 :         cmd.header = mc_encode_cmd_header(DPSECI_CMDID_OPEN,
      41                 :            :                                           cmd_flags,
      42                 :            :                                           0);
      43                 :            :         cmd_params = (struct dpseci_cmd_open *)cmd.params;
      44                 :          0 :         cmd_params->dpseci_id = cpu_to_le32(dpseci_id);
      45                 :            : 
      46                 :            :         /* send command to mc*/
      47                 :          0 :         err = mc_send_command(mc_io, &cmd);
      48         [ #  # ]:          0 :         if (err)
      49                 :            :                 return err;
      50                 :            : 
      51                 :            :         /* retrieve response parameters */
      52                 :          0 :         *token = mc_cmd_hdr_read_token(&cmd);
      53                 :            : 
      54                 :          0 :         return 0;
      55                 :            : }
      56                 :            : 
      57                 :            : /**
      58                 :            :  * dpseci_close() - Close the control session of the object
      59                 :            :  * @mc_io:      Pointer to MC portal's I/O object
      60                 :            :  * @cmd_flags:  Command flags; one or more of 'MC_CMD_FLAG_'
      61                 :            :  * @token:      Token of DPSECI object
      62                 :            :  *
      63                 :            :  * After this function is called, no further operations are
      64                 :            :  * allowed on the object without opening a new control session.
      65                 :            :  *
      66                 :            :  * Return:      '0' on Success; Error code otherwise.
      67                 :            :  */
      68                 :          0 : int dpseci_close(struct fsl_mc_io *mc_io,
      69                 :            :                  uint32_t cmd_flags,
      70                 :            :                  uint16_t token)
      71                 :            : {
      72                 :          0 :         struct mc_command cmd = { 0 };
      73                 :            : 
      74                 :            :         /* prepare command */
      75                 :          0 :         cmd.header = mc_encode_cmd_header(DPSECI_CMDID_CLOSE,
      76                 :            :                                           cmd_flags,
      77                 :            :                                           token);
      78                 :            : 
      79                 :            :         /* send command to mc*/
      80                 :          0 :         return mc_send_command(mc_io, &cmd);
      81                 :            : }
      82                 :            : 
      83                 :            : /**
      84                 :            :  * dpseci_create() - Create the DPSECI object
      85                 :            :  * @mc_io:      Pointer to MC portal's I/O object
      86                 :            :  * @dprc_token: Parent container token; '0' for default container
      87                 :            :  * @cmd_flags:  Command flags; one or more of 'MC_CMD_FLAG_'
      88                 :            :  * @cfg:        Configuration structure
      89                 :            :  * @obj_id:     Returned object id
      90                 :            :  *
      91                 :            :  * Create the DPSECI object, allocate required resources and
      92                 :            :  * perform required initialization.
      93                 :            :  *
      94                 :            :  * The object can be created either by declaring it in the
      95                 :            :  * DPL file, or by calling this function.
      96                 :            :  *
      97                 :            :  * The function accepts an authentication token of a parent
      98                 :            :  * container that this object should be assigned to. The token
      99                 :            :  * can be '0' so the object will be assigned to the default container.
     100                 :            :  * The newly created object can be opened with the returned
     101                 :            :  * object id and using the container's associated tokens and MC portals.
     102                 :            :  *
     103                 :            :  * Return:      '0' on Success; Error code otherwise.
     104                 :            :  */
     105                 :          0 : int dpseci_create(struct fsl_mc_io *mc_io,
     106                 :            :                   uint16_t dprc_token,
     107                 :            :                   uint32_t cmd_flags,
     108                 :            :                   const struct dpseci_cfg *cfg,
     109                 :            :                   uint32_t *obj_id)
     110                 :            : {
     111                 :            :         struct dpseci_cmd_create *cmd_params;
     112                 :          0 :         struct mc_command cmd = { 0 };
     113                 :            :         int err, i;
     114                 :            : 
     115                 :            :         /* prepare command */
     116                 :          0 :         cmd.header = mc_encode_cmd_header(DPSECI_CMDID_CREATE,
     117                 :            :                                           cmd_flags,
     118                 :            :                                           dprc_token);
     119                 :            :         cmd_params = (struct dpseci_cmd_create *)cmd.params;
     120         [ #  # ]:          0 :         for (i = 0; i < 8; i++)
     121                 :          0 :                 cmd_params->priorities[i] = cfg->priorities[i];
     122         [ #  # ]:          0 :         for (i = 0; i < 8; i++)
     123                 :          0 :                 cmd_params->priorities2[i] = cfg->priorities[8 + i];
     124                 :          0 :         cmd_params->num_tx_queues = cfg->num_tx_queues;
     125                 :          0 :         cmd_params->num_rx_queues = cfg->num_rx_queues;
     126                 :          0 :         cmd_params->options = cpu_to_le32(cfg->options);
     127                 :            : 
     128                 :            :         /* send command to mc*/
     129                 :          0 :         err = mc_send_command(mc_io, &cmd);
     130         [ #  # ]:          0 :         if (err)
     131                 :            :                 return err;
     132                 :            : 
     133                 :            :         /* retrieve response parameters */
     134                 :          0 :         *obj_id = mc_cmd_read_object_id(&cmd);
     135                 :            : 
     136                 :          0 :         return 0;
     137                 :            : }
     138                 :            : 
     139                 :            : /**
     140                 :            :  * dpseci_destroy() - Destroy the DPSECI object and release all its resources.
     141                 :            :  * @mc_io:      Pointer to MC portal's I/O object
     142                 :            :  * @dprc_token: Parent container token; '0' for default container
     143                 :            :  * @cmd_flags:  Command flags; one or more of 'MC_CMD_FLAG_'
     144                 :            :  * @object_id:  The object id; it must be a valid id within the container that
     145                 :            :  * created this object;
     146                 :            :  *
     147                 :            :  * The function accepts the authentication token of the parent container that
     148                 :            :  * created the object (not the one that currently owns the object). The object
     149                 :            :  * is searched within parent using the provided 'object_id'.
     150                 :            :  * All tokens to the object must be closed before calling destroy.
     151                 :            :  *
     152                 :            :  * Return:      '0' on Success; error code otherwise.
     153                 :            :  */
     154                 :          0 : int dpseci_destroy(struct fsl_mc_io *mc_io,
     155                 :            :                    uint16_t dprc_token,
     156                 :            :                    uint32_t cmd_flags,
     157                 :            :                    uint32_t object_id)
     158                 :            : {
     159                 :            :         struct dpseci_cmd_destroy *cmd_params;
     160                 :          0 :         struct mc_command cmd = { 0 };
     161                 :            : 
     162                 :            :         /* prepare command */
     163                 :          0 :         cmd.header = mc_encode_cmd_header(DPSECI_CMDID_DESTROY,
     164                 :            :                                           cmd_flags,
     165                 :            :                                           dprc_token);
     166                 :            :         cmd_params = (struct dpseci_cmd_destroy *)cmd.params;
     167                 :          0 :         cmd_params->dpseci_id = cpu_to_le32(object_id);
     168                 :            : 
     169                 :            :         /* send command to mc*/
     170                 :          0 :         return mc_send_command(mc_io, &cmd);
     171                 :            : }
     172                 :            : 
     173                 :            : /**
     174                 :            :  * dpseci_enable() - Enable the DPSECI, allow sending and receiving frames.
     175                 :            :  * @mc_io:      Pointer to MC portal's I/O object
     176                 :            :  * @cmd_flags:  Command flags; one or more of 'MC_CMD_FLAG_'
     177                 :            :  * @token:      Token of DPSECI object
     178                 :            :  *
     179                 :            :  * Return:      '0' on Success; Error code otherwise.
     180                 :            :  */
     181                 :          0 : int dpseci_enable(struct fsl_mc_io *mc_io,
     182                 :            :                   uint32_t cmd_flags,
     183                 :            :                   uint16_t token)
     184                 :            : {
     185                 :          0 :         struct mc_command cmd = { 0 };
     186                 :            : 
     187                 :            :         /* prepare command */
     188                 :          0 :         cmd.header = mc_encode_cmd_header(DPSECI_CMDID_ENABLE,
     189                 :            :                                           cmd_flags,
     190                 :            :                                           token);
     191                 :            : 
     192                 :            :         /* send command to mc*/
     193                 :          0 :         return mc_send_command(mc_io, &cmd);
     194                 :            : }
     195                 :            : 
     196                 :            : /**
     197                 :            :  * dpseci_disable() - Disable the DPSECI, stop sending and receiving frames.
     198                 :            :  * @mc_io:      Pointer to MC portal's I/O object
     199                 :            :  * @cmd_flags:  Command flags; one or more of 'MC_CMD_FLAG_'
     200                 :            :  * @token:      Token of DPSECI object
     201                 :            :  *
     202                 :            :  * Return:      '0' on Success; Error code otherwise.
     203                 :            :  */
     204                 :          0 : int dpseci_disable(struct fsl_mc_io *mc_io,
     205                 :            :                    uint32_t cmd_flags,
     206                 :            :                    uint16_t token)
     207                 :            : {
     208                 :          0 :         struct mc_command cmd = { 0 };
     209                 :            : 
     210                 :            :         /* prepare command */
     211                 :          0 :         cmd.header = mc_encode_cmd_header(DPSECI_CMDID_DISABLE,
     212                 :            :                                           cmd_flags,
     213                 :            :                                           token);
     214                 :            : 
     215                 :            :         /* send command to mc*/
     216                 :          0 :         return mc_send_command(mc_io, &cmd);
     217                 :            : }
     218                 :            : 
     219                 :            : /**
     220                 :            :  * dpseci_is_enabled() - Check if the DPSECI is enabled.
     221                 :            :  * @mc_io:      Pointer to MC portal's I/O object
     222                 :            :  * @cmd_flags:  Command flags; one or more of 'MC_CMD_FLAG_'
     223                 :            :  * @token:      Token of DPSECI object
     224                 :            :  * @en:         Returns '1' if object is enabled; '0' otherwise
     225                 :            :  *
     226                 :            :  * Return:      '0' on Success; Error code otherwise.
     227                 :            :  */
     228                 :          0 : int dpseci_is_enabled(struct fsl_mc_io *mc_io,
     229                 :            :                       uint32_t cmd_flags,
     230                 :            :                       uint16_t token,
     231                 :            :                       int *en)
     232                 :            : {
     233                 :            :         struct dpseci_rsp_is_enabled *rsp_params;
     234                 :          0 :         struct mc_command cmd = { 0 };
     235                 :            :         int err;
     236                 :            : 
     237                 :            :         /* prepare command */
     238                 :          0 :         cmd.header = mc_encode_cmd_header(DPSECI_CMDID_IS_ENABLED,
     239                 :            :                                           cmd_flags,
     240                 :            :                                           token);
     241                 :            : 
     242                 :            :         /* send command to mc*/
     243                 :          0 :         err = mc_send_command(mc_io, &cmd);
     244         [ #  # ]:          0 :         if (err)
     245                 :            :                 return err;
     246                 :            : 
     247                 :            :         /* retrieve response parameters */
     248                 :            :         rsp_params = (struct dpseci_rsp_is_enabled *)cmd.params;
     249                 :          0 :         *en = dpseci_get_field(rsp_params->en, ENABLE);
     250                 :            : 
     251                 :          0 :         return 0;
     252                 :            : }
     253                 :            : 
     254                 :            : /**
     255                 :            :  * dpseci_reset() - Reset the DPSECI, returns the object to initial state.
     256                 :            :  * @mc_io:      Pointer to MC portal's I/O object
     257                 :            :  * @cmd_flags:  Command flags; one or more of 'MC_CMD_FLAG_'
     258                 :            :  * @token:      Token of DPSECI object
     259                 :            :  *
     260                 :            :  * Return:      '0' on Success; Error code otherwise.
     261                 :            :  */
     262                 :          0 : int dpseci_reset(struct fsl_mc_io *mc_io,
     263                 :            :                  uint32_t cmd_flags,
     264                 :            :                  uint16_t token)
     265                 :            : {
     266                 :          0 :         struct mc_command cmd = { 0 };
     267                 :            : 
     268                 :            :         /* prepare command */
     269                 :          0 :         cmd.header = mc_encode_cmd_header(DPSECI_CMDID_RESET,
     270                 :            :                                           cmd_flags,
     271                 :            :                                           token);
     272                 :            : 
     273                 :            :         /* send command to mc*/
     274                 :          0 :         return mc_send_command(mc_io, &cmd);
     275                 :            : }
     276                 :            : 
     277                 :            : /**
     278                 :            :  * dpseci_get_attributes() - Retrieve DPSECI attributes.
     279                 :            :  * @mc_io:      Pointer to MC portal's I/O object
     280                 :            :  * @cmd_flags:  Command flags; one or more of 'MC_CMD_FLAG_'
     281                 :            :  * @token:      Token of DPSECI object
     282                 :            :  * @attr:       Returned object's attributes
     283                 :            :  *
     284                 :            :  * Return:      '0' on Success; Error code otherwise.
     285                 :            :  */
     286                 :          0 : int dpseci_get_attributes(struct fsl_mc_io *mc_io,
     287                 :            :                           uint32_t cmd_flags,
     288                 :            :                           uint16_t token,
     289                 :            :                           struct dpseci_attr *attr)
     290                 :            : {
     291                 :            :         struct dpseci_rsp_get_attr *rsp_params;
     292                 :          0 :         struct mc_command cmd = { 0 };
     293                 :            :         int err;
     294                 :            : 
     295                 :            :         /* prepare command */
     296                 :          0 :         cmd.header = mc_encode_cmd_header(DPSECI_CMDID_GET_ATTR,
     297                 :            :                                           cmd_flags,
     298                 :            :                                           token);
     299                 :            : 
     300                 :            :         /* send command to mc*/
     301                 :          0 :         err = mc_send_command(mc_io, &cmd);
     302         [ #  # ]:          0 :         if (err)
     303                 :            :                 return err;
     304                 :            : 
     305                 :            :         /* retrieve response parameters */
     306                 :            :         rsp_params = (struct dpseci_rsp_get_attr *)cmd.params;
     307                 :          0 :         attr->id = le32_to_cpu(rsp_params->id);
     308                 :          0 :         attr->options = le32_to_cpu(rsp_params->options);
     309                 :          0 :         attr->num_tx_queues = rsp_params->num_tx_queues;
     310                 :          0 :         attr->num_rx_queues = rsp_params->num_rx_queues;
     311                 :            : 
     312                 :          0 :         return 0;
     313                 :            : }
     314                 :            : 
     315                 :            : /**
     316                 :            :  * dpseci_set_rx_queue() - Set Rx queue configuration
     317                 :            :  * @mc_io:      Pointer to MC portal's I/O object
     318                 :            :  * @cmd_flags:  Command flags; one or more of 'MC_CMD_FLAG_'
     319                 :            :  * @token:      Token of DPSECI object
     320                 :            :  * @queue:      Select the queue relative to number of
     321                 :            :  *              priorities configured at DPSECI creation; use
     322                 :            :  *              DPSECI_ALL_QUEUES to configure all Rx queues identically.
     323                 :            :  * @cfg:        Rx queue configuration
     324                 :            :  *
     325                 :            :  * Return:      '0' on Success; Error code otherwise.
     326                 :            :  */
     327                 :          0 : int dpseci_set_rx_queue(struct fsl_mc_io *mc_io,
     328                 :            :                         uint32_t cmd_flags,
     329                 :            :                         uint16_t token,
     330                 :            :                         uint8_t queue,
     331                 :            :                         const struct dpseci_rx_queue_cfg *cfg)
     332                 :            : {
     333                 :            :         struct dpseci_cmd_set_rx_queue *cmd_params;
     334                 :          0 :         struct mc_command cmd = { 0 };
     335                 :            : 
     336                 :            :         /* prepare command */
     337                 :          0 :         cmd.header = mc_encode_cmd_header(DPSECI_CMDID_SET_RX_QUEUE,
     338                 :            :                                           cmd_flags,
     339                 :            :                                           token);
     340                 :            :         cmd_params = (struct dpseci_cmd_set_rx_queue *)cmd.params;
     341                 :          0 :         cmd_params->dest_id = cpu_to_le32(cfg->dest_cfg.dest_id);
     342                 :          0 :         cmd_params->dest_priority = cfg->dest_cfg.priority;
     343                 :          0 :         cmd_params->queue = queue;
     344                 :          0 :         cmd_params->user_ctx = cpu_to_le64(cfg->user_ctx);
     345                 :          0 :         cmd_params->options = cpu_to_le32(cfg->options);
     346                 :          0 :         dpseci_set_field(cmd_params->dest_type,
     347                 :            :                          DEST_TYPE,
     348                 :            :                          cfg->dest_cfg.dest_type);
     349                 :          0 :         dpseci_set_field(cmd_params->order_preservation_en,
     350                 :            :                          ORDER_PRESERVATION,
     351                 :            :                          cfg->order_preservation_en);
     352                 :            : 
     353                 :            :         /* send command to mc*/
     354                 :          0 :         return mc_send_command(mc_io, &cmd);
     355                 :            : }
     356                 :            : 
     357                 :            : /**
     358                 :            :  * dpseci_get_rx_queue() - Retrieve Rx queue attributes.
     359                 :            :  * @mc_io:      Pointer to MC portal's I/O object
     360                 :            :  * @cmd_flags:  Command flags; one or more of 'MC_CMD_FLAG_'
     361                 :            :  * @token:      Token of DPSECI object
     362                 :            :  * @queue:      Select the queue relative to number of
     363                 :            :  *                              priorities configured at DPSECI creation
     364                 :            :  * @attr:       Returned Rx queue attributes
     365                 :            :  *
     366                 :            :  * Return:      '0' on Success; Error code otherwise.
     367                 :            :  */
     368                 :          0 : int dpseci_get_rx_queue(struct fsl_mc_io *mc_io,
     369                 :            :                         uint32_t cmd_flags,
     370                 :            :                         uint16_t token,
     371                 :            :                         uint8_t queue,
     372                 :            :                         struct dpseci_rx_queue_attr *attr)
     373                 :            : {
     374                 :            :         struct dpseci_rsp_get_rx_queue *rsp_params;
     375                 :            :         struct dpseci_cmd_get_queue *cmd_params;
     376                 :          0 :         struct mc_command cmd = { 0 };
     377                 :            :         int err;
     378                 :            : 
     379                 :            :         /* prepare command */
     380                 :          0 :         cmd.header = mc_encode_cmd_header(DPSECI_CMDID_GET_RX_QUEUE,
     381                 :            :                                           cmd_flags,
     382                 :            :                                           token);
     383                 :            :         cmd_params = (struct dpseci_cmd_get_queue *)cmd.params;
     384                 :          0 :         cmd_params->queue = queue;
     385                 :            : 
     386                 :            :         /* send command to mc*/
     387                 :          0 :         err = mc_send_command(mc_io, &cmd);
     388         [ #  # ]:          0 :         if (err)
     389                 :            :                 return err;
     390                 :            : 
     391                 :            :         /* retrieve response parameters */
     392                 :            :         rsp_params = (struct dpseci_rsp_get_rx_queue *)cmd.params;
     393                 :          0 :         attr->user_ctx = le64_to_cpu(rsp_params->user_ctx);
     394                 :          0 :         attr->fqid = le32_to_cpu(rsp_params->fqid);
     395                 :          0 :         attr->dest_cfg.dest_id = le32_to_cpu(rsp_params->dest_id);
     396                 :          0 :         attr->dest_cfg.priority = rsp_params->dest_priority;
     397                 :          0 :         attr->dest_cfg.dest_type =
     398                 :          0 :                 dpseci_get_field(rsp_params->dest_type,
     399                 :            :                                  DEST_TYPE);
     400                 :          0 :         attr->order_preservation_en =
     401                 :          0 :                 dpseci_get_field(rsp_params->order_preservation_en,
     402                 :            :                                  ORDER_PRESERVATION);
     403                 :            : 
     404                 :          0 :         return 0;
     405                 :            : }
     406                 :            : 
     407                 :            : /**
     408                 :            :  * dpseci_get_tx_queue() - Retrieve Tx queue attributes.
     409                 :            :  * @mc_io:      Pointer to MC portal's I/O object
     410                 :            :  * @cmd_flags:  Command flags; one or more of 'MC_CMD_FLAG_'
     411                 :            :  * @token:      Token of DPSECI object
     412                 :            :  * @queue:      Select the queue relative to number of
     413                 :            :  *              priorities configured at DPSECI creation
     414                 :            :  * @attr:       Returned Tx queue attributes
     415                 :            :  *
     416                 :            :  * Return:      '0' on Success; Error code otherwise.
     417                 :            :  */
     418                 :          0 : int dpseci_get_tx_queue(struct fsl_mc_io *mc_io,
     419                 :            :                         uint32_t cmd_flags,
     420                 :            :                         uint16_t token,
     421                 :            :                         uint8_t queue,
     422                 :            :                         struct dpseci_tx_queue_attr *attr)
     423                 :            : {
     424                 :            :         struct dpseci_rsp_get_tx_queue *rsp_params;
     425                 :            :         struct dpseci_cmd_get_queue *cmd_params;
     426                 :          0 :         struct mc_command cmd = { 0 };
     427                 :            :         int err;
     428                 :            : 
     429                 :            :         /* prepare command */
     430                 :          0 :         cmd.header = mc_encode_cmd_header(DPSECI_CMDID_GET_TX_QUEUE,
     431                 :            :                                           cmd_flags,
     432                 :            :                                           token);
     433                 :            :         cmd_params = (struct dpseci_cmd_get_queue *)cmd.params;
     434                 :          0 :         cmd_params->queue = queue;
     435                 :            : 
     436                 :            :         /* send command to mc*/
     437                 :          0 :         err = mc_send_command(mc_io, &cmd);
     438         [ #  # ]:          0 :         if (err)
     439                 :            :                 return err;
     440                 :            : 
     441                 :            :         /* retrieve response parameters */
     442                 :            :         rsp_params = (struct dpseci_rsp_get_tx_queue *)cmd.params;
     443                 :          0 :         attr->fqid = le32_to_cpu(rsp_params->fqid);
     444                 :          0 :         attr->priority = rsp_params->priority;
     445                 :            : 
     446                 :          0 :         return 0;
     447                 :            : }
     448                 :            : 
     449                 :            : /**
     450                 :            :  * dpseci_get_sec_attr() - Retrieve SEC accelerator attributes.
     451                 :            :  * @mc_io:      Pointer to MC portal's I/O object
     452                 :            :  * @cmd_flags:  Command flags; one or more of 'MC_CMD_FLAG_'
     453                 :            :  * @token:      Token of DPSECI object
     454                 :            :  * @attr:       Returned SEC attributes
     455                 :            :  *
     456                 :            :  * Return:      '0' on Success; Error code otherwise.
     457                 :            :  */
     458                 :          0 : int dpseci_get_sec_attr(struct fsl_mc_io *mc_io,
     459                 :            :                         uint32_t cmd_flags,
     460                 :            :                         uint16_t token,
     461                 :            :                         struct dpseci_sec_attr *attr)
     462                 :            : {
     463                 :            :         struct dpseci_rsp_get_sec_attr *rsp_params;
     464                 :          0 :         struct mc_command cmd = { 0 };
     465                 :            :         int err;
     466                 :            : 
     467                 :            :         /* prepare command */
     468                 :          0 :         cmd.header = mc_encode_cmd_header(DPSECI_CMDID_GET_SEC_ATTR,
     469                 :            :                                           cmd_flags,
     470                 :            :                                           token);
     471                 :            : 
     472                 :            :         /* send command to mc*/
     473                 :          0 :         err = mc_send_command(mc_io, &cmd);
     474         [ #  # ]:          0 :         if (err)
     475                 :            :                 return err;
     476                 :            : 
     477                 :            :         /* retrieve response parameters */
     478                 :            :         rsp_params = (struct dpseci_rsp_get_sec_attr *)cmd.params;
     479                 :          0 :         attr->ip_id = le16_to_cpu(rsp_params->ip_id);
     480                 :          0 :         attr->major_rev = rsp_params->major_rev;
     481                 :          0 :         attr->minor_rev = rsp_params->minor_rev;
     482                 :          0 :         attr->era = rsp_params->era;
     483                 :          0 :         attr->deco_num = rsp_params->deco_num;
     484                 :          0 :         attr->zuc_auth_acc_num = rsp_params->zuc_auth_acc_num;
     485                 :          0 :         attr->zuc_enc_acc_num = rsp_params->zuc_enc_acc_num;
     486                 :          0 :         attr->snow_f8_acc_num = rsp_params->snow_f8_acc_num;
     487                 :          0 :         attr->snow_f9_acc_num = rsp_params->snow_f9_acc_num;
     488                 :          0 :         attr->crc_acc_num = rsp_params->crc_acc_num;
     489                 :          0 :         attr->pk_acc_num = rsp_params->pk_acc_num;
     490                 :          0 :         attr->kasumi_acc_num = rsp_params->kasumi_acc_num;
     491                 :          0 :         attr->rng_acc_num = rsp_params->rng_acc_num;
     492                 :          0 :         attr->md_acc_num = rsp_params->md_acc_num;
     493                 :          0 :         attr->arc4_acc_num = rsp_params->arc4_acc_num;
     494                 :          0 :         attr->des_acc_num = rsp_params->des_acc_num;
     495                 :          0 :         attr->aes_acc_num = rsp_params->aes_acc_num;
     496                 :          0 :         attr->ccha_acc_num = rsp_params->ccha_acc_num;
     497                 :          0 :         attr->ptha_acc_num = rsp_params->ptha_acc_num;
     498                 :            : 
     499                 :          0 :         return 0;
     500                 :            : }
     501                 :            : 
     502                 :            : /**
     503                 :            :  * dpseci_get_sec_counters() - Retrieve SEC accelerator counters.
     504                 :            :  * @mc_io:      Pointer to MC portal's I/O object
     505                 :            :  * @cmd_flags:  Command flags; one or more of 'MC_CMD_FLAG_'
     506                 :            :  * @token:      Token of DPSECI object
     507                 :            :  * @counters:   Returned SEC counters
     508                 :            :  *
     509                 :            :  * Return:      '0' on Success; Error code otherwise.
     510                 :            :  */
     511                 :          0 : int dpseci_get_sec_counters(struct fsl_mc_io *mc_io,
     512                 :            :                             uint32_t cmd_flags,
     513                 :            :                             uint16_t token,
     514                 :            :                             struct dpseci_sec_counters *counters)
     515                 :            : {
     516                 :            :         struct dpseci_rsp_get_sec_counters *rsp_params;
     517                 :          0 :         struct mc_command cmd = { 0 };
     518                 :            :         int err;
     519                 :            : 
     520                 :            :         /* prepare command */
     521                 :          0 :         cmd.header = mc_encode_cmd_header(DPSECI_CMDID_GET_SEC_COUNTERS,
     522                 :            :                                           cmd_flags,
     523                 :            :                                           token);
     524                 :            : 
     525                 :            :         /* send command to mc*/
     526                 :          0 :         err = mc_send_command(mc_io, &cmd);
     527         [ #  # ]:          0 :         if (err)
     528                 :            :                 return err;
     529                 :            : 
     530                 :            :         /* retrieve response parameters */
     531                 :            :         rsp_params = (struct dpseci_rsp_get_sec_counters *)cmd.params;
     532                 :          0 :         counters->dequeued_requests =
     533                 :          0 :                                 le64_to_cpu(rsp_params->dequeued_requests);
     534                 :          0 :         counters->ob_enc_requests = le64_to_cpu(rsp_params->ob_enc_requests);
     535                 :          0 :         counters->ib_dec_requests = le64_to_cpu(rsp_params->ib_dec_requests);
     536                 :          0 :         counters->ob_enc_bytes = le64_to_cpu(rsp_params->ob_enc_bytes);
     537                 :          0 :         counters->ob_prot_bytes = le64_to_cpu(rsp_params->ob_prot_bytes);
     538                 :          0 :         counters->ib_dec_bytes = le64_to_cpu(rsp_params->ib_dec_bytes);
     539                 :          0 :         counters->ib_valid_bytes = le64_to_cpu(rsp_params->ib_valid_bytes);
     540                 :            : 
     541                 :          0 :         return 0;
     542                 :            : }
     543                 :            : 
     544                 :            : /**
     545                 :            :  * dpseci_get_api_version() - Get Data Path SEC Interface API version
     546                 :            :  * @mc_io:  Pointer to MC portal's I/O object
     547                 :            :  * @cmd_flags:  Command flags; one or more of 'MC_CMD_FLAG_'
     548                 :            :  * @major_ver:  Major version of data path sec API
     549                 :            :  * @minor_ver:  Minor version of data path sec API
     550                 :            :  *
     551                 :            :  * Return:  '0' on Success; Error code otherwise.
     552                 :            :  */
     553                 :          0 : int dpseci_get_api_version(struct fsl_mc_io *mc_io,
     554                 :            :                            uint32_t cmd_flags,
     555                 :            :                            uint16_t *major_ver,
     556                 :            :                            uint16_t *minor_ver)
     557                 :            : {
     558                 :            :         struct dpseci_rsp_get_api_version *rsp_params;
     559                 :          0 :         struct mc_command cmd = { 0 };
     560                 :            :         int err;
     561                 :            : 
     562                 :          0 :         cmd.header = mc_encode_cmd_header(DPSECI_CMDID_GET_API_VERSION,
     563                 :            :                                         cmd_flags,
     564                 :            :                                         0);
     565                 :            : 
     566                 :          0 :         err = mc_send_command(mc_io, &cmd);
     567         [ #  # ]:          0 :         if (err)
     568                 :            :                 return err;
     569                 :            : 
     570                 :            :         rsp_params = (struct dpseci_rsp_get_api_version *)cmd.params;
     571                 :          0 :         *major_ver = le16_to_cpu(rsp_params->major);
     572                 :          0 :         *minor_ver = le16_to_cpu(rsp_params->minor);
     573                 :            : 
     574                 :          0 :         return 0;
     575                 :            : }
     576                 :            : 
     577                 :            : /**
     578                 :            :  * dpseci_set_opr() - Set Order Restoration configuration.
     579                 :            :  * @mc_io:      Pointer to MC portal's I/O object
     580                 :            :  * @cmd_flags:  Command flags; one or more of 'MC_CMD_FLAG_'
     581                 :            :  * @token:      Token of DPSECI object
     582                 :            :  * @index:      The queue index
     583                 :            :  * @options:    Configuration mode options
     584                 :            :  *                      can be OPR_OPT_CREATE or OPR_OPT_RETIRE
     585                 :            :  * @cfg:        Configuration options for the OPR
     586                 :            :  *
     587                 :            :  * Return:      '0' on Success; Error code otherwise.
     588                 :            :  */
     589                 :          0 : int dpseci_set_opr(struct fsl_mc_io *mc_io,
     590                 :            :                    uint32_t cmd_flags,
     591                 :            :                    uint16_t token,
     592                 :            :                    uint8_t index,
     593                 :            :                    uint8_t options,
     594                 :            :                    struct opr_cfg *cfg)
     595                 :            : {
     596                 :            :         struct dpseci_cmd_set_opr *cmd_params;
     597                 :          0 :         struct mc_command cmd = { 0 };
     598                 :            : 
     599                 :            :         /* prepare command */
     600                 :          0 :         cmd.header = mc_encode_cmd_header(DPSECI_CMDID_SET_OPR,
     601                 :            :                                           cmd_flags,
     602                 :            :                                           token);
     603                 :            :         cmd_params = (struct dpseci_cmd_set_opr *)cmd.params;
     604                 :          0 :         cmd_params->index = index;
     605                 :          0 :         cmd_params->options = options;
     606                 :          0 :         cmd_params->oloe = cfg->oloe;
     607                 :          0 :         cmd_params->oeane = cfg->oeane;
     608                 :          0 :         cmd_params->olws = cfg->olws;
     609                 :          0 :         cmd_params->oa = cfg->oa;
     610                 :          0 :         cmd_params->oprrws = cfg->oprrws;
     611                 :            : 
     612                 :            :         /* send command to mc*/
     613                 :          0 :         return mc_send_command(mc_io, &cmd);
     614                 :            : }
     615                 :            : 
     616                 :            : /**
     617                 :            :  * dpseci_get_opr() - Retrieve Order Restoration config and query.
     618                 :            :  * @mc_io:      Pointer to MC portal's I/O object
     619                 :            :  * @cmd_flags:  Command flags; one or more of 'MC_CMD_FLAG_'
     620                 :            :  * @token:      Token of DPSECI object
     621                 :            :  * @index:      The queue index
     622                 :            :  * @cfg:        Returned OPR configuration
     623                 :            :  * @qry:        Returned OPR query
     624                 :            :  *
     625                 :            :  * Return:     '0' on Success; Error code otherwise.
     626                 :            :  */
     627                 :          0 : int dpseci_get_opr(struct fsl_mc_io *mc_io,
     628                 :            :                    uint32_t cmd_flags,
     629                 :            :                    uint16_t token,
     630                 :            :                    uint8_t index,
     631                 :            :                    struct opr_cfg *cfg,
     632                 :            :                    struct opr_qry *qry)
     633                 :            : {
     634                 :            :         struct dpseci_rsp_get_opr *rsp_params;
     635                 :            :         struct dpseci_cmd_get_opr *cmd_params;
     636                 :          0 :         struct mc_command cmd = { 0 };
     637                 :            :         int err;
     638                 :            : 
     639                 :            :         /* prepare command */
     640                 :          0 :         cmd.header = mc_encode_cmd_header(DPSECI_CMDID_GET_OPR,
     641                 :            :                                           cmd_flags,
     642                 :            :                                           token);
     643                 :            :         cmd_params = (struct dpseci_cmd_get_opr *)cmd.params;
     644                 :          0 :         cmd_params->index = index;
     645                 :            : 
     646                 :            :         /* send command to mc*/
     647                 :          0 :         err = mc_send_command(mc_io, &cmd);
     648         [ #  # ]:          0 :         if (err)
     649                 :            :                 return err;
     650                 :            : 
     651                 :            :         /* retrieve response parameters */
     652                 :            :         rsp_params = (struct dpseci_rsp_get_opr *)cmd.params;
     653                 :          0 :         cfg->oloe = rsp_params->oloe;
     654                 :          0 :         cfg->oeane = rsp_params->oeane;
     655                 :          0 :         cfg->olws = rsp_params->olws;
     656                 :          0 :         cfg->oa = rsp_params->oa;
     657                 :          0 :         cfg->oprrws = rsp_params->oprrws;
     658                 :          0 :         qry->rip = dpseci_get_field(rsp_params->flags, RIP);
     659                 :          0 :         qry->enable = dpseci_get_field(rsp_params->flags, OPR_ENABLE);
     660                 :          0 :         qry->nesn = le16_to_cpu(rsp_params->nesn);
     661                 :          0 :         qry->ndsn = le16_to_cpu(rsp_params->ndsn);
     662                 :          0 :         qry->ea_tseq = le16_to_cpu(rsp_params->ea_tseq);
     663                 :          0 :         qry->tseq_nlis = dpseci_get_field(rsp_params->tseq_nlis, TSEQ_NLIS);
     664                 :          0 :         qry->ea_hseq = le16_to_cpu(rsp_params->ea_hseq);
     665                 :          0 :         qry->hseq_nlis = dpseci_get_field(rsp_params->hseq_nlis, HSEQ_NLIS);
     666                 :          0 :         qry->ea_hptr = le16_to_cpu(rsp_params->ea_hptr);
     667                 :          0 :         qry->ea_tptr = le16_to_cpu(rsp_params->ea_tptr);
     668                 :          0 :         qry->opr_vid = le16_to_cpu(rsp_params->opr_vid);
     669                 :          0 :         qry->opr_id = le16_to_cpu(rsp_params->opr_id);
     670                 :            : 
     671                 :          0 :         return 0;
     672                 :            : }
     673                 :            : 
     674                 :            : /**
     675                 :            :  * dpseci_set_congestion_notification() - Set congestion group
     676                 :            :  *      notification configuration
     677                 :            :  * @mc_io:      Pointer to MC portal's I/O object
     678                 :            :  * @cmd_flags:  Command flags; one or more of 'MC_CMD_FLAG_'
     679                 :            :  * @token:      Token of DPSECI object
     680                 :            :  * @cfg:        congestion notification configuration
     681                 :            :  *
     682                 :            :  * Return:      '0' on success, error code otherwise
     683                 :            :  */
     684                 :          0 : int dpseci_set_congestion_notification(
     685                 :            :                         struct fsl_mc_io *mc_io,
     686                 :            :                         uint32_t cmd_flags,
     687                 :            :                         uint16_t token,
     688                 :            :                         const struct dpseci_congestion_notification_cfg *cfg)
     689                 :            : {
     690                 :            :         struct dpseci_cmd_set_congestion_notification *cmd_params;
     691                 :          0 :         struct mc_command cmd = { 0 };
     692                 :            : 
     693                 :            :         /* prepare command */
     694                 :          0 :         cmd.header = mc_encode_cmd_header(
     695                 :            :                         DPSECI_CMDID_SET_CONGESTION_NOTIFICATION,
     696                 :            :                         cmd_flags,
     697                 :            :                         token);
     698                 :            : 
     699                 :            :         cmd_params =
     700                 :            :                 (struct dpseci_cmd_set_congestion_notification *)cmd.params;
     701                 :          0 :         cmd_params->dest_id = cfg->dest_cfg.dest_id;
     702                 :          0 :         cmd_params->dest_priority = cfg->dest_cfg.priority;
     703                 :          0 :         cmd_params->message_ctx = cfg->message_ctx;
     704                 :          0 :         cmd_params->message_iova = cfg->message_iova;
     705                 :          0 :         cmd_params->notification_mode = cfg->notification_mode;
     706                 :          0 :         cmd_params->threshold_entry = cfg->threshold_entry;
     707                 :          0 :         cmd_params->threshold_exit = cfg->threshold_exit;
     708                 :          0 :         dpseci_set_field(cmd_params->type_units,
     709                 :            :                          DEST_TYPE,
     710                 :            :                          cfg->dest_cfg.dest_type);
     711                 :          0 :         dpseci_set_field(cmd_params->type_units,
     712                 :            :                          CG_UNITS,
     713                 :            :                          cfg->units);
     714                 :            : 
     715                 :            :         /* send command to mc*/
     716                 :          0 :         return mc_send_command(mc_io, &cmd);
     717                 :            : }
     718                 :            : 
     719                 :            : /**
     720                 :            :  * dpseci_get_congestion_notification() - Get congestion group
     721                 :            :  *      notification configuration
     722                 :            :  * @mc_io:      Pointer to MC portal's I/O object
     723                 :            :  * @cmd_flags:  Command flags; one or more of 'MC_CMD_FLAG_'
     724                 :            :  * @token:      Token of DPSECI object
     725                 :            :  * @cfg:        congestion notification configuration
     726                 :            :  *
     727                 :            :  * Return:      '0' on success, error code otherwise
     728                 :            :  */
     729                 :          0 : int dpseci_get_congestion_notification(
     730                 :            :                                 struct fsl_mc_io *mc_io,
     731                 :            :                                 uint32_t cmd_flags,
     732                 :            :                                 uint16_t token,
     733                 :            :                                 struct dpseci_congestion_notification_cfg *cfg)
     734                 :            : {
     735                 :            :         struct dpseci_cmd_set_congestion_notification *rsp_params;
     736                 :          0 :         struct mc_command cmd = { 0 };
     737                 :            :         int err;
     738                 :            : 
     739                 :            :         /* prepare command */
     740                 :          0 :         cmd.header = mc_encode_cmd_header(
     741                 :            :                         DPSECI_CMDID_GET_CONGESTION_NOTIFICATION,
     742                 :            :                         cmd_flags,
     743                 :            :                         token);
     744                 :            : 
     745                 :            :         /* send command to mc*/
     746                 :          0 :         err = mc_send_command(mc_io, &cmd);
     747         [ #  # ]:          0 :         if (err)
     748                 :            :                 return err;
     749                 :            : 
     750                 :            :         rsp_params =
     751                 :            :                 (struct dpseci_cmd_set_congestion_notification *)cmd.params;
     752                 :            : 
     753                 :          0 :         cfg->dest_cfg.dest_id = le32_to_cpu(rsp_params->dest_id);
     754                 :          0 :         cfg->dest_cfg.priority = rsp_params->dest_priority;
     755                 :          0 :         cfg->notification_mode = le16_to_cpu(rsp_params->notification_mode);
     756                 :          0 :         cfg->message_ctx = le64_to_cpu(rsp_params->message_ctx);
     757                 :          0 :         cfg->message_iova = le64_to_cpu(rsp_params->message_iova);
     758                 :          0 :         cfg->threshold_entry = le32_to_cpu(rsp_params->threshold_entry);
     759                 :          0 :         cfg->threshold_exit = le32_to_cpu(rsp_params->threshold_exit);
     760                 :          0 :         cfg->units = dpseci_get_field(rsp_params->type_units, CG_UNITS);
     761                 :          0 :         cfg->dest_cfg.dest_type = dpseci_get_field(rsp_params->type_units,
     762                 :            :                                                 DEST_TYPE);
     763                 :            : 
     764                 :          0 :         return 0;
     765                 :            : }
     766                 :            : 
     767                 :            : 
     768                 :            : /**
     769                 :            :  * dpseci_get_rx_queue_status() - Get queue status attributes
     770                 :            :  * @mc_io:      Pointer to MC portal's I/O object
     771                 :            :  * @cmd_flags:  Command flags; one or more of 'MC_CMD_FLAG_'
     772                 :            :  * @token:      Token of DPSECI object
     773                 :            :  * @queue_index:        Select the queue_index
     774                 :            :  * @attr:       Returned queue status attributes
     775                 :            :  *
     776                 :            :  * Return:      '0' on success, error code otherwise
     777                 :            :  */
     778                 :          0 : int dpseci_get_rx_queue_status(struct fsl_mc_io *mc_io,
     779                 :            :                                 uint32_t cmd_flags,
     780                 :            :                                 uint16_t token,
     781                 :            :                                 uint32_t queue_index,
     782                 :            :                                 struct dpseci_queue_status *attr)
     783                 :            : {
     784                 :            :         struct dpseci_rsp_get_queue_status *rsp_params;
     785                 :            :         struct dpseci_cmd_get_queue_status *cmd_params;
     786                 :          0 :         struct mc_command cmd = { 0 };
     787                 :            :         int err;
     788                 :            : 
     789                 :            :         /* prepare command */
     790                 :          0 :         cmd.header = mc_encode_cmd_header(DPSECI_CMDID_GET_RX_QUEUE_STATUS,
     791                 :            :                                           cmd_flags,
     792                 :            :                                           token);
     793                 :            :         cmd_params = (struct dpseci_cmd_get_queue_status *)cmd.params;
     794                 :          0 :         cmd_params->queue_index = cpu_to_le32(queue_index);
     795                 :            : 
     796                 :            :         /* send command to mc*/
     797                 :          0 :         err = mc_send_command(mc_io, &cmd);
     798         [ #  # ]:          0 :         if (err)
     799                 :            :                 return err;
     800                 :            : 
     801                 :            :         /* retrieve response parameters */
     802                 :            :         rsp_params = (struct dpseci_rsp_get_queue_status *)cmd.params;
     803                 :          0 :         attr->fqid = le32_to_cpu(rsp_params->fqid);
     804                 :          0 :         attr->schedstate = (enum qbman_fq_schedstate_e)(le16_to_cpu(rsp_params->schedstate));
     805                 :          0 :         attr->state_flags = le16_to_cpu(rsp_params->state_flags);
     806                 :          0 :         attr->frame_count = le32_to_cpu(rsp_params->frame_count);
     807                 :          0 :         attr->byte_count = le32_to_cpu(rsp_params->byte_count);
     808                 :            : 
     809                 :          0 :         return 0;
     810                 :            : }
     811                 :            : 
     812                 :            : /**
     813                 :            :  * dpseci_get_tx_queue_status() - Get queue status attributes
     814                 :            :  * @mc_io:      Pointer to MC portal's I/O object
     815                 :            :  * @cmd_flags:  Command flags; one or more of 'MC_CMD_FLAG_'
     816                 :            :  * @token:      Token of DPSECI object
     817                 :            :  * @queue_index:        Select the queue_index
     818                 :            :  * @attr:       Returned queue status attributes
     819                 :            :  *
     820                 :            :  * Return:      '0' on success, error code otherwise
     821                 :            :  */
     822                 :          0 : int dpseci_get_tx_queue_status(struct fsl_mc_io *mc_io,
     823                 :            :                                 uint32_t cmd_flags,
     824                 :            :                                 uint16_t token,
     825                 :            :                                 uint32_t queue_index,
     826                 :            :                                 struct dpseci_queue_status *attr)
     827                 :            : {
     828                 :            :         struct dpseci_rsp_get_queue_status *rsp_params;
     829                 :            :         struct dpseci_cmd_get_queue_status *cmd_params;
     830                 :          0 :         struct mc_command cmd = { 0 };
     831                 :            :         int err;
     832                 :            : 
     833                 :            :         /* prepare command */
     834                 :          0 :         cmd.header = mc_encode_cmd_header(DPSECI_CMDID_GET_TX_QUEUE_STATUS,
     835                 :            :                                           cmd_flags,
     836                 :            :                                           token);
     837                 :            :         cmd_params = (struct dpseci_cmd_get_queue_status *)cmd.params;
     838                 :          0 :         cmd_params->queue_index = cpu_to_le32(queue_index);
     839                 :            : 
     840                 :            :         /* send command to mc*/
     841                 :          0 :         err = mc_send_command(mc_io, &cmd);
     842         [ #  # ]:          0 :         if (err)
     843                 :            :                 return err;
     844                 :            : 
     845                 :            :         /* retrieve response parameters */
     846                 :            :         rsp_params = (struct dpseci_rsp_get_queue_status *)cmd.params;
     847                 :          0 :         attr->fqid = le32_to_cpu(rsp_params->fqid);
     848                 :          0 :         attr->schedstate = (enum qbman_fq_schedstate_e)(le16_to_cpu(rsp_params->schedstate));
     849                 :          0 :         attr->state_flags = le16_to_cpu(rsp_params->state_flags);
     850                 :          0 :         attr->frame_count = le32_to_cpu(rsp_params->frame_count);
     851                 :          0 :         attr->byte_count = le32_to_cpu(rsp_params->byte_count);
     852                 :            : 
     853                 :          0 :         return 0;
     854                 :            : }

Generated by: LCOV version 1.14