Zephyr API Documentation 4.0.0
A Scalable Open Source RTOS
Loading...
Searching...
No Matches
Distributed Switch Architecture definitions and helpers

DSA definitions and helpers . More...

Data Structures

struct  dsa_slave_config
 Structure to provide mac address for each LAN interface. More...
 

Typedefs

typedef enum net_verdict(* dsa_net_recv_cb_t) (struct net_if *iface, struct net_pkt *pkt)
 DSA (MGMT) Receive packet callback.
 
typedef int(* dsa_send_t) (const struct device *dev, struct net_pkt *pkt)
 Pointer to master interface send function.
 

Functions

int dsa_tx (const struct device *dev, struct net_pkt *pkt)
 DSA generic transmit function.
 
int dsa_register_recv_callback (struct net_if *iface, dsa_net_recv_cb_t cb)
 Register DSA Rx callback functions.
 
struct net_ifdsa_net_recv (struct net_if *iface, struct net_pkt **pkt)
 Set DSA interface to packet.
 
int dsa_register_master_tx (struct net_if *iface, dsa_send_t fn)
 DSA helper function to register transmit function for master.
 
bool dsa_is_port_master (struct net_if *iface)
 DSA helper function to check if port is master.
 
struct net_ifdsa_get_slave_port (struct net_if *iface, int slave_num)
 Get network interface of a slave port.
 
int dsa_switch_read (struct net_if *iface, uint16_t reg_addr, uint8_t *value)
 Read from DSA switch register.
 
int dsa_switch_write (struct net_if *iface, uint16_t reg_addr, uint8_t value)
 Write to DSA switch.
 
int dsa_switch_set_mac_table_entry (struct net_if *iface, const uint8_t *mac, uint8_t fw_port, uint16_t tbl_entry_idx, uint16_t flags)
 Write static MAC table entry.
 
int dsa_switch_get_mac_table_entry (struct net_if *iface, uint8_t *buf, uint16_t tbl_entry_idx)
 Read static MAC table entry.
 

Detailed Description

DSA definitions and helpers .

Since
2.5
Version
0.8.0

Typedef Documentation

◆ dsa_net_recv_cb_t

typedef enum net_verdict(* dsa_net_recv_cb_t) (struct net_if *iface, struct net_pkt *pkt)

#include <zephyr/net/dsa.h>

DSA (MGMT) Receive packet callback.

Callback gets called upon receiving packet. It is responsible for freeing packet or indicating to the stack that it needs to free packet by returning correct net_verdict.

Returns:

  • NET_DROP, if packet was invalid, rejected or we want the stack to free it. In this case the core stack will free the packet.
  • NET_OK, if the packet was accepted, in this case the ownership of the net_pkt goes to callback and core network stack will forget it.

◆ dsa_send_t

typedef int(* dsa_send_t) (const struct device *dev, struct net_pkt *pkt)

#include <zephyr/net/dsa.h>

Pointer to master interface send function.

Function Documentation

◆ dsa_get_slave_port()

struct net_if * dsa_get_slave_port ( struct net_if * iface,
int slave_num )

#include <zephyr/net/dsa.h>

Get network interface of a slave port.

Parameters
ifaceMaster port
[in]slave_numSlave port number
Returns
network interface of the slave if successful
NULL if slave port does not exist

◆ dsa_is_port_master()

bool dsa_is_port_master ( struct net_if * iface)

#include <zephyr/net/dsa.h>

DSA helper function to check if port is master.

Parameters
ifaceNetwork interface (master)

Returns:

  • true if ok, false otherwise

◆ dsa_net_recv()

struct net_if * dsa_net_recv ( struct net_if * iface,
struct net_pkt ** pkt )

#include <zephyr/net/dsa.h>

Set DSA interface to packet.

Parameters
ifaceNetwork interface (master)
pktNetwork packet
Returns
Return the slave network interface

◆ dsa_register_master_tx()

int dsa_register_master_tx ( struct net_if * iface,
dsa_send_t fn )

#include <zephyr/net/dsa.h>

DSA helper function to register transmit function for master.

Parameters
ifaceNetwork interface (master)
fnPointer to master interface send method

Returns:

  • 0 if ok, < 0 if error

◆ dsa_register_recv_callback()

int dsa_register_recv_callback ( struct net_if * iface,
dsa_net_recv_cb_t cb )

#include <zephyr/net/dsa.h>

Register DSA Rx callback functions.

Parameters
ifaceNetwork interface
cbReceive callback function
Returns
0 if ok, < 0 if error

◆ dsa_switch_get_mac_table_entry()

int dsa_switch_get_mac_table_entry ( struct net_if * iface,
uint8_t * buf,
uint16_t tbl_entry_idx )

#include <zephyr/net/dsa.h>

Read static MAC table entry.

Parameters
ifaceMaster DSA interface
bufBuffer to receive MAC address
[in]tbl_entry_idxTable entry index
Returns
0 if successful, negative if error

◆ dsa_switch_read()

int dsa_switch_read ( struct net_if * iface,
uint16_t reg_addr,
uint8_t * value )

#include <zephyr/net/dsa.h>

Read from DSA switch register.

Parameters
ifaceThe interface
[in]reg_addrThe register address
valueThe value
Returns
0 if successful, negative if error

◆ dsa_switch_set_mac_table_entry()

int dsa_switch_set_mac_table_entry ( struct net_if * iface,
const uint8_t * mac,
uint8_t fw_port,
uint16_t tbl_entry_idx,
uint16_t flags )

#include <zephyr/net/dsa.h>

Write static MAC table entry.

Parameters
ifaceMaster DSA interface
[in]macMAC address
[in]fw_portThe firmware port
[in]tbl_entry_idxTable entry index
[in]flagsFlags
Returns
0 if successful, negative if error

◆ dsa_switch_write()

int dsa_switch_write ( struct net_if * iface,
uint16_t reg_addr,
uint8_t value )

#include <zephyr/net/dsa.h>

Write to DSA switch.

Parameters
ifaceThe interface
[in]reg_addrThe register address
[in]valueThe value
Returns
{ description_of_the_return_value }

◆ dsa_tx()

int dsa_tx ( const struct device * dev,
struct net_pkt * pkt )

#include <zephyr/net/dsa.h>

DSA generic transmit function.

This is a generic function for passing packets from slave DSA interface to master.

Parameters
devDevice
pktNetwork packet

Returns:

  • 0 if ok (packet sent via master iface), < 0 if error