dpdk/drivers/net/dpaa/fmlib/ncsw_ext.h
<<
>>
Prefs
   1/* SPDX-License-Identifier: (BSD-3-Clause OR GPL-2.0)
   2 * Copyright 2008-2012 Freescale Semiconductor Inc.
   3 * Copyright 2017-2020 NXP
   4 */
   5
   6#ifndef __NCSW_EXT_H
   7#define __NCSW_EXT_H
   8
   9#include <stdint.h>
  10
  11#define PTR_TO_UINT(_ptr)       ((uintptr_t)(_ptr))
  12#define UINT_TO_PTR(_val)       ((void *)(uintptr_t)(_val))
  13
  14/* phys_address_t should be uintptr_t */
  15typedef uint64_t phys_address_t;
  16
  17/*
  18 * @Description   Possible RxStore callback responses.
  19 */
  20typedef enum e_rx_store_response {
  21        e_RX_STORE_RESPONSE_PAUSE
  22                /**< Pause invoking callback with received data; in polling
  23                 * mode, start again invoking callback only next time user
  24                 * invokes the receive routine; in interrupt mode, start again
  25                 * invoking callback only next time a receive event triggers an
  26                 * interrupt; in all cases, received data that are pending are
  27                 * not lost, rather, their processing is temporarily deferred;
  28                 * in all cases, received data are processed in the order in
  29                 * which they were received.
  30                 */
  31        , e_RX_STORE_RESPONSE_CONTINUE
  32                /**< Continue invoking callback with received data. */
  33} e_rx_store_response;
  34
  35
  36/*
  37 * @Description   General Handle
  38 */
  39typedef void *t_handle;   /**< handle, used as object's descriptor */
  40
  41/* @} */
  42
  43/*
  44 * @Function      t_get_buf_function
  45 *
  46 * @Description   User callback function called by driver to get data buffer.
  47 *
  48 *                User provides this function. Driver invokes it.
  49 *
  50 * @Param[in]     h_buffer_pool         A handle to buffer pool manager
  51 * @Param[out]    p_buf_context_handle  Returns the user's private context that
  52 *                                      should be associated with the buffer
  53 *
  54 * @Return        Pointer to data buffer, NULL if error
  55 */
  56typedef uint8_t * (t_get_buf_function)(t_handle   h_buffer_pool,
  57                                        t_handle *p_buf_context_handle);
  58
  59/*
  60 * @Function      t_put_buf_function
  61 *
  62 * @Description   User callback function called by driver to return data buffer.
  63 *                User provides this function. Driver invokes it.
  64 *
  65 * @Param[in]     h_buffer_pool         A handle to buffer pool manager
  66 * @Param[in]     p_buffer              A pointer to buffer to return
  67 * @Param[in]     h_buf_context         The user's private context associated
  68 *                                      with the returned buffer
  69 *
  70 * @Return        E_OK on success; Error code otherwise
  71 */
  72typedef uint32_t (t_put_buf_function)(t_handle h_buffer_pool,
  73                                uint8_t  *p_buffer,
  74                                t_handle h_buf_context);
  75
  76/*
  77 * @Function      t_phys_to_virt
  78 *
  79 * @Description   Translates a physical address to the matching virtual address.
  80 *
  81 * @Param[in]     addr          The physical address to translate.
  82 *
  83 * @Return        Virtual address.
  84 */
  85typedef void *t_phys_to_virt(phys_address_t addr);
  86
  87/*
  88 * @Function      t_virt_to_phys
  89 *
  90 * @Description   Translates a virtual address to the matching physical address.
  91 *
  92 * @Param[in]     addr          The virtual address to translate.
  93 *
  94 * @Return        Physical address.
  95 */
  96typedef phys_address_t t_virt_to_phys(void *addr);
  97
  98/*
  99 * @Description   Buffer Pool Information Structure.
 100 */
 101typedef struct t_buffer_pool_info {
 102        t_handle                h_buffer_pool;
 103                /**< A handle to the buffer pool mgr */
 104        t_get_buf_function      *f_get_buf;
 105                /**< User callback to get a free buffer */
 106        t_put_buf_function      *f_put_buf;
 107                /**< User callback to return a buffer */
 108        uint16_t                buffer_size;
 109                /**< Buffer size (in bytes) */
 110        t_phys_to_virt  *f_phys_to_virt;
 111                /**< User callback to translate pool buffers physical addresses
 112                 * to virtual addresses
 113                 */
 114        t_virt_to_phys  *f_virt_to_phys;
 115                /**< User callback to translate pool buffers virtual addresses
 116                 * to physical addresses
 117                 */
 118} t_buffer_pool_info;
 119
 120/*
 121 * @Description   User callback function called by driver with receive data.
 122 *                User provides this function. Driver invokes it.
 123 *
 124 * @Param[in]     h_app         Application's handle, as was provided to the
 125 *                              driver by the user
 126 * @Param[in]     queue_id      Receive queue ID
 127 * @Param[in]     p_data        Pointer to the buffer with received data
 128 * @Param[in]     h_buf_context The user's private context associated with the
 129 *                              given data buffer
 130 * @Param[in]     length        Length of received data
 131 * @Param[in]     status        Receive status and errors
 132 * @Param[in]     position      Position of buffer in frame
 133 * @Param[in]     flags         Driver-dependent information
 134 *
 135 * @Retval        e_RX_STORE_RESPONSE_CONTINUE  order the driver to continue Rx
 136 *                                              operation for all ready data.
 137 * @Retval        e_RX_STORE_RESPONSE_PAUSE     order the driver to stop Rx ops.
 138 */
 139typedef e_rx_store_response(t_rx_store_function)(t_handle  h_app,
 140                                                uint32_t  queue_id,
 141                                                uint8_t   *p_data,
 142                                                t_handle  h_buf_context,
 143                                                uint32_t  length,
 144                                                uint16_t  status,
 145                                                uint8_t   position,
 146                                                uint32_t  flags);
 147
 148typedef struct t_device {
 149        uintptr_t   id; /**< the device id */
 150        int     fd;     /**< the device file descriptor */
 151        t_handle        h_user_priv;
 152        uint32_t        owners;
 153} t_device;
 154
 155t_handle create_device(t_handle h_user_priv, t_handle h_dev_id);
 156t_handle get_device_id(t_handle h_dev);
 157
 158#endif /* __NCSW_EXT_H */
 159