AM261x MCU+ SDK: TI ENET LLD ethernet specific

| AM261x MCU+ SDK 26.00.00 |

Files | Data Structures | Functions | Typedefs | Macros
TI ENET LLD ethernet specific
APIs for combase Binding

## Introduction

## Files
file | cb_lld_ethernet.h
| TI ENET LLD specific network layer part.

## Data Structures
struct | lld_ethhdr
| Ethernet header structure. More...
struct | lld_sockaddr
| Structure representing the lld_sockaddr instance. More...
struct | lld_ethdev_t
| Structure representing the lld_ethdev instance. More...
struct | cb_socket_lldcfg_update_t
| Structure representing the cb_socket_lldcfg_update instance. More...
struct | cb_tilld_port_stats_t

## Functions
struct lld_ethhdr | __attribute__ ((packed))
int | cb_lld_init_devs_table (lld_ethdev_t *ethdevs, uint32_t ndevs, uint32_t enet_type, uint32_t instance_id, const LLDTsyncTsSource tsSource)
| Initialize a LLD device table. More...
int | cb_socket_set_lldcfg_update_cb (cb_socket_lldcfg_update_cb_t lldcfg_update_cb)
| This function sets the callback for updating LLD config parameters. It enables the user to update config parameters for the Enet LLD layer that are not supported by the CB socket. It is important to note that this function should only be called once. More...
int | cb_lld_netdev_to_macport (const char *netdev)
| Convert net device name to mac port. More...
int | cb_lld_sendto (CB_SOCKET_T sfd, void *sdata, int psize, int flags, const CB_SOCKADDR_LL_T *addr, int addrsize)
| Send a TX ethernet L2 packet. More...
int | cb_lld_sendto_scatter (CB_SOCKET_T sfd, LLDEnetFrameScatter_t *frame, const CB_SOCKADDR_LL_T *addr)
| Send a TX ethernet L2 packet in the scatter way. More...
int | cb_lld_recv (CB_SOCKET_T sfd, void *buf, int size, CB_SOCKADDR_LL_T *addr, int addrsize)
| Receive a RX ethernet L2 packet. This should be called after a rxnotify_cb is invoked. More...
int | cb_lld_recv_zerocopy (CB_SOCKET_T sfd, LLDEnetRecvCb_t cblld_recv_cb, void *cbarg)
| Receive a RX ethernet L2 packet n the zero-copy way. This should be called after a rxnotify_cb is invoked. More...
int | cb_lld_set_txnotify_cb (CB_SOCKET_T sfd, void(*txnotify_cb)(void *arg), void *arg)
| Set the TX notify callback that is invoked when an TX packet is sent successfully. More...
int | cb_lld_set_rxnotify_cb (CB_SOCKET_T sfd, void(*rxnotify_cb)(void *arg), void *arg)
| Set the RX notify callback that is invoked when an RX packet is ready to be received. More...
int | cb_lld_set_default_rxdata_cb (CB_SOCKET_T sfd, void(*default_rxdata_cb)(void *data, int size, int port, void *arg), void *arg)
| Set the default RX data callback that is invoked when an RX packet does not match any filters. More...
int | cb_lld_get_type_instance (uint32_t *enet_type, uint32_t *instance_id)
| Get enet type and instance that is set via cb_lld_init_devs_table() More...
int | cb_lld_get_ts_source (LLDTsyncTsSource *tsSource)
| Get Timestamp source that is set via cb_lld_init_devs_table() More...
int | cb_lld_get_netdevs (char *netdevs[], int *len)
| Get all virtual network interfaces which were defined for the TI platform. More...
int | cb_lld_get_link_state (CB_SOCKET_T cfd, const char *dev, uint32_t *linkstate)
| get link state from device name like 'eth0' More...
int | cb_lld_get_link_info (CB_SOCKET_T cfd, const char *dev, uint32_t *speed, uint32_t *duplex)
| get link info(speed and duplex) from device name like 'eth0' More...
int | cb_lld_get_port_stats (CB_SOCKET_T sfd, int port, cb_tilld_port_stats_t *stats)
| Get stats info from host or mac port. More...
void | cb_lld_reset_port_stats (CB_SOCKET_T sfd, int port)
| reset stats info from host or mac port. More...
int | cb_lld_process_status_frames (CB_SOCKET_T sfd)
| process the Phy status frames. More...
void | cb_lld_notify_linkchange (void)
| Nofity link change event through cbl_query_thread_data_t signal. More...

## Typedefs
typedef struct lld_socket | lld_socket_t
| Structure representing the lld_socket instance. More...
typedef int(* | cb_socket_lldcfg_update_cb_t) (cb_socket_lldcfg_update_t *update_cfg)
| Callback function type for cb_socket_lldcfg_update. More...

## Macros
#define | LWIP_DONT_PROVIDE_BYTEORDER_FUNCTIONS
#define | htons __htons
#define | ntohs __ntohs
#define | htonl __htonl
#define | ntohl __ntohl
#define | MAX_NUMBER_ENET_DEVS LLDENET_MAX_PORTS
#define | CB_SOCKET_VALID(x) ((x)!=NULL)
#define | CB_SOCKET_INVALID_VALUE NULL
#define | CB_SOCKET_T lld_socket_t*
#define | CB_ETHHDR_T struct lld_ethhdr
#define | CB_SOCKADDR_LL_T struct lld_sockaddr
#define | CB_SOCKADDR_T struct lld_sockaddr
#define | CB_SOCK_SENDTO cb_lld_sendto
#define | CB_SOCK_CLOSE cb_rawsock_close
#define | CB_OPEN open
#define | CB_CLOSE close
#define | CB_WRITE write
#define | CB_IN_ADDR_T void*
#define | IFNAMSIZ 16
#define | ETH_ALEN 6 /* Octets in one ethernet addr */
#define | ETH_HLEN 14 /* Total octets in header. */
#define | ETH_DATA_LEN 1500 /* Max. octets in payload */
#define | ETH_P_8021Q 0x8100 /* 802.1Q VLAN Extended Header */
#define | ETH_P_1588 0x88F7 /* IEEE 1588 Timesync */
#define | ETH_P_LLDP 0x88CC /* 802.1AB LLDP */
#define | ETH_P_TSN 0x22F0 /* TSN (IEEE 1722) packet */
#define | ETH_P_NETLINK 0x22F1 /* A virtual prototol for netlink rawsockt on TI platforms */
#define | CB_MAX_NETDEVNAME 16
#define | MKPIPE(x) (-1)
#define | CB_LLD_MAX_ETH_FRAME_SIZE (1522U)
#define | CB_TILLD_STATS_BLOCK_ELEM_NUM (128U)

## Macro Definition Documentation

## ◆ LWIP_DONT_PROVIDE_BYTEORDER_FUNCTIONS

#define LWIP_DONT_PROVIDE_BYTEORDER_FUNCTIONS

## ◆ htons

#define htons __htons

## ◆ ntohs

#define ntohs __ntohs

## ◆ htonl

#define htonl __htonl

## ◆ ntohl

#define ntohl __ntohl

## ◆ MAX_NUMBER_ENET_DEVS

#define MAX_NUMBER_ENET_DEVS LLDENET_MAX_PORTS

## ◆ CB_SOCKET_VALID

#define CB_SOCKET_VALID | ( |  | x | ) | ((x)!=NULL)

## ◆ CB_SOCKET_INVALID_VALUE

#define CB_SOCKET_INVALID_VALUE NULL

## ◆ CB_SOCKET_T

#define CB_SOCKET_T lld_socket_t*

## ◆ CB_ETHHDR_T

#define CB_ETHHDR_T struct lld_ethhdr

## ◆ CB_SOCKADDR_LL_T

#define CB_SOCKADDR_LL_T struct lld_sockaddr

## ◆ CB_SOCKADDR_T

#define CB_SOCKADDR_T struct lld_sockaddr

## ◆ CB_SOCK_SENDTO

#define CB_SOCK_SENDTO cb_lld_sendto

## ◆ CB_SOCK_CLOSE

#define CB_SOCK_CLOSE cb_rawsock_close

## ◆ CB_OPEN

#define CB_OPEN open

## ◆ CB_CLOSE

#define CB_CLOSE close

## ◆ CB_WRITE

#define CB_WRITE write

## ◆ CB_IN_ADDR_T

#define CB_IN_ADDR_T void*

## ◆ IFNAMSIZ

#define IFNAMSIZ 16

## ◆ ETH_ALEN

#define ETH_ALEN 6 /* Octets in one ethernet addr */

## ◆ ETH_HLEN

#define ETH_HLEN 14 /* Total octets in header. */

## ◆ ETH_DATA_LEN

#define ETH_DATA_LEN 1500 /* Max. octets in payload */

## ◆ ETH_P_8021Q

#define ETH_P_8021Q 0x8100 /* 802.1Q VLAN Extended Header */

## ◆ ETH_P_1588

#define ETH_P_1588 0x88F7 /* IEEE 1588 Timesync */

## ◆ ETH_P_LLDP

#define ETH_P_LLDP 0x88CC /* 802.1AB LLDP */

## ◆ ETH_P_TSN

#define ETH_P_TSN 0x22F0 /* TSN (IEEE 1722) packet */

## ◆ ETH_P_NETLINK

#define ETH_P_NETLINK 0x22F1 /* A virtual prototol for netlink rawsockt on TI platforms */

## ◆ CB_MAX_NETDEVNAME

#define CB_MAX_NETDEVNAME 16

## ◆ MKPIPE

#define MKPIPE | ( |  | x | ) | (-1)

## ◆ CB_LLD_MAX_ETH_FRAME_SIZE

#define CB_LLD_MAX_ETH_FRAME_SIZE (1522U)

## ◆ CB_TILLD_STATS_BLOCK_ELEM_NUM

#define CB_TILLD_STATS_BLOCK_ELEM_NUM (128U)

## Typedef Documentation

## ◆ lld_socket_t

typedef struct lld_socket lld_socket_t

Structure representing the lld_socket instance.

## ◆ cb_socket_lldcfg_update_cb_t

cb_socket_lldcfg_update_cb_t

Callback function type for cb_socket_lldcfg_update.

Parameters

  update_cfg | Pointer to the cb_socket_lldcfg_update instance.

Returns
  Integer value indicating the result of the callback. 0: OK, <0: error

## Function Documentation

## ◆ __attribute__()

struct lld_ethhdr __attribute__ | ( | (packed) |  | ) |

## ◆ cb_lld_init_devs_table()

int cb_lld_init_devs_table | ( | lld_ethdev_t * | ethdevs,
|  | uint32_t | ndevs,
|  | uint32_t | enet_type,
|  | uint32_t | instance_id,
|  | const LLDTsyncTsSource | tsSource
| ) |  |

Initialize a LLD device table.

This function should only be called once, before calling any net functions from the combase. It is recommended to call once in the main() application, not in any TSN module source. If the ethdevs[i].srcmac is all zero, the srcmac will be alloced dynamically by the the LLD layer. Please note that ethdevs[i].netdev must point to a global memory address, not a stack memory address.

Parameters

  ethdevs | an arrays of ethernet devices
  ndevs | number of devices in the array
  enet_type | LLD ethernet type
  instance_id | LLD ethernet instance ID
  tsSource | LLDTsync timestamp source

Returns
  0: OK, <0: error, detailed error will be printed out.

## ◆ cb_socket_set_lldcfg_update_cb()

int cb_socket_set_lldcfg_update_cb | ( | cb_socket_lldcfg_update_cb_t | lldcfg_update_cb | ) |

This function sets the callback for updating LLD config parameters. It enables the user to update config parameters for the Enet LLD layer that are not supported by the CB socket. It is important to note that this function should only be called once.

Parameters

  lldcfg_update_cb | update callback

Returns
  0: OK, <0: error, detailed error will be printed out.

## ◆ cb_lld_netdev_to_macport()

int cb_lld_netdev_to_macport | ( | const char * | netdev | ) |

Convert net device name to mac port.

Parameters

  netdev | net device name e.g. eth0

Returns
  >=0: MAC port, <0: error, detailed error will be printed out.

## ◆ cb_lld_sendto()

int cb_lld_sendto | ( | CB_SOCKET_T | sfd,
|  | void * | sdata,
|  | int | psize,
|  | int | flags,
|  | const CB_SOCKADDR_LL_T * | addr,
|  | int | addrsize
| ) |  |

Send a TX ethernet L2 packet.

Parameters

  sfd | socket fd
  sdata | ethernet L2 packet
  psize | packet size
  flags | it is unused now, keep it to make it compatible with POSIX sendto
  addr | destination address info
  addrsize | address size

Returns
  number of sent bytes if OK, <0: error, detailed error will be printed out.

## ◆ cb_lld_sendto_scatter()

int cb_lld_sendto_scatter | ( | CB_SOCKET_T | sfd,
|  | LLDEnetFrameScatter_t * | frame,
|  | const CB_SOCKADDR_LL_T * | addr
| ) |  |

Send a TX ethernet L2 packet in the scatter way.

Parameters

  sfd | socket fd
  frame | ethernet L2 packet in the scatter way
  addr | destination address info

Returns
  number of sent bytes if OK, <0: error, detailed error will be printed out.

## ◆ cb_lld_recv()

int cb_lld_recv | ( | CB_SOCKET_T | sfd,
|  | void * | buf,
|  | int | size,
|  | CB_SOCKADDR_LL_T * | addr,
|  | int | addrsize
| ) |  |

Receive a RX ethernet L2 packet. This should be called after a rxnotify_cb is invoked.

Parameters

  sfd | socket fd
  buf | packet buffer
  size | buffer size
  addr | index of received port and packets info
  addrsize | size of the addr structure.

Returns
  <0: error; 0: No data available; 0xFFFF: Unmatched data filter; >0: data len

## ◆ cb_lld_recv_zerocopy()

int cb_lld_recv_zerocopy | ( | CB_SOCKET_T | sfd,
|  | LLDEnetRecvCb_t | cblld_recv_cb,
|  | void * | cbarg
| ) |  |

Receive a RX ethernet L2 packet n the zero-copy way. This should be called after a rxnotify_cb is invoked.

Parameters

  sfd | socket fd
  cblld_recv_cb | the receive callback
  cbarg | the callback argument

Returns
  <0: error; 0: No data available; 0xFFFF: Unmatched data filter; 1: received data

## ◆ cb_lld_set_txnotify_cb()

int cb_lld_set_txnotify_cb | ( | CB_SOCKET_T | sfd,
|  | void(*)(void *arg) | txnotify_cb,
|  | void * | arg
| ) |  |

Set the TX notify callback that is invoked when an TX packet is sent successfully.

Parameters

  sfd | socket fd
  txnotify_cb | callback
  arg | callback argument

Returns
  0: OK, <0: error, detailed error will be printed out

## ◆ cb_lld_set_rxnotify_cb()

int cb_lld_set_rxnotify_cb | ( | CB_SOCKET_T | sfd,
|  | void(*)(void *arg) | rxnotify_cb,
|  | void * | arg
| ) |  |

Set the RX notify callback that is invoked when an RX packet is ready to be received.

Parameters

  sfd | socket fd
  rxnotify_cb | callback
  arg | callback argument

Returns
  0: OK, <0: error, detailed error will be printed out

## ◆ cb_lld_set_default_rxdata_cb()

int cb_lld_set_default_rxdata_cb | ( | CB_SOCKET_T | sfd,
|  | void(*)(void *data, int size, int port, void *arg) | default_rxdata_cb,
|  | void * | arg
| ) |  |

Set the default RX data callback that is invoked when an RX packet does not match any filters.

Parameters

  sfd | socket fd
  default_rxdata_cb | callback
  arg | callback argument

Returns
  0: OK, <0: error, detailed error will be printed out

## ◆ cb_lld_get_type_instance()

int cb_lld_get_type_instance | ( | uint32_t * | enet_type,
|  | uint32_t * | instance_id
| ) |  |

Get enet type and instance that is set via cb_lld_init_devs_table()

Parameters

  enet_type | ethernet type
  instance_id | ethernet instance ID

Returns
  0: OK, <0: error, detailed error will be printed out

## ◆ cb_lld_get_ts_source()

int cb_lld_get_ts_source | ( | LLDTsyncTsSource * | tsSource | ) |

Get Timestamp source that is set via cb_lld_init_devs_table()

Parameters

  tsSource | Pointer to the tsSource

Returns
  0: OK, <0: error, detailed error will be printed out

## ◆ cb_lld_get_netdevs()

int cb_lld_get_netdevs | ( | char * | netdevs[],
|  | int * | len
| ) |  |

Get all virtual network interfaces which were defined for the TI platform.

Parameters

  netdevs | an array of pointer points to the net devices acquired by this api.
  len | how many net devices are returned by this api.

Returns
  0 on success; -1 on failure

## ◆ cb_lld_get_link_state()

int cb_lld_get_link_state | ( | CB_SOCKET_T | cfd,
|  | const char * | dev,
|  | uint32_t * | linkstate
| ) |  |

get link state from device name like 'eth0'

Parameters

  cfd | a socket handle coressponding to the ethernet device name specified via the second argument `dev`
  dev | ethernet device name like 'eth0'
  linkstate | a pointer for storing link state value (0:down, 1:up)

Returns
  0 on success, -1 on error

## ◆ cb_lld_get_link_info()

int cb_lld_get_link_info | ( | CB_SOCKET_T | cfd,
|  | const char * | dev,
|  | uint32_t * | speed,
|  | uint32_t * | duplex
| ) |  |

get link info(speed and duplex) from device name like 'eth0'

Parameters

  cfd | a socket handle coressponding to the ethernet device name specified via the second argument `dev`
  dev | ethenert device name like 'eth0'
  speed | a pointer for storing speed value (0:unknow, 10:10Mbps, 100:100Mbps, 1000:1Gbps)
  duplex | a pointer for storing duplex value (0:unknow, 1:Full, 2:Half)

Returns
  0 on success, -1 on error

## ◆ cb_lld_get_port_stats()

int cb_lld_get_port_stats | ( | CB_SOCKET_T | sfd,
|  | int | port,
|  | cb_tilld_port_stats_t * | stats
| ) |  |

Get stats info from host or mac port.

Parameters

  sfd | socket fd
  port | 0xFF: host port; less than 0xFF: mac port.
  stats | a pointer to cb_tilld_port_stats_t object

Note
  valid index of mac port depends on HW platform

Returns
  0 on success, -1 on failure

## ◆ cb_lld_reset_port_stats()

void cb_lld_reset_port_stats | ( | CB_SOCKET_T | sfd,
|  | int | port
| ) |  |

reset stats info from host or mac port.

Parameters

  sfd | socket fd
  port | 0xFF: host port; less than: mac port.

Note
  valid index of mac port depends on HW platform

## ◆ cb_lld_process_status_frames()

int cb_lld_process_status_frames | ( | CB_SOCKET_T | sfd | ) |

process the Phy status frames.

Parameters

  sfd | socket fd

Returns
  number of status frames processed.

## ◆ cb_lld_notify_linkchange()

void cb_lld_notify_linkchange | ( | void |  | ) |

Nofity link change event through cbl_query_thread_data_t signal.

## Variable Documentation

## ◆ __attribute__

__attribute__

This is the SecureBoot Stream type which holds the data for a specific bootloader to HSM call. This packet is needed by HSM the to do the required operation.

HSM client / server message format struct.