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-01-02 22:41:34 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                 :            : /**
      13                 :            :  * dpci_open() - Open a control session for the specified object
      14                 :            :  * @mc_io:      Pointer to MC portal's I/O object
      15                 :            :  * @cmd_flags:  Command flags; one or more of 'MC_CMD_FLAG_'
      16                 :            :  * @dpci_id:    DPCI unique ID
      17                 :            :  * @token:      Returned token; use in subsequent API calls
      18                 :            :  *
      19                 :            :  * This function can be used to open a control session for an
      20                 :            :  * already created object; an object may have been declared in
      21                 :            :  * the DPL or by calling the dpci_create() function.
      22                 :            :  * This function returns a unique authentication token,
      23                 :            :  * associated with the specific object ID and the specific MC
      24                 :            :  * portal; this token must be used in all subsequent commands for
      25                 :            :  * this specific object.
      26                 :            :  *
      27                 :            :  * Return:      '0' on Success; Error code otherwise.
      28                 :            :  */
      29                 :          0 : int dpci_open(struct fsl_mc_io *mc_io,
      30                 :            :               uint32_t cmd_flags,
      31                 :            :               int dpci_id,
      32                 :            :               uint16_t *token)
      33                 :            : {
      34                 :            :         struct dpci_cmd_open *cmd_params;
      35                 :          0 :         struct mc_command cmd = { 0 };
      36                 :            :         int err;
      37                 :            : 
      38                 :            :         /* prepare command */
      39                 :          0 :         cmd.header = mc_encode_cmd_header(DPCI_CMDID_OPEN,
      40                 :            :                                           cmd_flags,
      41                 :            :                                           0);
      42                 :            :         cmd_params = (struct dpci_cmd_open *)cmd.params;
      43                 :          0 :         cmd_params->dpci_id = cpu_to_le32(dpci_id);
      44                 :            : 
      45                 :            :         /* send command to mc*/
      46                 :          0 :         err = mc_send_command(mc_io, &cmd);
      47         [ #  # ]:          0 :         if (err)
      48                 :            :                 return err;
      49                 :            : 
      50                 :            :         /* retrieve response parameters */
      51                 :          0 :         *token = mc_cmd_hdr_read_token(&cmd);
      52                 :            : 
      53                 :          0 :         return 0;
      54                 :            : }
      55                 :            : 
      56                 :            : /**
      57                 :            :  * dpci_close() - Close the control session of the object
      58                 :            :  * @mc_io:      Pointer to MC portal's I/O object
      59                 :            :  * @cmd_flags:  Command flags; one or more of 'MC_CMD_FLAG_'
      60                 :            :  * @token:      Token of DPCI object
      61                 :            :  *
      62                 :            :  * After this function is called, no further operations are
      63                 :            :  * allowed on the object without opening a new control session.
      64                 :            :  *
      65                 :            :  * Return:      '0' on Success; Error code otherwise.
      66                 :            :  */
      67                 :          0 : int dpci_close(struct fsl_mc_io *mc_io,
      68                 :            :                uint32_t cmd_flags,
      69                 :            :                uint16_t token)
      70                 :            : {
      71                 :          0 :         struct mc_command cmd = { 0 };
      72                 :            : 
      73                 :            :         /* prepare command */
      74                 :          0 :         cmd.header = mc_encode_cmd_header(DPCI_CMDID_CLOSE,
      75                 :            :                                           cmd_flags,
      76                 :            :                                           token);
      77                 :            : 
      78                 :            :         /* send command to mc*/
      79                 :          0 :         return mc_send_command(mc_io, &cmd);
      80                 :            : }
      81                 :            : 
      82                 :            : /**
      83                 :            :  * dpci_create() - Create the DPCI object.
      84                 :            :  * @mc_io:      Pointer to MC portal's I/O object
      85                 :            :  * @dprc_token: Parent container token; '0' for default container
      86                 :            :  * @cmd_flags:  Command flags; one or more of 'MC_CMD_FLAG_'
      87                 :            :  * @cfg:        Configuration structure
      88                 :            :  * @obj_id:     Returned object id
      89                 :            :  *
      90                 :            :  * Create the DPCI object, allocate required resources and perform required
      91                 :            :  * initialization.
      92                 :            :  *
      93                 :            :  * The object can be created either by declaring it in the
      94                 :            :  * DPL file, or by calling this function.
      95                 :            :  *
      96                 :            :  * The function accepts an authentication token of a parent
      97                 :            :  * container that this object should be assigned to. The token
      98                 :            :  * can be '0' so the object will be assigned to the default container.
      99                 :            :  * The newly created object can be opened with the returned
     100                 :            :  * object id and using the container's associated tokens and MC portals.
     101                 :            :  *
     102                 :            :  * Return:      '0' on Success; Error code otherwise.
     103                 :            :  */
     104                 :          0 : int dpci_create(struct fsl_mc_io *mc_io,
     105                 :            :                 uint16_t dprc_token,
     106                 :            :                 uint32_t cmd_flags,
     107                 :            :                 const struct dpci_cfg *cfg,
     108                 :            :                 uint32_t *obj_id)
     109                 :            : {
     110                 :            :         struct dpci_cmd_create *cmd_params;
     111                 :          0 :         struct mc_command cmd = { 0 };
     112                 :            :         int err;
     113                 :            : 
     114                 :            :         /* prepare command */
     115                 :          0 :         cmd.header = mc_encode_cmd_header(DPCI_CMDID_CREATE,
     116                 :            :                                           cmd_flags,
     117                 :            :                                           dprc_token);
     118                 :            :         cmd_params = (struct dpci_cmd_create *)cmd.params;
     119                 :          0 :         cmd_params->num_of_priorities = cfg->num_of_priorities;
     120                 :            : 
     121                 :            :         /* send command to mc*/
     122                 :          0 :         err = mc_send_command(mc_io, &cmd);
     123         [ #  # ]:          0 :         if (err)
     124                 :            :                 return err;
     125                 :            : 
     126                 :            :         /* retrieve response parameters */
     127                 :          0 :         *obj_id = mc_cmd_read_object_id(&cmd);
     128                 :            : 
     129                 :          0 :         return 0;
     130                 :            : }
     131                 :            : 
     132                 :            : /**
     133                 :            :  * dpci_destroy() - Destroy the DPCI object and release all its resources.
     134                 :            :  * @mc_io:      Pointer to MC portal's I/O object
     135                 :            :  * @dprc_token: Parent container token; '0' for default container
     136                 :            :  * @cmd_flags:  Command flags; one or more of 'MC_CMD_FLAG_'
     137                 :            :  * @object_id:  The object id; it must be a valid id within the container that
     138                 :            :  * created this object;
     139                 :            :  *
     140                 :            :  * The function accepts the authentication token of the parent container that
     141                 :            :  * created the object (not the one that currently owns the object). The object
     142                 :            :  * is searched within parent using the provided 'object_id'.
     143                 :            :  * All tokens to the object must be closed before calling destroy.
     144                 :            :  *
     145                 :            :  * Return:      '0' on Success; error code otherwise.
     146                 :            :  */
     147                 :          0 : int dpci_destroy(struct fsl_mc_io *mc_io,
     148                 :            :                  uint16_t dprc_token,
     149                 :            :                  uint32_t cmd_flags,
     150                 :            :                  uint32_t object_id)
     151                 :            : {
     152                 :            :         struct dpci_cmd_destroy *cmd_params;
     153                 :          0 :         struct mc_command cmd = { 0 };
     154                 :            : 
     155                 :            :         /* prepare command */
     156                 :          0 :         cmd.header = mc_encode_cmd_header(DPCI_CMDID_DESTROY,
     157                 :            :                                           cmd_flags,
     158                 :            :                                           dprc_token);
     159                 :            :         cmd_params = (struct dpci_cmd_destroy *)cmd.params;
     160                 :          0 :         cmd_params->dpci_id = cpu_to_le32(object_id);
     161                 :            : 
     162                 :            :         /* send command to mc*/
     163                 :          0 :         return mc_send_command(mc_io, &cmd);
     164                 :            : }
     165                 :            : 
     166                 :            : /**
     167                 :            :  * dpci_enable() - Enable the DPCI, allow sending and receiving frames.
     168                 :            :  * @mc_io:      Pointer to MC portal's I/O object
     169                 :            :  * @cmd_flags:  Command flags; one or more of 'MC_CMD_FLAG_'
     170                 :            :  * @token:      Token of DPCI object
     171                 :            :  *
     172                 :            :  * Return:      '0' on Success; Error code otherwise.
     173                 :            :  */
     174                 :          0 : int dpci_enable(struct fsl_mc_io *mc_io,
     175                 :            :                 uint32_t cmd_flags,
     176                 :            :                 uint16_t token)
     177                 :            : {
     178                 :          0 :         struct mc_command cmd = { 0 };
     179                 :            : 
     180                 :            :         /* prepare command */
     181                 :          0 :         cmd.header = mc_encode_cmd_header(DPCI_CMDID_ENABLE,
     182                 :            :                                           cmd_flags,
     183                 :            :                                           token);
     184                 :            : 
     185                 :            :         /* send command to mc*/
     186                 :          0 :         return mc_send_command(mc_io, &cmd);
     187                 :            : }
     188                 :            : 
     189                 :            : /**
     190                 :            :  * dpci_disable() - Disable the DPCI, stop sending and receiving frames.
     191                 :            :  * @mc_io:      Pointer to MC portal's I/O object
     192                 :            :  * @cmd_flags:  Command flags; one or more of 'MC_CMD_FLAG_'
     193                 :            :  * @token:      Token of DPCI object
     194                 :            :  *
     195                 :            :  * Return:      '0' on Success; Error code otherwise.
     196                 :            :  */
     197                 :          0 : int dpci_disable(struct fsl_mc_io *mc_io,
     198                 :            :                  uint32_t cmd_flags,
     199                 :            :                  uint16_t token)
     200                 :            : {
     201                 :          0 :         struct mc_command cmd = { 0 };
     202                 :            : 
     203                 :            :         /* prepare command */
     204                 :          0 :         cmd.header = mc_encode_cmd_header(DPCI_CMDID_DISABLE,
     205                 :            :                                           cmd_flags,
     206                 :            :                                           token);
     207                 :            : 
     208                 :            :         /* send command to mc*/
     209                 :          0 :         return mc_send_command(mc_io, &cmd);
     210                 :            : }
     211                 :            : 
     212                 :            : /**
     213                 :            :  * dpci_is_enabled() - Check if the DPCI is enabled.
     214                 :            :  * @mc_io:      Pointer to MC portal's I/O object
     215                 :            :  * @cmd_flags:  Command flags; one or more of 'MC_CMD_FLAG_'
     216                 :            :  * @token:      Token of DPCI object
     217                 :            :  * @en:         Returns '1' if object is enabled; '0' otherwise
     218                 :            :  *
     219                 :            :  * Return:      '0' on Success; Error code otherwise.
     220                 :            :  */
     221                 :          0 : int dpci_is_enabled(struct fsl_mc_io *mc_io,
     222                 :            :                     uint32_t cmd_flags,
     223                 :            :                     uint16_t token,
     224                 :            :                     int *en)
     225                 :            : {
     226                 :            :         struct dpci_rsp_is_enabled *rsp_params;
     227                 :          0 :         struct mc_command cmd = { 0 };
     228                 :            :         int err;
     229                 :            : 
     230                 :            :         /* prepare command */
     231                 :          0 :         cmd.header = mc_encode_cmd_header(DPCI_CMDID_IS_ENABLED, cmd_flags,
     232                 :            :                                           token);
     233                 :            : 
     234                 :            :         /* send command to mc*/
     235                 :          0 :         err = mc_send_command(mc_io, &cmd);
     236         [ #  # ]:          0 :         if (err)
     237                 :            :                 return err;
     238                 :            : 
     239                 :            :         /* retrieve response parameters */
     240                 :            :         rsp_params = (struct dpci_rsp_is_enabled *)cmd.params;
     241                 :          0 :         *en = dpci_get_field(rsp_params->en, ENABLE);
     242                 :            : 
     243                 :          0 :         return 0;
     244                 :            : }
     245                 :            : 
     246                 :            : /**
     247                 :            :  * dpci_reset() - Reset the DPCI, returns the object to initial state.
     248                 :            :  * @mc_io:      Pointer to MC portal's I/O object
     249                 :            :  * @cmd_flags:  Command flags; one or more of 'MC_CMD_FLAG_'
     250                 :            :  * @token:      Token of DPCI object
     251                 :            :  *
     252                 :            :  * Return:      '0' on Success; Error code otherwise.
     253                 :            :  */
     254                 :          0 : int dpci_reset(struct fsl_mc_io *mc_io,
     255                 :            :                uint32_t cmd_flags,
     256                 :            :                uint16_t token)
     257                 :            : {
     258                 :          0 :         struct mc_command cmd = { 0 };
     259                 :            : 
     260                 :            :         /* prepare command */
     261                 :          0 :         cmd.header = mc_encode_cmd_header(DPCI_CMDID_RESET,
     262                 :            :                                           cmd_flags,
     263                 :            :                                           token);
     264                 :            : 
     265                 :            :         /* send command to mc*/
     266                 :          0 :         return mc_send_command(mc_io, &cmd);
     267                 :            : }
     268                 :            : 
     269                 :            : /**
     270                 :            :  * dpci_get_attributes() - Retrieve DPCI attributes.
     271                 :            :  * @mc_io:      Pointer to MC portal's I/O object
     272                 :            :  * @cmd_flags:  Command flags; one or more of 'MC_CMD_FLAG_'
     273                 :            :  * @token:      Token of DPCI object
     274                 :            :  * @attr:       Returned object's attributes
     275                 :            :  *
     276                 :            :  * Return:      '0' on Success; Error code otherwise.
     277                 :            :  */
     278                 :          0 : int dpci_get_attributes(struct fsl_mc_io *mc_io,
     279                 :            :                         uint32_t cmd_flags,
     280                 :            :                         uint16_t token,
     281                 :            :                         struct dpci_attr *attr)
     282                 :            : {
     283                 :            :         struct dpci_rsp_get_attr *rsp_params;
     284                 :          0 :         struct mc_command cmd = { 0 };
     285                 :            :         int err;
     286                 :            : 
     287                 :            :         /* prepare command */
     288                 :          0 :         cmd.header = mc_encode_cmd_header(DPCI_CMDID_GET_ATTR,
     289                 :            :                                           cmd_flags,
     290                 :            :                                           token);
     291                 :            : 
     292                 :            :         /* send command to mc*/
     293                 :          0 :         err = mc_send_command(mc_io, &cmd);
     294         [ #  # ]:          0 :         if (err)
     295                 :            :                 return err;
     296                 :            : 
     297                 :            :         /* retrieve response parameters */
     298                 :            :         rsp_params = (struct dpci_rsp_get_attr *)cmd.params;
     299                 :          0 :         attr->id = le32_to_cpu(rsp_params->id);
     300                 :          0 :         attr->num_of_priorities = rsp_params->num_of_priorities;
     301                 :            : 
     302                 :          0 :         return 0;
     303                 :            : }
     304                 :            : 
     305                 :            : /**
     306                 :            :  * dpci_set_rx_queue() - Set Rx queue configuration
     307                 :            :  * @mc_io:      Pointer to MC portal's I/O object
     308                 :            :  * @cmd_flags:  Command flags; one or more of 'MC_CMD_FLAG_'
     309                 :            :  * @token:      Token of DPCI object
     310                 :            :  * @priority:   Select the queue relative to number of
     311                 :            :  *                      priorities configured at DPCI creation; use
     312                 :            :  *                      DPCI_ALL_QUEUES to configure all Rx queues
     313                 :            :  *                      identically.
     314                 :            :  * @cfg:        Rx queue configuration
     315                 :            :  *
     316                 :            :  * Return:      '0' on Success; Error code otherwise.
     317                 :            :  */
     318                 :          0 : int dpci_set_rx_queue(struct fsl_mc_io *mc_io,
     319                 :            :                       uint32_t cmd_flags,
     320                 :            :                       uint16_t token,
     321                 :            :                       uint8_t priority,
     322                 :            :                       const struct dpci_rx_queue_cfg *cfg)
     323                 :            : {
     324                 :            :         struct dpci_cmd_set_rx_queue *cmd_params;
     325                 :          0 :         struct mc_command cmd = { 0 };
     326                 :            : 
     327                 :            :         /* prepare command */
     328                 :          0 :         cmd.header = mc_encode_cmd_header(DPCI_CMDID_SET_RX_QUEUE,
     329                 :            :                                           cmd_flags,
     330                 :            :                                           token);
     331                 :            :         cmd_params = (struct dpci_cmd_set_rx_queue *)cmd.params;
     332                 :          0 :         cmd_params->dest_id = cpu_to_le32(cfg->dest_cfg.dest_id);
     333                 :          0 :         cmd_params->dest_priority = cfg->dest_cfg.priority;
     334                 :          0 :         cmd_params->priority = priority;
     335                 :          0 :         cmd_params->user_ctx = cpu_to_le64(cfg->user_ctx);
     336                 :          0 :         cmd_params->options = cpu_to_le32(cfg->options);
     337                 :          0 :         dpci_set_field(cmd_params->dest_type,
     338                 :            :                        DEST_TYPE,
     339                 :            :                        cfg->dest_cfg.dest_type);
     340                 :          0 :         dpci_set_field(cmd_params->dest_type,
     341                 :            :                        ORDER_PRESERVATION,
     342                 :            :                        cfg->order_preservation_en);
     343                 :            : 
     344                 :            :         /* send command to mc*/
     345                 :          0 :         return mc_send_command(mc_io, &cmd);
     346                 :            : }
     347                 :            : 
     348                 :            : /**
     349                 :            :  * dpci_get_rx_queue() - Retrieve Rx queue attributes.
     350                 :            :  * @mc_io:      Pointer to MC portal's I/O object
     351                 :            :  * @cmd_flags:  Command flags; one or more of 'MC_CMD_FLAG_'
     352                 :            :  * @token:      Token of DPCI object
     353                 :            :  * @priority:   Select the queue relative to number of
     354                 :            :  *              priorities configured at DPCI creation
     355                 :            :  * @attr:       Returned Rx queue attributes
     356                 :            :  *
     357                 :            :  * Return:      '0' on Success; Error code otherwise.
     358                 :            :  */
     359                 :          0 : int dpci_get_rx_queue(struct fsl_mc_io *mc_io,
     360                 :            :                       uint32_t cmd_flags,
     361                 :            :                       uint16_t token,
     362                 :            :                       uint8_t priority,
     363                 :            :                       struct dpci_rx_queue_attr *attr)
     364                 :            : {
     365                 :            :         struct dpci_cmd_get_queue *cmd_params;
     366                 :            :         struct dpci_rsp_get_rx_queue *rsp_params;
     367                 :          0 :         struct mc_command cmd = { 0 };
     368                 :            :         int err;
     369                 :            : 
     370                 :            :         /* prepare command */
     371                 :          0 :         cmd.header = mc_encode_cmd_header(DPCI_CMDID_GET_RX_QUEUE,
     372                 :            :                                           cmd_flags,
     373                 :            :                                           token);
     374                 :            :         cmd_params = (struct dpci_cmd_get_queue *)cmd.params;
     375                 :          0 :         cmd_params->priority = priority;
     376                 :            : 
     377                 :            :         /* send command to mc*/
     378                 :          0 :         err = mc_send_command(mc_io, &cmd);
     379         [ #  # ]:          0 :         if (err)
     380                 :            :                 return err;
     381                 :            : 
     382                 :            :         /* retrieve response parameters */
     383                 :            :         rsp_params = (struct dpci_rsp_get_rx_queue *)cmd.params;
     384                 :          0 :         attr->user_ctx = le64_to_cpu(rsp_params->user_ctx);
     385                 :          0 :         attr->fqid = le32_to_cpu(rsp_params->fqid);
     386                 :          0 :         attr->dest_cfg.dest_id = le32_to_cpu(rsp_params->dest_id);
     387                 :          0 :         attr->dest_cfg.priority = rsp_params->dest_priority;
     388                 :          0 :         attr->dest_cfg.dest_type = dpci_get_field(rsp_params->dest_type,
     389                 :            :                                                   DEST_TYPE);
     390                 :            : 
     391                 :          0 :         return 0;
     392                 :            : }
     393                 :            : 
     394                 :            : /**
     395                 :            :  * dpci_get_tx_queue() - Retrieve Tx queue attributes.
     396                 :            :  * @mc_io:      Pointer to MC portal's I/O object
     397                 :            :  * @cmd_flags:  Command flags; one or more of 'MC_CMD_FLAG_'
     398                 :            :  * @token:      Token of DPCI object
     399                 :            :  * @priority:   Select the queue relative to number of
     400                 :            :  *              priorities of the peer DPCI object
     401                 :            :  * @attr:       Returned Tx queue attributes
     402                 :            :  *
     403                 :            :  * Return:      '0' on Success; Error code otherwise.
     404                 :            :  */
     405                 :          0 : int dpci_get_tx_queue(struct fsl_mc_io *mc_io,
     406                 :            :                       uint32_t cmd_flags,
     407                 :            :                       uint16_t token,
     408                 :            :                       uint8_t priority,
     409                 :            :                       struct dpci_tx_queue_attr *attr)
     410                 :            : {
     411                 :            :         struct dpci_cmd_get_queue *cmd_params;
     412                 :            :         struct dpci_rsp_get_tx_queue *rsp_params;
     413                 :          0 :         struct mc_command cmd = { 0 };
     414                 :            :         int err;
     415                 :            : 
     416                 :            :         /* prepare command */
     417                 :          0 :         cmd.header = mc_encode_cmd_header(DPCI_CMDID_GET_TX_QUEUE,
     418                 :            :                                           cmd_flags,
     419                 :            :                                           token);
     420                 :            :         cmd_params = (struct dpci_cmd_get_queue *)cmd.params;
     421                 :          0 :         cmd_params->priority = priority;
     422                 :            : 
     423                 :            :         /* send command to mc*/
     424                 :          0 :         err = mc_send_command(mc_io, &cmd);
     425         [ #  # ]:          0 :         if (err)
     426                 :            :                 return err;
     427                 :            : 
     428                 :            :         /* retrieve response parameters */
     429                 :            :         rsp_params = (struct dpci_rsp_get_tx_queue *)cmd.params;
     430                 :          0 :         attr->fqid = le32_to_cpu(rsp_params->fqid);
     431                 :            : 
     432                 :          0 :         return 0;
     433                 :            : }
     434                 :            : 
     435                 :            : /**
     436                 :            :  * dpci_get_api_version() - Get communication interface API version
     437                 :            :  * @mc_io:      Pointer to MC portal's I/O object
     438                 :            :  * @cmd_flags:  Command flags; one or more of 'MC_CMD_FLAG_'
     439                 :            :  * @major_ver:  Major version of data path communication interface API
     440                 :            :  * @minor_ver:  Minor version of data path communication interface API
     441                 :            :  *
     442                 :            :  * Return:  '0' on Success; Error code otherwise.
     443                 :            :  */
     444                 :          0 : int dpci_get_api_version(struct fsl_mc_io *mc_io,
     445                 :            :                          uint32_t cmd_flags,
     446                 :            :                          uint16_t *major_ver,
     447                 :            :                          uint16_t *minor_ver)
     448                 :            : {
     449                 :            :         struct dpci_rsp_get_api_version *rsp_params;
     450                 :          0 :         struct mc_command cmd = { 0 };
     451                 :            :         int err;
     452                 :            : 
     453                 :          0 :         cmd.header = mc_encode_cmd_header(DPCI_CMDID_GET_API_VERSION,
     454                 :            :                                         cmd_flags,
     455                 :            :                                         0);
     456                 :            : 
     457                 :          0 :         err = mc_send_command(mc_io, &cmd);
     458         [ #  # ]:          0 :         if (err)
     459                 :            :                 return err;
     460                 :            : 
     461                 :            :         rsp_params = (struct dpci_rsp_get_api_version *)cmd.params;
     462                 :          0 :         *major_ver = le16_to_cpu(rsp_params->major);
     463                 :          0 :         *minor_ver = le16_to_cpu(rsp_params->minor);
     464                 :            : 
     465                 :          0 :         return 0;
     466                 :            : }
     467                 :            : 
     468                 :            : /**
     469                 :            :  * dpci_set_opr() - Set Order Restoration configuration.
     470                 :            :  * @mc_io:      Pointer to MC portal's I/O object
     471                 :            :  * @cmd_flags:  Command flags; one or more of 'MC_CMD_FLAG_'
     472                 :            :  * @token:      Token of DPCI object
     473                 :            :  * @index:      The queue index
     474                 :            :  * @options:    Configuration mode options
     475                 :            :  *              can be OPR_OPT_CREATE or OPR_OPT_RETIRE
     476                 :            :  * @cfg:        Configuration options for the OPR
     477                 :            :  *
     478                 :            :  * Return:      '0' on Success; Error code otherwise.
     479                 :            :  */
     480                 :          0 : int dpci_set_opr(struct fsl_mc_io *mc_io,
     481                 :            :                  uint32_t cmd_flags,
     482                 :            :                  uint16_t token,
     483                 :            :                  uint8_t index,
     484                 :            :                  uint8_t options,
     485                 :            :                  struct opr_cfg *cfg)
     486                 :            : {
     487                 :            :         struct dpci_cmd_set_opr *cmd_params;
     488                 :          0 :         struct mc_command cmd = { 0 };
     489                 :            : 
     490                 :            :         /* prepare command */
     491                 :          0 :         cmd.header = mc_encode_cmd_header(DPCI_CMDID_SET_OPR,
     492                 :            :                                           cmd_flags,
     493                 :            :                                           token);
     494                 :            :         cmd_params = (struct dpci_cmd_set_opr *)cmd.params;
     495                 :          0 :         cmd_params->index = index;
     496                 :          0 :         cmd_params->options = options;
     497                 :          0 :         cmd_params->oloe = cfg->oloe;
     498                 :          0 :         cmd_params->oeane = cfg->oeane;
     499                 :          0 :         cmd_params->olws = cfg->olws;
     500                 :          0 :         cmd_params->oa = cfg->oa;
     501                 :          0 :         cmd_params->oprrws = cfg->oprrws;
     502                 :            : 
     503                 :            :         /* send command to mc*/
     504                 :          0 :         return mc_send_command(mc_io, &cmd);
     505                 :            : }
     506                 :            : 
     507                 :            : /**
     508                 :            :  * dpci_get_opr() - Retrieve Order Restoration config and query.
     509                 :            :  * @mc_io:      Pointer to MC portal's I/O object
     510                 :            :  * @cmd_flags:  Command flags; one or more of 'MC_CMD_FLAG_'
     511                 :            :  * @token:      Token of DPCI object
     512                 :            :  * @index:      The queue index
     513                 :            :  * @cfg:        Returned OPR configuration
     514                 :            :  * @qry:        Returned OPR query
     515                 :            :  *
     516                 :            :  * Return:      '0' on Success; Error code otherwise.
     517                 :            :  */
     518                 :          0 : int dpci_get_opr(struct fsl_mc_io *mc_io,
     519                 :            :                  uint32_t cmd_flags,
     520                 :            :                  uint16_t token,
     521                 :            :                  uint8_t index,
     522                 :            :                  struct opr_cfg *cfg,
     523                 :            :                  struct opr_qry *qry)
     524                 :            : {
     525                 :            :         struct dpci_rsp_get_opr *rsp_params;
     526                 :            :         struct dpci_cmd_get_opr *cmd_params;
     527                 :          0 :         struct mc_command cmd = { 0 };
     528                 :            :         int err;
     529                 :            : 
     530                 :            :         /* prepare command */
     531                 :          0 :         cmd.header = mc_encode_cmd_header(DPCI_CMDID_GET_OPR,
     532                 :            :                                           cmd_flags,
     533                 :            :                                           token);
     534                 :            :         cmd_params = (struct dpci_cmd_get_opr *)cmd.params;
     535                 :          0 :         cmd_params->index = index;
     536                 :            : 
     537                 :            :         /* send command to mc*/
     538                 :          0 :         err = mc_send_command(mc_io, &cmd);
     539         [ #  # ]:          0 :         if (err)
     540                 :            :                 return err;
     541                 :            : 
     542                 :            :         /* retrieve response parameters */
     543                 :            :         rsp_params = (struct dpci_rsp_get_opr *)cmd.params;
     544                 :          0 :         cfg->oloe = rsp_params->oloe;
     545                 :          0 :         cfg->oeane = rsp_params->oeane;
     546                 :          0 :         cfg->olws = rsp_params->olws;
     547                 :          0 :         cfg->oa = rsp_params->oa;
     548                 :          0 :         cfg->oprrws = rsp_params->oprrws;
     549                 :          0 :         qry->rip = dpci_get_field(rsp_params->flags, RIP);
     550                 :          0 :         qry->enable = dpci_get_field(rsp_params->flags, OPR_ENABLE);
     551                 :          0 :         qry->nesn = le16_to_cpu(rsp_params->nesn);
     552                 :          0 :         qry->ndsn = le16_to_cpu(rsp_params->ndsn);
     553                 :          0 :         qry->ea_tseq = le16_to_cpu(rsp_params->ea_tseq);
     554                 :          0 :         qry->tseq_nlis = dpci_get_field(rsp_params->tseq_nlis, TSEQ_NLIS);
     555                 :          0 :         qry->ea_hseq = le16_to_cpu(rsp_params->ea_hseq);
     556                 :          0 :         qry->hseq_nlis = dpci_get_field(rsp_params->hseq_nlis, HSEQ_NLIS);
     557                 :          0 :         qry->ea_hptr = le16_to_cpu(rsp_params->ea_hptr);
     558                 :          0 :         qry->ea_tptr = le16_to_cpu(rsp_params->ea_tptr);
     559                 :          0 :         qry->opr_vid = le16_to_cpu(rsp_params->opr_vid);
     560                 :          0 :         qry->opr_id = le16_to_cpu(rsp_params->opr_id);
     561                 :            : 
     562                 :          0 :         return 0;
     563                 :            : }

Generated by: LCOV version 1.14