no-OS
All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
oa_tc6.h File Reference
#include "no_os_spi.h"
#include "no_os_util.h"
#include <stdint.h>
Include dependency graph for oa_tc6.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  oa_tc6_frame_buffer
 Stores an Ethernet frame along with metadata needed for parsing. The MAC driver or the user application will receive and submit frames for transmission in this format. More...
 
struct  oa_tc6_desc
 Holds the frame buffers and the communication descriptor for the OA TC6 driver. More...
 
struct  oa_tc6_init_param
 Holds the initialization parameters for the OA TC6 driver. More...
 

Macros

#define CONFIG_OA_TX_FRAME_BUFF_NUM   2
 
#define CONFIG_OA_RX_FRAME_BUFF_NUM   5
 
#define CONFIG_OA_CHUNK_BUFFER_SIZE   1514
 
#define OA_TX_FRAME_BUFF_NUM   CONFIG_OA_TX_FRAME_BUFF_NUM
 
#define OA_RX_FRAME_BUFF_NUM   CONFIG_OA_RX_FRAME_BUFF_NUM
 
#define OA_SPI_BUFF_LEN   1632
 
#define OA_CHUNK_SIZE   64
 
#define OA_REG_LEN   4
 
#define OA_HEADER_LEN   4
 
#define OA_FOOTER_LEN   4
 
#define OA_MMS_REG(m, r)
 
#define OA_CTRL_ADDR_MMS_MASK   NO_OS_GENMASK(27, 8)
 
#define OA_CTRL_HDRB_MASK   NO_OS_BIT(30)
 
#define OA_CTRL_WNR_MASK   NO_OS_BIT(29)
 
#define OA_CTRL_AID_MASK   NO_OS_BIT(28)
 
#define OA_CTRL_MMS_MASK   NO_OS_GENMASK(27, 24)
 
#define OA_CTRL_ADDR_MASK   NO_OS_GENMASK(23, 8)
 
#define OA_CTRL_LEN_MASK   NO_OS_GENMASK(7, 1)
 
#define OA_CTRL_P_MASK   NO_OS_BIT(0)
 
#define OA_DATA_FOOTER_EXST_MASK   NO_OS_BIT(31)
 
#define OA_DATA_FOOTER_HDRB_MASK   NO_OS_BIT(30)
 
#define OA_DATA_FOOTER_SYNC_MASK   NO_OS_BIT(29)
 
#define OA_DATA_FOOTER_RCA_MASK   NO_OS_GENMASK(28, 24)
 
#define OA_DATA_FOOTER_VS_MASK   NO_OS_GENMASK(23, 22)
 
#define OA_DATA_FOOTER_DV_MASK   NO_OS_BIT(21)
 
#define OA_DATA_FOOTER_SV_MASK   NO_OS_BIT(20)
 
#define OA_DATA_FOOTER_SWO_MASK   NO_OS_GENMASK(19, 16)
 
#define OA_DATA_FOOTER_EV_MASK   NO_OS_BIT(14)
 
#define OA_DATA_FOOTER_EBO_MASK   NO_OS_GENMASK(13, 8)
 
#define OA_DATA_FOOTER_TXC_MASK   NO_OS_GENMASK(5, 1)
 
#define OA_DATA_FOOTER_P_MASK   NO_OS_BIT(0)
 
#define OA_DATA_HEADER_DNC_MASK   NO_OS_BIT(31)
 
#define OA_DATA_HEADER_SEQ_MASK   NO_OS_BIT(30)
 
#define OA_DATA_HEADER_NORX_MASK   NO_OS_BIT(29)
 
#define OA_DATA_HEADER_VS_MASK   NO_OS_GENMASK(23, 22)
 
#define OA_DATA_HEADER_DV_MASK   NO_OS_BIT(21)
 
#define OA_DATA_HEADER_SV_MASK   NO_OS_BIT(20)
 
#define OA_DATA_HEADER_SWO_MASK   NO_OS_GENMASK(19, 16)
 
#define OA_DATA_HEADER_EV_MASK   NO_OS_BIT(14)
 
#define OA_DATA_HEADER_EBO_MASK   NO_OS_GENMASK(13, 8)
 
#define OA_DATA_HEADER_P_MASK   NO_OS_BIT(0)
 
#define OA_TC6_IDVER_REG   OA_MMS_REG(0x0, 0x0000)
 
#define OA_TC6_PHYID_REG   OA_MMS_REG(0x0, 0x0001)
 
#define OA_TC6_STDCAP_REG   OA_MMS_REG(0x0, 0x0002)
 
#define OA_TC6_RESET_REG   OA_MMS_REG(0x0, 0x0003)
 
#define OA_TC6_CONFIG0_REG   OA_MMS_REG(0x0, 0x0004)
 
#define OA_TC6_CONFIG1_REG   OA_MMS_REG(0x0, 0x0005)
 
#define OA_TC6_CONFIG2_REG   OA_MMS_REG(0x0, 0x0006)
 
#define OA_TC6_STATUS0_REG   OA_MMS_REG(0x0, 0x0008)
 
#define OA_TC6_STATUS1_REG   OA_MMS_REG(0x0, 0x0009)
 
#define OA_TC6_BUFST_REG   OA_MMS_REG(0x0, 0x000B)
 
#define OA_TC6_IMSK0_REG   OA_MMS_REG(0x0, 0x000C)
 
#define OA_TC6_IMSK1_REG   OA_MMS_REG(0x0, 0x000D)
 
#define OA_TC6_TTSCAH_REG   OA_MMS_REG(0x0, 0x0010)
 
#define OA_TC6_TTSCAL_REG   OA_MMS_REG(0x0, 0x0011)
 
#define OA_TC6_TTSCBH_REG   OA_MMS_REG(0x0, 0x0012)
 
#define OA_TC6_TTSCBL_REG   OA_MMS_REG(0x0, 0x0013)
 
#define OA_TC6_TTSCCH_REG   OA_MMS_REG(0x0, 0x0014)
 
#define OA_TC6_TTSCCL_REG   OA_MMS_REG(0x0, 0x0015)
 
#define OA_TC6_MDIOACC0_REG   OA_MMS_REG(0x0, 0x0020)
 
#define OA_TC6_MDIOACC1_REG   OA_MMS_REG(0x0, 0x0021)
 
#define OA_TC6_MDIOACC2_REG   OA_MMS_REG(0x0, 0x0022)
 
#define OA_TC6_MDIOACC3_REG   OA_MMS_REG(0x0, 0x0023)
 
#define OA_TC6_MDIOACC4_REG   OA_MMS_REG(0x0, 0x0024)
 
#define OA_TC6_MDIOACC5_REG   OA_MMS_REG(0x0, 0x0025)
 
#define OA_TC6_MDIOACC6_REG   OA_MMS_REG(0x0, 0x0026)
 
#define OA_TC6_MDIOACC7_REG   OA_MMS_REG(0x0, 0x0027)
 
#define OA_TC6_CONFIG0_ZARFE_MASK   NO_OS_BIT(12)
 
#define OA_TC6_BUFSTS_TXC_MASK   NO_OS_GENMASK(15, 8)
 
#define OA_TC6_BUFSTS_RCA_MASK   NO_OS_GENMASK(7, 0)
 

Enumerations

enum  oa_tc6_user_buffer_state {
  OA_BUFF_FREE ,
  OA_BUFF_RX_IN_PROGRESS ,
  OA_BUFF_RX_COMPLETE ,
  OA_BUFF_RX_USER_OWNED ,
  OA_BUFF_TX_BUSY ,
  OA_BUFF_TX_READY
}
 State for data buffers containing Ethernet frames. More...
 

Functions

int oa_tc6_reg_read (struct oa_tc6_desc *, uint32_t, uint32_t *)
 Read a register value.
 
int oa_tc6_reg_write (struct oa_tc6_desc *, uint32_t, uint32_t)
 Write a register value.
 
int oa_tc6_reg_update (struct oa_tc6_desc *, uint32_t, uint32_t, uint32_t)
 Update a field inside a register.
 
int oa_tc6_get_rx_frame_match_vs (struct oa_tc6_desc *, struct oa_tc6_frame_buffer **, uint8_t, uint8_t)
 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 *, struct oa_tc6_frame_buffer **)
 Get a frame buffer that is ready to be read by the user.
 
int oa_tc6_put_rx_frame (struct oa_tc6_desc *, struct oa_tc6_frame_buffer *)
 Mark a frame buffer as used and ready to be rewritten.
 
int oa_tc6_get_tx_frame (struct oa_tc6_desc *, struct oa_tc6_frame_buffer **)
 Get a frame buffer that can be filled by user.
 
int oa_tc6_put_tx_frame (struct oa_tc6_desc *, struct oa_tc6_frame_buffer *)
 Mark a frame buffer as ready to be transmitted.
 
int oa_tc6_thread (struct oa_tc6_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_init (struct oa_tc6_desc **, struct oa_tc6_init_param *)
 Allocate resources for the OA TC6 driver.
 
int oa_tc6_remove (struct oa_tc6_desc *)
 Free a device descriptor.
 

Macro Definition Documentation

◆ CONFIG_OA_CHUNK_BUFFER_SIZE

#define CONFIG_OA_CHUNK_BUFFER_SIZE   1514

◆ CONFIG_OA_RX_FRAME_BUFF_NUM

#define CONFIG_OA_RX_FRAME_BUFF_NUM   5

◆ CONFIG_OA_TX_FRAME_BUFF_NUM

#define CONFIG_OA_TX_FRAME_BUFF_NUM   2

◆ OA_CHUNK_SIZE

#define OA_CHUNK_SIZE   64

◆ OA_CTRL_ADDR_MASK

#define OA_CTRL_ADDR_MASK   NO_OS_GENMASK(23, 8)

◆ OA_CTRL_ADDR_MMS_MASK

#define OA_CTRL_ADDR_MMS_MASK   NO_OS_GENMASK(27, 8)

◆ OA_CTRL_AID_MASK

#define OA_CTRL_AID_MASK   NO_OS_BIT(28)

◆ OA_CTRL_HDRB_MASK

#define OA_CTRL_HDRB_MASK   NO_OS_BIT(30)

◆ OA_CTRL_LEN_MASK

#define OA_CTRL_LEN_MASK   NO_OS_GENMASK(7, 1)

◆ OA_CTRL_MMS_MASK

#define OA_CTRL_MMS_MASK   NO_OS_GENMASK(27, 24)

◆ OA_CTRL_P_MASK

#define OA_CTRL_P_MASK   NO_OS_BIT(0)

◆ OA_CTRL_WNR_MASK

#define OA_CTRL_WNR_MASK   NO_OS_BIT(29)

◆ OA_DATA_FOOTER_DV_MASK

#define OA_DATA_FOOTER_DV_MASK   NO_OS_BIT(21)

◆ OA_DATA_FOOTER_EBO_MASK

#define OA_DATA_FOOTER_EBO_MASK   NO_OS_GENMASK(13, 8)

◆ OA_DATA_FOOTER_EV_MASK

#define OA_DATA_FOOTER_EV_MASK   NO_OS_BIT(14)

◆ OA_DATA_FOOTER_EXST_MASK

#define OA_DATA_FOOTER_EXST_MASK   NO_OS_BIT(31)

◆ OA_DATA_FOOTER_HDRB_MASK

#define OA_DATA_FOOTER_HDRB_MASK   NO_OS_BIT(30)

◆ OA_DATA_FOOTER_P_MASK

#define OA_DATA_FOOTER_P_MASK   NO_OS_BIT(0)

◆ OA_DATA_FOOTER_RCA_MASK

#define OA_DATA_FOOTER_RCA_MASK   NO_OS_GENMASK(28, 24)

◆ OA_DATA_FOOTER_SV_MASK

#define OA_DATA_FOOTER_SV_MASK   NO_OS_BIT(20)

◆ OA_DATA_FOOTER_SWO_MASK

#define OA_DATA_FOOTER_SWO_MASK   NO_OS_GENMASK(19, 16)

◆ OA_DATA_FOOTER_SYNC_MASK

#define OA_DATA_FOOTER_SYNC_MASK   NO_OS_BIT(29)

◆ OA_DATA_FOOTER_TXC_MASK

#define OA_DATA_FOOTER_TXC_MASK   NO_OS_GENMASK(5, 1)

◆ OA_DATA_FOOTER_VS_MASK

#define OA_DATA_FOOTER_VS_MASK   NO_OS_GENMASK(23, 22)

◆ OA_DATA_HEADER_DNC_MASK

#define OA_DATA_HEADER_DNC_MASK   NO_OS_BIT(31)

◆ OA_DATA_HEADER_DV_MASK

#define OA_DATA_HEADER_DV_MASK   NO_OS_BIT(21)

◆ OA_DATA_HEADER_EBO_MASK

#define OA_DATA_HEADER_EBO_MASK   NO_OS_GENMASK(13, 8)

◆ OA_DATA_HEADER_EV_MASK

#define OA_DATA_HEADER_EV_MASK   NO_OS_BIT(14)

◆ OA_DATA_HEADER_NORX_MASK

#define OA_DATA_HEADER_NORX_MASK   NO_OS_BIT(29)

◆ OA_DATA_HEADER_P_MASK

#define OA_DATA_HEADER_P_MASK   NO_OS_BIT(0)

◆ OA_DATA_HEADER_SEQ_MASK

#define OA_DATA_HEADER_SEQ_MASK   NO_OS_BIT(30)

◆ OA_DATA_HEADER_SV_MASK

#define OA_DATA_HEADER_SV_MASK   NO_OS_BIT(20)

◆ OA_DATA_HEADER_SWO_MASK

#define OA_DATA_HEADER_SWO_MASK   NO_OS_GENMASK(19, 16)

◆ OA_DATA_HEADER_VS_MASK

#define OA_DATA_HEADER_VS_MASK   NO_OS_GENMASK(23, 22)

◆ OA_FOOTER_LEN

#define OA_FOOTER_LEN   4

◆ OA_HEADER_LEN

#define OA_HEADER_LEN   4

◆ OA_MMS_REG

#define OA_MMS_REG ( m,
r )
Value:
(((m) << 16) | ((r) & NO_OS_GENMASK(15, 0)))
#define NO_OS_GENMASK(h, l)
Definition no_os_util.h:76

◆ OA_REG_LEN

#define OA_REG_LEN   4

◆ OA_RX_FRAME_BUFF_NUM

#define OA_RX_FRAME_BUFF_NUM   CONFIG_OA_RX_FRAME_BUFF_NUM

◆ OA_SPI_BUFF_LEN

#define OA_SPI_BUFF_LEN   1632

◆ OA_TC6_BUFST_REG

#define OA_TC6_BUFST_REG   OA_MMS_REG(0x0, 0x000B)

◆ OA_TC6_BUFSTS_RCA_MASK

#define OA_TC6_BUFSTS_RCA_MASK   NO_OS_GENMASK(7, 0)

◆ OA_TC6_BUFSTS_TXC_MASK

#define OA_TC6_BUFSTS_TXC_MASK   NO_OS_GENMASK(15, 8)

◆ OA_TC6_CONFIG0_REG

#define OA_TC6_CONFIG0_REG   OA_MMS_REG(0x0, 0x0004)

◆ OA_TC6_CONFIG0_ZARFE_MASK

#define OA_TC6_CONFIG0_ZARFE_MASK   NO_OS_BIT(12)

◆ OA_TC6_CONFIG1_REG

#define OA_TC6_CONFIG1_REG   OA_MMS_REG(0x0, 0x0005)

◆ OA_TC6_CONFIG2_REG

#define OA_TC6_CONFIG2_REG   OA_MMS_REG(0x0, 0x0006)

◆ OA_TC6_IDVER_REG

#define OA_TC6_IDVER_REG   OA_MMS_REG(0x0, 0x0000)

◆ OA_TC6_IMSK0_REG

#define OA_TC6_IMSK0_REG   OA_MMS_REG(0x0, 0x000C)

◆ OA_TC6_IMSK1_REG

#define OA_TC6_IMSK1_REG   OA_MMS_REG(0x0, 0x000D)

◆ OA_TC6_MDIOACC0_REG

#define OA_TC6_MDIOACC0_REG   OA_MMS_REG(0x0, 0x0020)

◆ OA_TC6_MDIOACC1_REG

#define OA_TC6_MDIOACC1_REG   OA_MMS_REG(0x0, 0x0021)

◆ OA_TC6_MDIOACC2_REG

#define OA_TC6_MDIOACC2_REG   OA_MMS_REG(0x0, 0x0022)

◆ OA_TC6_MDIOACC3_REG

#define OA_TC6_MDIOACC3_REG   OA_MMS_REG(0x0, 0x0023)

◆ OA_TC6_MDIOACC4_REG

#define OA_TC6_MDIOACC4_REG   OA_MMS_REG(0x0, 0x0024)

◆ OA_TC6_MDIOACC5_REG

#define OA_TC6_MDIOACC5_REG   OA_MMS_REG(0x0, 0x0025)

◆ OA_TC6_MDIOACC6_REG

#define OA_TC6_MDIOACC6_REG   OA_MMS_REG(0x0, 0x0026)

◆ OA_TC6_MDIOACC7_REG

#define OA_TC6_MDIOACC7_REG   OA_MMS_REG(0x0, 0x0027)

◆ OA_TC6_PHYID_REG

#define OA_TC6_PHYID_REG   OA_MMS_REG(0x0, 0x0001)

◆ OA_TC6_RESET_REG

#define OA_TC6_RESET_REG   OA_MMS_REG(0x0, 0x0003)

◆ OA_TC6_STATUS0_REG

#define OA_TC6_STATUS0_REG   OA_MMS_REG(0x0, 0x0008)

◆ OA_TC6_STATUS1_REG

#define OA_TC6_STATUS1_REG   OA_MMS_REG(0x0, 0x0009)

◆ OA_TC6_STDCAP_REG

#define OA_TC6_STDCAP_REG   OA_MMS_REG(0x0, 0x0002)

◆ OA_TC6_TTSCAH_REG

#define OA_TC6_TTSCAH_REG   OA_MMS_REG(0x0, 0x0010)

◆ OA_TC6_TTSCAL_REG

#define OA_TC6_TTSCAL_REG   OA_MMS_REG(0x0, 0x0011)

◆ OA_TC6_TTSCBH_REG

#define OA_TC6_TTSCBH_REG   OA_MMS_REG(0x0, 0x0012)

◆ OA_TC6_TTSCBL_REG

#define OA_TC6_TTSCBL_REG   OA_MMS_REG(0x0, 0x0013)

◆ OA_TC6_TTSCCH_REG

#define OA_TC6_TTSCCH_REG   OA_MMS_REG(0x0, 0x0014)

◆ OA_TC6_TTSCCL_REG

#define OA_TC6_TTSCCL_REG   OA_MMS_REG(0x0, 0x0015)

◆ OA_TX_FRAME_BUFF_NUM

#define OA_TX_FRAME_BUFF_NUM   CONFIG_OA_TX_FRAME_BUFF_NUM

Enumeration Type Documentation

◆ oa_tc6_user_buffer_state

State for data buffers containing Ethernet frames.

Enumerator
OA_BUFF_FREE 
OA_BUFF_RX_IN_PROGRESS 
OA_BUFF_RX_COMPLETE 
OA_BUFF_RX_USER_OWNED 
OA_BUFF_TX_BUSY 
OA_BUFF_TX_READY 

Function Documentation

◆ 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
Here is the caller graph for this function:

◆ 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
Here is the caller graph for this function:

◆ 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
Here is the caller graph for this function:

◆ 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
Here is the caller graph for this function:

◆ 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
Here is the caller graph for this function:

◆ oa_tc6_reg_read()

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

Read 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
Here is the caller graph for this function:

◆ 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
Here is the caller graph for this function:

◆ 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
Here is the caller graph for this function:

◆ 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
Here is the caller graph for this function:

◆ 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
Here is the caller graph for this function: