Scalable Scatter-Gather DMA Intel® FPGA IP User Guide

ID 823097
Date 4/07/2025
Public
Document Table of Contents

5.2.2. intel_ssgdma.c 

Table 68.  intel_ssgdma_open 

Prototype 

intel_ssgdma_dev *intel_ssgdma_open(const char *name) 

Include 

<intel_ssgdma.h> 

Parameters 

name - Character pointer to name of ssgdma device. 

Return 

intel_ssgdma_dev *dev - Success.  

Null - Invalid name or device is not registered. 

Description 

Retrieve a pointer to the ssgdma device instance of the given name. For this api to work properly, instance must be within the scope, where this function is called. 

Table 69.  intel_ssgdma_init

Prototype 

void intel_ssgdma_init(intel_ssgdma_dev *const dev, const FPGA_INTERRUPT_HANDLE irq_controller_id, const FPGA_INTERRUPT_HANDLE irq, const FPGA_MMIO_INTERFACE_HANDLE mmio_handle, const uint16_t num_D2H_ST_device_ports, const uint16_t num_H2D_ST_device_ports, const uint16_t num_H2D_MM_device_ports, const uint16_t total_device_ports, const bool restrict_unaligned_access) 

Include 

<intel_ssgdma.h> 

Parameters 

  • dev - pointer to the SSGDMA device structure.  
  • irq_controller_id - interrupt controller id.  
  • irq - interrupt number.  
  • mmio_handle - memory in out handler for the device.  
  • num_D2H_ST_device_ports - total number of Host to Device memory mapped port.  
  • num_H2D_ST_device_ports - total number of Host to Device streaming port.  
  • num_H2D_MM_device_ports - total number of Device to Host streaming port.  
  • total_device_ports - total number of all device ports.  
  • restrict_unaligned_access - For 32-bit system, restrict 32 bytes aligned address for descriptor and multiple of 4 for length. Doubles for 64-bit system. 

Return 

None 

Description 

Initializes the Scalable Scatter-Gather DMA controller. This routine is called from the INTEL_SSGDMA_INIT macro and is called automatically by alt_sys_init.c in HAL system. 

 
Table 70.  intel_ssgdma_register_global_error_callback  

Prototype 

intel_ssgdma_return_e intel_ssgdma_register_global_error_callback( intel_ssgdma_dev *dev, intel_ssgdma_global_error_callback callback, void *user_context) 

Include 

<intel_ssgdma.h> 

Parameters 

  • dev - Pointer to ssgdma device (instance) structure.  
  • callback - Pointer to callback routine to execute at interrupt level. 
  • user_context - user defined context. 

Return 

E_INTEL_SSGDMA_OK : 0 -> Success.

E_INTEL_SSGDMA_INVALID_ARGUMENT : -1 -> Invalid arguments. 

Description 

Function is set user callback function for ISR from application. User may use this function to handle global errors.  

 

Notes: When defining global error callback, user should set a flag in user_context to initiate device global reset flow. Please do not call the API directly in the callback, as most of the API blocks until the hw is stopped or reset. The user callback is called directly in the intel_ssgdma_irq.  

 

Suggested global reset flow:  

  • intel_ssgdma_global_soft_pause  
  • intel_ssgdma_global_soft_reset  
  • intel_ssgdma_global_resume 

Callback Details 

typedef void (*intel_ssgdma_global_error_callback)(void *user_context, const FPGA_MMIO_INTERFACE_HANDLE csr_base, const uint32_t global_status);

Callback Arguments:
  • user_context - pointer to user defined callback context
  • csr_base - Base address to identify the interrupting device.
  • global_status - saved value of global status register upon interrupt. 
Table 71.  intel_ssgdma_register_queue_error_callback 

Prototype 

intel_ssgdma_return_e intel_ssgdma_register_queue_error_callback( 

intel_ssgdma_dev *dev, intel_ssgdma_queue_error_callback callback, 

void *user_context) 

Include 

<intel_ssgdma.h> 

Parameters 

  • dev - Pointer to ssgdma device (instance) structure. 
  • callback - Pointer to callback routine to execute at interrupt level 
  • user_context - user defined context. 

Return 

E_INTEL_SSGDMA_OK                                  :  0  -> Success. 

E_INTEL_SSGDMA_INVALID_ARGUMENT : -1  -> Invalid arguments. 

Description 

Function is set user callback function for ISR from application. 

User may use this function to handle device port or descriptor errors. 

 

Notes: 

When defining queue error callback, user should set a flag in user_context 

to initiate device port reset flow. Please do not call the API directly 

in the callback, as most of the API blocks until the hw is stopped or reset. 

The user callback is called directly in intel_ssgdma_irq. 

Suggested device port reset flow: 
  • intel_ssgdma_device_port_soft_pause 
  • intel_ssgdma_device_port_soft_reset 
  • intel_ssgdma_device_port_reuse_setup 

Callback Details 

typedef void (*intel_ssgdma_queue_error_callback)(void *user_context, const FPGA_MMIO_INTERFACE_HANDLE csr_base, const intel_ssgdma_port_type_e port_type, const uint16_t port_num, const uint32_t q_status);

Callback Arguments: 
  • user_context  - user defined callback context
  • csr_base - Base address to identify the interrupting device. 
  • port_type - port type to identify the interrupting device port. 
  • port_num - port num to identify the interrupting device port. 
  • q_status  - saved value of queue status register upon interrupt.
Table 72.  intel_ssgdma_register_complete_callback  

Prototype 

intel_ssgdma_return_e intel_ssgdma_register_complete_callback( 

    intel_ssgdma_dev *dev, intel_ssgdma_complete_callback callback, 

    void *user_context) 

Include 

<intel_ssgdma.h> 

Parameters 

  • dev - Pointer to ssgdma device (instance) structure. 
  • callback - Pointer to callback routine to execute at interrupt level 
  • user_context  - user defined context

Return 

E_INTEL_SSGDMA_OK                                  :  0  -> Success. 

E_INTEL_SSGDMA_INVALID_ARGUMENT : -1  -> Invalid arguments. 

Description 

Function is set to user callback function for ISR from application. 

You may use this function to handle responder completed event. 

Notes: 

When defining completion callback, user should set a flag in user_context 

to signal transfer completion. Please do not call the API directly 

in the callback, as most of the API blocks until the hw is stopped or reset. 

The user callback is called by intel_ssgdma_service_all_completed_resp in 

intel_ssgdma_irq. 

Callback Details 

typedef void (*intel_ssgdma_complete_callback)(void *user_context,  const FPGA_MMIO_INTERFACE_HANDLE csr_base, const intel_ssgdma_port_type_e port_type,  const uint16_t port_num, const uint16_t completed_resp_num); 

Callback Arguments: 
  • user_context  - user defined callback context
  • csr_base - Base address to identify the interrupting device
  • port_type - port type to identify the interrupting device port
  • port_num  - port num to identify the interrupting device port
  • completed_resp_num - number of completed responder, since last service
Table 73.  intel_ssgdma_register_video_flushing_callback

Prototype 

intel_ssgdma_return_e intel_ssgdma_register_video_flushing_callback( 

    intel_ssgdma_dev *dev, intel_ssgdma_video_flushing_callback callback, 

    void *user_context) 

Include 

<intel_ssgdma.h> 

Parameters 

  • dev                    - Pointer to ssgdma device (instance) structure. 
  • callback            - Pointer to callback routine to execute at interrupt level 
  • user_context   - user defined context

Return 

E_INTEL_SSGDMA_OK                                  :  0  -> Success. 

E_INTEL_SSGDMA_INVALID_ARGUMENT : -1  -> Invalid arguments. 

Description 

Function is set user callback function for ISR from application. 

You may use this function to handle video flushing event. 

Notes: 

When defining video flushing callback, you should set a flag in user_context 

to signal transfer completion. Please do not call the API directly 

in the callback, as most of the API blocks until the hw is stopped or reset. 

The user callback is called by intel_ssgdma_video_flushing_event in 

intel_ssgdma_irq. 

Callback Details 

typedef void (*intel_ssgdma_video_flushing_callback)(void *user_context, const FPGA_MMIO_INTERFACE_HANDLE csr_base, const intel_ssgdma_port_type_e port_type, const uint16_t port_num, const uint16_t next_pend_desc_hw_idx, const uint32_t q_bytessent, const uint32_t q_total_bytessent); 

Callback Arguments: 

- user_context  - user defined callback context 

- csr_base          - Base address to identify the interrupting device. 

- port_type        - port type to identify the interrupting device port. 

- port_num        - port num to identify the interrupting device port. 

- next_pend_desc_hw_idx - hw index of the descriptor, that is being flushed. 

- q_bytessent                       - bytes sent during flushing event. 

- q_total_bytessent            - total byte sent since first flushing event. 

Table 74.  intel_ssgdma_cal_host_mem_size 

Prototype 

intel_ssgdma_return_e intel_ssgdma_cal_host_mem_size( intel_ssgdma_dev *dev, uint16_t total_desc_block, uint16_t total_resp_block, size_t *total_alloc_bytes) 

Include 

<intel_ssgdma.h> 

Parameters 

  • dev - Pointer to the ssgdma device structure.  
  • total_desc_block - Total number of descriptor blocks for all ports.
  • total_resp_block - Total number of responder blocks for all ports. 
  • total_alloc_bytes - Pointer to total bytes that should be allocated.

Return 

E_INTEL_SSGDMA_OK : 0 → Success.

E_INTEL_SSGDMA_INVALID_ARGUMENT : -1 → Invalid arguments. 

E_INTEL_SSGDMA_ALREADY_SETUP : -9 → Already calculated. Please reset before calling this function.

Description 

Calculates required host memory allocation to hold descriptors and responders for dma operations. You are advised to allocate at least 1 descriptor block to each device port. This function can only be called once. Please call intel_ssgdma_global_soft_reset to start again.

After this you should use total_alloc_bytes to allocate host memory and call intel_ssgdma_set_desc_start to assign the memory to the driver.

Table 75.  intel_ssgdma_set_desc_start 

Prototype 

intel_ssgdma_return_e intel_ssgdma_cal_host_mem_size( intel_ssgdma_dev *dev, uint16_t total_desc_block, uint16_t total_resp_block, size_t *total_alloc_bytes) 

Include 

<intel_ssgdma.h> 

Parameters 

  • dev - Pointer to the ssgdma device structure.  
  • desc_start - pointer to host memory, which is used to store the first descriptor of the ssgdma device instance..

Return 

E_INTEL_SSGDMA_OK : 0 → Success.

E_INTEL_SSGDMA_INVALID_ARGUMENT : -1 → Invalid arguments. 

E_INTEL_SSGDMA_MEMALLOC_ERROR : -4 → Given desc_start is null pointer or unaligned address.

E_INTEL_SSGDMA_ALREADY_SETUP: -9 → Already assigned. Please reset before calling this function.

Description 

Assign the allocated host memory as the address of the first descriptor of the device port. This function can only be called once. Please call intel_ssgdma_global_soft_reset to start again..

Before this function, you must first call intel_ssgdma_cal_host_mem_size.