LCOV - code coverage report
Current view: top level - drivers/bus/fslmc/mc - dpci.c (source / functions) Hit Total Coverage
Test: Code coverage Lines: 0 126 0.0 %
Date: 2025-05-01 17:49:45 Functions: 0 15 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 2017-2019 NXP
       5                 :            :  *
       6                 :            :  */
       7                 :            : #include <fsl_mc_sys.h>
       8                 :            : #include <fsl_mc_cmd.h>
       9                 :            : #include <fsl_dpci.h>
      10                 :            : #include <fsl_dpci_cmd.h>
      11                 :            : 
      12                 :            : #include <eal_export.h>
      13                 :            : 
      14                 :            : /**
      15                 :            :  * dpci_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                 :            :  * @dpci_id:    DPCI 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 dpci_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                 :          0 : int dpci_open(struct fsl_mc_io *mc_io,
      32                 :            :               uint32_t cmd_flags,
      33                 :            :               int dpci_id,
      34                 :            :               uint16_t *token)
      35                 :            : {
      36                 :            :         struct dpci_cmd_open *cmd_params;
      37                 :          0 :         struct mc_command cmd = { 0 };
      38                 :            :         int err;
      39                 :            : 
      40                 :            :         /* prepare command */
      41                 :          0 :         cmd.header = mc_encode_cmd_header(DPCI_CMDID_OPEN,
      42                 :            :                                           cmd_flags,
      43                 :            :                                           0);
      44                 :            :         cmd_params = (struct dpci_cmd_open *)cmd.params;
      45                 :          0 :         cmd_params->dpci_id = cpu_to_le32(dpci_id);
      46                 :            : 
      47                 :            :         /* send command to mc*/
      48                 :          0 :         err = mc_send_command(mc_io, &cmd);
      49         [ #  # ]:          0 :         if (err)
      50                 :            :                 return err;
      51                 :            : 
      52                 :            :         /* retrieve response parameters */
      53                 :          0 :         *token = mc_cmd_hdr_read_token(&cmd);
      54                 :            : 
      55                 :          0 :         return 0;
      56                 :            : }
      57                 :            : 
      58                 :            : /**
      59                 :            :  * dpci_close() - Close the control session of the object
      60                 :            :  * @mc_io:      Pointer to MC portal's I/O object
      61                 :            :  * @cmd_flags:  Command flags; one or more of 'MC_CMD_FLAG_'
      62                 :            :  * @token:      Token of DPCI object
      63                 :            :  *
      64                 :            :  * After this function is called, no further operations are
      65                 :            :  * allowed on the object without opening a new control session.
      66                 :            :  *
      67                 :            :  * Return:      '0' on Success; Error code otherwise.
      68                 :            :  */
      69                 :          0 : int dpci_close(struct fsl_mc_io *mc_io,
      70                 :            :                uint32_t cmd_flags,
      71                 :            :                uint16_t token)
      72                 :            : {
      73                 :          0 :         struct mc_command cmd = { 0 };
      74                 :            : 
      75                 :            :         /* prepare command */
      76                 :          0 :         cmd.header = mc_encode_cmd_header(DPCI_CMDID_CLOSE,
      77                 :            :                                           cmd_flags,
      78                 :            :                                           token);
      79                 :            : 
      80                 :            :         /* send command to mc*/
      81                 :          0 :         return mc_send_command(mc_io, &cmd);
      82                 :            : }
      83                 :            : 
      84                 :            : /**
      85                 :            :  * dpci_create() - Create the DPCI object.
      86                 :            :  * @mc_io:      Pointer to MC portal's I/O object
      87                 :            :  * @dprc_token: Parent container token; '0' for default container
      88                 :            :  * @cmd_flags:  Command flags; one or more of 'MC_CMD_FLAG_'
      89                 :            :  * @cfg:        Configuration structure
      90                 :            :  * @obj_id:     Returned object id
      91                 :            :  *
      92                 :            :  * Create the DPCI object, allocate required resources and perform required
      93                 :            :  * initialization.
      94                 :            :  *
      95                 :            :  * The object can be created either by declaring it in the
      96                 :            :  * DPL file, or by calling this function.
      97                 :            :  *
      98                 :            :  * The function accepts an authentication token of a parent
      99                 :            :  * container that this object should be assigned to. The token
     100                 :            :  * can be '0' so the object will be assigned to the default container.
     101                 :            :  * The newly created object can be opened with the returned
     102                 :            :  * object id and using the container's associated tokens and MC portals.
     103                 :            :  *
     104                 :            :  * Return:      '0' on Success; Error code otherwise.
     105                 :            :  */
     106                 :          0 : int dpci_create(struct fsl_mc_io *mc_io,
     107                 :            :                 uint16_t dprc_token,
     108                 :            :                 uint32_t cmd_flags,
     109                 :            :                 const struct dpci_cfg *cfg,
     110                 :            :                 uint32_t *obj_id)
     111                 :            : {
     112                 :            :         struct dpci_cmd_create *cmd_params;
     113                 :          0 :         struct mc_command cmd = { 0 };
     114                 :            :         int err;
     115                 :            : 
     116                 :            :         /* prepare command */
     117                 :          0 :         cmd.header = mc_encode_cmd_header(DPCI_CMDID_CREATE,
     118                 :            :                                           cmd_flags,
     119                 :            :                                           dprc_token);
     120                 :            :         cmd_params = (struct dpci_cmd_create *)cmd.params;
     121                 :          0 :         cmd_params->num_of_priorities = cfg->num_of_priorities;
     122                 :            : 
     123                 :            :         /* send command to mc*/
     124                 :          0 :         err = mc_send_command(mc_io, &cmd);
     125         [ #  # ]:          0 :         if (err)
     126                 :            :                 return err;
     127                 :            : 
     128                 :            :         /* retrieve response parameters */
     129                 :          0 :         *obj_id = mc_cmd_read_object_id(&cmd);
     130                 :            : 
     131                 :          0 :         return 0;
     132                 :            : }
     133                 :            : 
     134                 :            : /**
     135                 :            :  * dpci_destroy() - Destroy the DPCI object and release all its resources.
     136                 :            :  * @mc_io:      Pointer to MC portal's I/O object
     137                 :            :  * @dprc_token: Parent container token; '0' for default container
     138                 :            :  * @cmd_flags:  Command flags; one or more of 'MC_CMD_FLAG_'
     139                 :            :  * @object_id:  The object id; it must be a valid id within the container that
     140                 :            :  * created this object;
     141                 :            :  *
     142                 :            :  * The function accepts the authentication token of the parent container that
     143                 :            :  * created the object (not the one that currently owns the object). The object
     144                 :            :  * is searched within parent using the provided 'object_id'.
     145                 :            :  * All tokens to the object must be closed before calling destroy.
     146                 :            :  *
     147                 :            :  * Return:      '0' on Success; error code otherwise.
     148                 :            :  */
     149                 :          0 : int dpci_destroy(struct fsl_mc_io *mc_io,
     150                 :            :                  uint16_t dprc_token,
     151                 :            :                  uint32_t cmd_flags,
     152                 :            :                  uint32_t object_id)
     153                 :            : {
     154                 :            :         struct dpci_cmd_destroy *cmd_params;
     155                 :          0 :         struct mc_command cmd = { 0 };
     156                 :            : 
     157                 :            :         /* prepare command */
     158                 :          0 :         cmd.header = mc_encode_cmd_header(DPCI_CMDID_DESTROY,
     159                 :            :                                           cmd_flags,
     160                 :            :                                           dprc_token);
     161                 :            :         cmd_params = (struct dpci_cmd_destroy *)cmd.params;
     162                 :          0 :         cmd_params->dpci_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                 :            :  * dpci_enable() - Enable the DPCI, allow sending and receiving frames.
     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 DPCI object
     173                 :            :  *
     174                 :            :  * Return:      '0' on Success; Error code otherwise.
     175                 :            :  */
     176                 :          0 : int dpci_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(DPCI_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                 :            :  * dpci_disable() - Disable the DPCI, stop sending and receiving frames.
     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 DPCI object
     196                 :            :  *
     197                 :            :  * Return:      '0' on Success; Error code otherwise.
     198                 :            :  */
     199                 :          0 : int dpci_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(DPCI_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                 :            :  * dpci_is_enabled() - Check if the DPCI 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 DPCI object
     219                 :            :  * @en:         Returns '1' if object is enabled; '0' otherwise
     220                 :            :  *
     221                 :            :  * Return:      '0' on Success; Error code otherwise.
     222                 :            :  */
     223                 :          0 : int dpci_is_enabled(struct fsl_mc_io *mc_io,
     224                 :            :                     uint32_t cmd_flags,
     225                 :            :                     uint16_t token,
     226                 :            :                     int *en)
     227                 :            : {
     228                 :            :         struct dpci_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(DPCI_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 dpci_rsp_is_enabled *)cmd.params;
     243                 :          0 :         *en = dpci_get_field(rsp_params->en, ENABLE);
     244                 :            : 
     245                 :          0 :         return 0;
     246                 :            : }
     247                 :            : 
     248                 :            : /**
     249                 :            :  * dpci_reset() - Reset the DPCI, 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 DPCI object
     253                 :            :  *
     254                 :            :  * Return:      '0' on Success; Error code otherwise.
     255                 :            :  */
     256                 :          0 : int dpci_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(DPCI_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                 :            :  * dpci_get_attributes() - Retrieve DPCI 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 DPCI object
     276                 :            :  * @attr:       Returned object's attributes
     277                 :            :  *
     278                 :            :  * Return:      '0' on Success; Error code otherwise.
     279                 :            :  */
     280                 :          0 : int dpci_get_attributes(struct fsl_mc_io *mc_io,
     281                 :            :                         uint32_t cmd_flags,
     282                 :            :                         uint16_t token,
     283                 :            :                         struct dpci_attr *attr)
     284                 :            : {
     285                 :            :         struct dpci_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(DPCI_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 dpci_rsp_get_attr *)cmd.params;
     301                 :          0 :         attr->id = le32_to_cpu(rsp_params->id);
     302                 :          0 :         attr->num_of_priorities = rsp_params->num_of_priorities;
     303                 :            : 
     304                 :          0 :         return 0;
     305                 :            : }
     306                 :            : 
     307                 :            : /**
     308                 :            :  * dpci_set_rx_queue() - Set Rx queue configuration
     309                 :            :  * @mc_io:      Pointer to MC portal's I/O object
     310                 :            :  * @cmd_flags:  Command flags; one or more of 'MC_CMD_FLAG_'
     311                 :            :  * @token:      Token of DPCI object
     312                 :            :  * @priority:   Select the queue relative to number of
     313                 :            :  *                      priorities configured at DPCI creation; use
     314                 :            :  *                      DPCI_ALL_QUEUES to configure all Rx queues
     315                 :            :  *                      identically.
     316                 :            :  * @cfg:        Rx queue configuration
     317                 :            :  *
     318                 :            :  * Return:      '0' on Success; Error code otherwise.
     319                 :            :  */
     320                 :            : RTE_EXPORT_INTERNAL_SYMBOL(dpci_set_rx_queue)
     321                 :          0 : int dpci_set_rx_queue(struct fsl_mc_io *mc_io,
     322                 :            :                       uint32_t cmd_flags,
     323                 :            :                       uint16_t token,
     324                 :            :                       uint8_t priority,
     325                 :            :                       const struct dpci_rx_queue_cfg *cfg)
     326                 :            : {
     327                 :            :         struct dpci_cmd_set_rx_queue *cmd_params;
     328                 :          0 :         struct mc_command cmd = { 0 };
     329                 :            : 
     330                 :            :         /* prepare command */
     331                 :          0 :         cmd.header = mc_encode_cmd_header(DPCI_CMDID_SET_RX_QUEUE,
     332                 :            :                                           cmd_flags,
     333                 :            :                                           token);
     334                 :            :         cmd_params = (struct dpci_cmd_set_rx_queue *)cmd.params;
     335                 :          0 :         cmd_params->dest_id = cpu_to_le32(cfg->dest_cfg.dest_id);
     336                 :          0 :         cmd_params->dest_priority = cfg->dest_cfg.priority;
     337                 :          0 :         cmd_params->priority = priority;
     338                 :          0 :         cmd_params->user_ctx = cpu_to_le64(cfg->user_ctx);
     339                 :          0 :         cmd_params->options = cpu_to_le32(cfg->options);
     340                 :          0 :         dpci_set_field(cmd_params->dest_type,
     341                 :            :                        DEST_TYPE,
     342                 :            :                        cfg->dest_cfg.dest_type);
     343                 :          0 :         dpci_set_field(cmd_params->dest_type,
     344                 :            :                        ORDER_PRESERVATION,
     345                 :            :                        cfg->order_preservation_en);
     346                 :            : 
     347                 :            :         /* send command to mc*/
     348                 :          0 :         return mc_send_command(mc_io, &cmd);
     349                 :            : }
     350                 :            : 
     351                 :            : /**
     352                 :            :  * dpci_get_rx_queue() - Retrieve Rx queue attributes.
     353                 :            :  * @mc_io:      Pointer to MC portal's I/O object
     354                 :            :  * @cmd_flags:  Command flags; one or more of 'MC_CMD_FLAG_'
     355                 :            :  * @token:      Token of DPCI object
     356                 :            :  * @priority:   Select the queue relative to number of
     357                 :            :  *              priorities configured at DPCI creation
     358                 :            :  * @attr:       Returned Rx queue attributes
     359                 :            :  *
     360                 :            :  * Return:      '0' on Success; Error code otherwise.
     361                 :            :  */
     362                 :          0 : int dpci_get_rx_queue(struct fsl_mc_io *mc_io,
     363                 :            :                       uint32_t cmd_flags,
     364                 :            :                       uint16_t token,
     365                 :            :                       uint8_t priority,
     366                 :            :                       struct dpci_rx_queue_attr *attr)
     367                 :            : {
     368                 :            :         struct dpci_cmd_get_queue *cmd_params;
     369                 :            :         struct dpci_rsp_get_rx_queue *rsp_params;
     370                 :          0 :         struct mc_command cmd = { 0 };
     371                 :            :         int err;
     372                 :            : 
     373                 :            :         /* prepare command */
     374                 :          0 :         cmd.header = mc_encode_cmd_header(DPCI_CMDID_GET_RX_QUEUE,
     375                 :            :                                           cmd_flags,
     376                 :            :                                           token);
     377                 :            :         cmd_params = (struct dpci_cmd_get_queue *)cmd.params;
     378                 :          0 :         cmd_params->priority = priority;
     379                 :            : 
     380                 :            :         /* send command to mc*/
     381                 :          0 :         err = mc_send_command(mc_io, &cmd);
     382         [ #  # ]:          0 :         if (err)
     383                 :            :                 return err;
     384                 :            : 
     385                 :            :         /* retrieve response parameters */
     386                 :            :         rsp_params = (struct dpci_rsp_get_rx_queue *)cmd.params;
     387                 :          0 :         attr->user_ctx = le64_to_cpu(rsp_params->user_ctx);
     388                 :          0 :         attr->fqid = le32_to_cpu(rsp_params->fqid);
     389                 :          0 :         attr->dest_cfg.dest_id = le32_to_cpu(rsp_params->dest_id);
     390                 :          0 :         attr->dest_cfg.priority = rsp_params->dest_priority;
     391                 :          0 :         attr->dest_cfg.dest_type = dpci_get_field(rsp_params->dest_type,
     392                 :            :                                                   DEST_TYPE);
     393                 :            : 
     394                 :          0 :         return 0;
     395                 :            : }
     396                 :            : 
     397                 :            : /**
     398                 :            :  * dpci_get_tx_queue() - Retrieve Tx queue attributes.
     399                 :            :  * @mc_io:      Pointer to MC portal's I/O object
     400                 :            :  * @cmd_flags:  Command flags; one or more of 'MC_CMD_FLAG_'
     401                 :            :  * @token:      Token of DPCI object
     402                 :            :  * @priority:   Select the queue relative to number of
     403                 :            :  *              priorities of the peer DPCI object
     404                 :            :  * @attr:       Returned Tx queue attributes
     405                 :            :  *
     406                 :            :  * Return:      '0' on Success; Error code otherwise.
     407                 :            :  */
     408                 :          0 : int dpci_get_tx_queue(struct fsl_mc_io *mc_io,
     409                 :            :                       uint32_t cmd_flags,
     410                 :            :                       uint16_t token,
     411                 :            :                       uint8_t priority,
     412                 :            :                       struct dpci_tx_queue_attr *attr)
     413                 :            : {
     414                 :            :         struct dpci_cmd_get_queue *cmd_params;
     415                 :            :         struct dpci_rsp_get_tx_queue *rsp_params;
     416                 :          0 :         struct mc_command cmd = { 0 };
     417                 :            :         int err;
     418                 :            : 
     419                 :            :         /* prepare command */
     420                 :          0 :         cmd.header = mc_encode_cmd_header(DPCI_CMDID_GET_TX_QUEUE,
     421                 :            :                                           cmd_flags,
     422                 :            :                                           token);
     423                 :            :         cmd_params = (struct dpci_cmd_get_queue *)cmd.params;
     424                 :          0 :         cmd_params->priority = priority;
     425                 :            : 
     426                 :            :         /* send command to mc*/
     427                 :          0 :         err = mc_send_command(mc_io, &cmd);
     428         [ #  # ]:          0 :         if (err)
     429                 :            :                 return err;
     430                 :            : 
     431                 :            :         /* retrieve response parameters */
     432                 :            :         rsp_params = (struct dpci_rsp_get_tx_queue *)cmd.params;
     433                 :          0 :         attr->fqid = le32_to_cpu(rsp_params->fqid);
     434                 :            : 
     435                 :          0 :         return 0;
     436                 :            : }
     437                 :            : 
     438                 :            : /**
     439                 :            :  * dpci_get_api_version() - Get communication interface API version
     440                 :            :  * @mc_io:      Pointer to MC portal's I/O object
     441                 :            :  * @cmd_flags:  Command flags; one or more of 'MC_CMD_FLAG_'
     442                 :            :  * @major_ver:  Major version of data path communication interface API
     443                 :            :  * @minor_ver:  Minor version of data path communication interface API
     444                 :            :  *
     445                 :            :  * Return:  '0' on Success; Error code otherwise.
     446                 :            :  */
     447                 :          0 : int dpci_get_api_version(struct fsl_mc_io *mc_io,
     448                 :            :                          uint32_t cmd_flags,
     449                 :            :                          uint16_t *major_ver,
     450                 :            :                          uint16_t *minor_ver)
     451                 :            : {
     452                 :            :         struct dpci_rsp_get_api_version *rsp_params;
     453                 :          0 :         struct mc_command cmd = { 0 };
     454                 :            :         int err;
     455                 :            : 
     456                 :          0 :         cmd.header = mc_encode_cmd_header(DPCI_CMDID_GET_API_VERSION,
     457                 :            :                                         cmd_flags,
     458                 :            :                                         0);
     459                 :            : 
     460                 :          0 :         err = mc_send_command(mc_io, &cmd);
     461         [ #  # ]:          0 :         if (err)
     462                 :            :                 return err;
     463                 :            : 
     464                 :            :         rsp_params = (struct dpci_rsp_get_api_version *)cmd.params;
     465                 :          0 :         *major_ver = le16_to_cpu(rsp_params->major);
     466                 :          0 :         *minor_ver = le16_to_cpu(rsp_params->minor);
     467                 :            : 
     468                 :          0 :         return 0;
     469                 :            : }
     470                 :            : 
     471                 :            : /**
     472                 :            :  * dpci_set_opr() - Set Order Restoration configuration.
     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 DPCI object
     476                 :            :  * @index:      The queue index
     477                 :            :  * @options:    Configuration mode options
     478                 :            :  *              can be OPR_OPT_CREATE or OPR_OPT_RETIRE
     479                 :            :  * @cfg:        Configuration options for the OPR
     480                 :            :  *
     481                 :            :  * Return:      '0' on Success; Error code otherwise.
     482                 :            :  */
     483                 :            : RTE_EXPORT_INTERNAL_SYMBOL(dpci_set_opr)
     484                 :          0 : int dpci_set_opr(struct fsl_mc_io *mc_io,
     485                 :            :                  uint32_t cmd_flags,
     486                 :            :                  uint16_t token,
     487                 :            :                  uint8_t index,
     488                 :            :                  uint8_t options,
     489                 :            :                  struct opr_cfg *cfg)
     490                 :            : {
     491                 :            :         struct dpci_cmd_set_opr *cmd_params;
     492                 :          0 :         struct mc_command cmd = { 0 };
     493                 :            : 
     494                 :            :         /* prepare command */
     495                 :          0 :         cmd.header = mc_encode_cmd_header(DPCI_CMDID_SET_OPR,
     496                 :            :                                           cmd_flags,
     497                 :            :                                           token);
     498                 :            :         cmd_params = (struct dpci_cmd_set_opr *)cmd.params;
     499                 :          0 :         cmd_params->index = index;
     500                 :          0 :         cmd_params->options = options;
     501                 :          0 :         cmd_params->oloe = cfg->oloe;
     502                 :          0 :         cmd_params->oeane = cfg->oeane;
     503                 :          0 :         cmd_params->olws = cfg->olws;
     504                 :          0 :         cmd_params->oa = cfg->oa;
     505                 :          0 :         cmd_params->oprrws = cfg->oprrws;
     506                 :            : 
     507                 :            :         /* send command to mc*/
     508                 :          0 :         return mc_send_command(mc_io, &cmd);
     509                 :            : }
     510                 :            : 
     511                 :            : /**
     512                 :            :  * dpci_get_opr() - Retrieve Order Restoration config and query.
     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 DPCI object
     516                 :            :  * @index:      The queue index
     517                 :            :  * @cfg:        Returned OPR configuration
     518                 :            :  * @qry:        Returned OPR query
     519                 :            :  *
     520                 :            :  * Return:      '0' on Success; Error code otherwise.
     521                 :            :  */
     522                 :            : RTE_EXPORT_INTERNAL_SYMBOL(dpci_get_opr)
     523                 :          0 : int dpci_get_opr(struct fsl_mc_io *mc_io,
     524                 :            :                  uint32_t cmd_flags,
     525                 :            :                  uint16_t token,
     526                 :            :                  uint8_t index,
     527                 :            :                  struct opr_cfg *cfg,
     528                 :            :                  struct opr_qry *qry)
     529                 :            : {
     530                 :            :         struct dpci_rsp_get_opr *rsp_params;
     531                 :            :         struct dpci_cmd_get_opr *cmd_params;
     532                 :          0 :         struct mc_command cmd = { 0 };
     533                 :            :         int err;
     534                 :            : 
     535                 :            :         /* prepare command */
     536                 :          0 :         cmd.header = mc_encode_cmd_header(DPCI_CMDID_GET_OPR,
     537                 :            :                                           cmd_flags,
     538                 :            :                                           token);
     539                 :            :         cmd_params = (struct dpci_cmd_get_opr *)cmd.params;
     540                 :          0 :         cmd_params->index = index;
     541                 :            : 
     542                 :            :         /* send command to mc*/
     543                 :          0 :         err = mc_send_command(mc_io, &cmd);
     544         [ #  # ]:          0 :         if (err)
     545                 :            :                 return err;
     546                 :            : 
     547                 :            :         /* retrieve response parameters */
     548                 :            :         rsp_params = (struct dpci_rsp_get_opr *)cmd.params;
     549                 :          0 :         cfg->oloe = rsp_params->oloe;
     550                 :          0 :         cfg->oeane = rsp_params->oeane;
     551                 :          0 :         cfg->olws = rsp_params->olws;
     552                 :          0 :         cfg->oa = rsp_params->oa;
     553                 :          0 :         cfg->oprrws = rsp_params->oprrws;
     554                 :          0 :         qry->rip = dpci_get_field(rsp_params->flags, RIP);
     555                 :          0 :         qry->enable = dpci_get_field(rsp_params->flags, OPR_ENABLE);
     556                 :          0 :         qry->nesn = le16_to_cpu(rsp_params->nesn);
     557                 :          0 :         qry->ndsn = le16_to_cpu(rsp_params->ndsn);
     558                 :          0 :         qry->ea_tseq = le16_to_cpu(rsp_params->ea_tseq);
     559                 :          0 :         qry->tseq_nlis = dpci_get_field(rsp_params->tseq_nlis, TSEQ_NLIS);
     560                 :          0 :         qry->ea_hseq = le16_to_cpu(rsp_params->ea_hseq);
     561                 :          0 :         qry->hseq_nlis = dpci_get_field(rsp_params->hseq_nlis, HSEQ_NLIS);
     562                 :          0 :         qry->ea_hptr = le16_to_cpu(rsp_params->ea_hptr);
     563                 :          0 :         qry->ea_tptr = le16_to_cpu(rsp_params->ea_tptr);
     564                 :          0 :         qry->opr_vid = le16_to_cpu(rsp_params->opr_vid);
     565                 :          0 :         qry->opr_id = le16_to_cpu(rsp_params->opr_id);
     566                 :            : 
     567                 :          0 :         return 0;
     568                 :            : }

Generated by: LCOV version 1.14