no-OS
Loading...
Searching...
No Matches
oa_tc6.c File Reference
#include <errno.h>
#include <stdlib.h>
#include <stdint.h>
#include <stdbool.h>
#include <string.h>
#include "no_os_alloc.h"
#include "no_os_delay.h"
#include "no_os_mutex.h"
#include "oa_tc6.h"
Include dependency graph for oa_tc6.c:

Functions

int oa_rx_chunk_to_frame (struct oa_tc6_desc *desc, uint8_t *chunks, uint32_t len)
 
int oa_tc6_reg_read (struct oa_tc6_desc *desc, uint32_t addr, uint32_t *val)
 Write a register value.
 
int oa_tc6_reg_write (struct oa_tc6_desc *desc, uint32_t addr, uint32_t val)
 Write a register value.
 
int __oa_tc6_reg_update (struct oa_tc6_desc *desc, uint32_t addr, uint32_t val, uint32_t mask)
 
int oa_tc6_reg_update (struct oa_tc6_desc *desc, uint32_t addr, uint32_t val, uint32_t mask)
 Update a field inside a register.
 
int oa_tc6_get_tx_frame (struct oa_tc6_desc *desc, struct oa_tc6_frame_buffer **buffer)
 Get a frame buffer that can be filled by user.
 
int oa_tc6_put_tx_frame (struct oa_tc6_desc *desc, struct oa_tc6_frame_buffer *buffer)
 Mark a frame buffer as ready to be transmitted.
 
int oa_tc6_get_rx_frame_match_vs (struct oa_tc6_desc *desc, struct oa_tc6_frame_buffer **buffer, uint8_t vs, uint8_t mask)
 Get a frame buffer that is ready to be read by the user. The VS field in the chunk footer fields should match what is provided.
 
int oa_tc6_get_rx_frame (struct oa_tc6_desc *desc, struct oa_tc6_frame_buffer **buffer)
 Get a frame buffer that is ready to be read by the user.
 
int oa_tc6_put_rx_frame (struct oa_tc6_desc *desc, struct oa_tc6_frame_buffer *buffer)
 Mark a frame buffer as used and ready to be rewritten.
 
int oa_tc6_get_xfer_flags (struct oa_tc6_desc *desc, struct oa_tc6_flags *flags, bool clear)
 Gets the latched transfer flags that are read from the data chunk footer. Optionally clears the latched values.
 
int oa_tc6_thread (struct oa_tc6_desc *desc)
 Transmit all the frames in the OA_BUFF_TX_READY state and receive the frames in the OA_BUFF_RX_COMPLETE state.
 
int oa_tc6_sw_reset (struct oa_tc6_desc *desc)
 Trigger a soft reset of the MAC-PHY via the OA-TC6 RESET register and wait for completion. Mirrors the linux oa_tc6_sw_reset_macphy: write SWRESET, poll STATUS0.RESETC every 1ms up to 1s, then RW1C clear the reset-complete status.
 
int oa_tc6_register_callback (struct oa_tc6_desc *desc, void(*callback)(struct oa_tc6_desc *, uint32_t, void *), void *arg)
 
int oa_tc6_get_stats (struct oa_tc6_desc *desc, struct oa_tc6_stats *stats)
 Get a snapshot of the software statistics counters.
 
int oa_tc6_reset_stats (struct oa_tc6_desc *desc)
 Reset the software statistics counters to zero.
 
int oa_tc6_init (struct oa_tc6_desc **desc, struct oa_tc6_init_param *param)
 Allocate resources for the OA TC6 driver.
 
int oa_tc6_remove (struct oa_tc6_desc *desc)
 Free a device descriptor.
 

Function Documentation

◆ __oa_tc6_reg_update()

int __oa_tc6_reg_update ( struct oa_tc6_desc * desc,
uint32_t addr,
uint32_t val,
uint32_t mask )

◆ oa_rx_chunk_to_frame()

int oa_rx_chunk_to_frame ( struct oa_tc6_desc * desc,
uint8_t * chunks,
uint32_t len )

◆ oa_tc6_get_rx_frame()

int oa_tc6_get_rx_frame ( struct oa_tc6_desc * desc,
struct oa_tc6_frame_buffer ** buffer )

Get a frame buffer that is ready to be read by the user.

Parameters
desc- the OA TC6 descriptor.
buffer- buffer containing the frame received.
Returns
0 in case of success, negative error code otherwise

◆ oa_tc6_get_rx_frame_match_vs()

int oa_tc6_get_rx_frame_match_vs ( struct oa_tc6_desc * desc,
struct oa_tc6_frame_buffer ** buffer,
uint8_t vs,
uint8_t mask )

Get a frame buffer that is ready to be read by the user. The VS field in the chunk footer fields should match what is provided.

Parameters
desc- the OA TC6 descriptor.
buffer- buffer containing the frame received.
vs- the value of the VS field to match.
mask- the mask to apply to the VS field.
Returns
0 in case of success, negative error code otherwise

◆ oa_tc6_get_stats()

int oa_tc6_get_stats ( struct oa_tc6_desc * desc,
struct oa_tc6_stats * stats )

Get a snapshot of the software statistics counters.

Parameters
desc- the device descriptor.
stats- storage for the snapshot.
Returns
0 in case of success, negative error code otherwise.

◆ oa_tc6_get_tx_frame()

int oa_tc6_get_tx_frame ( struct oa_tc6_desc * desc,
struct oa_tc6_frame_buffer ** buffer )

Get a frame buffer that can be filled by user.

Parameters
desc- the OA TC6 descriptor.
buffer- buffer containing the frame to be transmitted.
Returns
0 in case of success, negative error code otherwise

◆ oa_tc6_get_xfer_flags()

int oa_tc6_get_xfer_flags ( struct oa_tc6_desc * desc,
struct oa_tc6_flags * flags,
bool clear )

Gets the latched transfer flags that are read from the data chunk footer. Optionally clears the latched values.

Parameters
desc- the OA TC6 descriptor
flags- Storage location for flag values
clear- If set, clears the latch and valid
Returns
0 in case of success, negative error code otherwise

◆ oa_tc6_init()

int oa_tc6_init ( struct oa_tc6_desc ** desc,
struct oa_tc6_init_param * param )

Allocate resources for the OA TC6 driver.

Parameters
desc- the device descriptor to be initialized
param- the device's parameter
Returns
0 in case of success, negative error code otherwise

◆ oa_tc6_put_rx_frame()

int oa_tc6_put_rx_frame ( struct oa_tc6_desc * desc,
struct oa_tc6_frame_buffer * buffer )

Mark a frame buffer as used and ready to be rewritten.

Parameters
desc- the OA TC6 descriptor.
buffer- buffer containing the frame read by the user.
Returns
0 in case of success, negative error code otherwise

◆ oa_tc6_put_tx_frame()

int oa_tc6_put_tx_frame ( struct oa_tc6_desc * desc,
struct oa_tc6_frame_buffer * buffer )

Mark a frame buffer as ready to be transmitted.

Parameters
desc- the OA TC6 descriptor.
buffer- buffer containing the frame to be transmitted.
Returns
0 in case of success, negative error code otherwise

◆ oa_tc6_reg_read()

int oa_tc6_reg_read ( struct oa_tc6_desc * desc,
uint32_t addr,
uint32_t * val )

Write a register value.

Parameters
desc- the OA TC6 descriptor.
addr- Register address.
val- Register value.
Returns
0 in case of success, negative error code otherwise

◆ oa_tc6_reg_update()

int oa_tc6_reg_update ( struct oa_tc6_desc * desc,
uint32_t addr,
uint32_t val,
uint32_t mask )

Update a field inside a register.

Parameters
desc- the OA TC6 descriptor.
addr- Register address.
val- Field value.
mask- Bit mask corresponding to the register field.
Returns
0 in case of success, negative error code otherwise

◆ oa_tc6_reg_write()

int oa_tc6_reg_write ( struct oa_tc6_desc * desc,
uint32_t addr,
uint32_t val )

Write a register value.

Parameters
desc- the OA TC6 descriptor.
addr- Register address.
val- Register value.
Returns
0 in case of success, negative error code otherwise

◆ oa_tc6_register_callback()

int oa_tc6_register_callback ( struct oa_tc6_desc * desc,
void(* callback )(struct oa_tc6_desc *, uint32_t, void *),
void * arg )

◆ oa_tc6_remove()

int oa_tc6_remove ( struct oa_tc6_desc * desc)

Free a device descriptor.

Parameters
desc- the device descriptor to be removed.
Returns
0

◆ oa_tc6_reset_stats()

int oa_tc6_reset_stats ( struct oa_tc6_desc * desc)

Reset the software statistics counters to zero.

Parameters
desc- the device descriptor.
Returns
0 in case of success, negative error code otherwise.

◆ oa_tc6_sw_reset()

int oa_tc6_sw_reset ( struct oa_tc6_desc * desc)

Trigger a soft reset of the MAC-PHY via the OA-TC6 RESET register and wait for completion. Mirrors the linux oa_tc6_sw_reset_macphy: write SWRESET, poll STATUS0.RESETC every 1ms up to 1s, then RW1C clear the reset-complete status.

Parameters
desc- the OA TC6 descriptor.
Returns
0 in case of success, -ENODEV on timeout, negative error otherwise.

◆ oa_tc6_thread()

int oa_tc6_thread ( struct oa_tc6_desc * desc)

Transmit all the frames in the OA_BUFF_TX_READY state and receive the frames in the OA_BUFF_RX_COMPLETE state.

Parameters
desc- the OA TC6 descriptor
Returns
0 in case of success, negative error code otherwise