PebbleOS v4.47.0-1312-gf1984a001
Loading...
Searching...
No Matches
ethernet.h File Reference
#include <stdbool.h>
#include <stddef.h>
#include <stdint.h>
#include <pbl/device.h>
#include <pbl/drivers/net/phy.h>
#include <pbl/kernel/mutex.h>
#include <pbl/util/bits.h>

Data Structures

struct  pbl_eth_buf
 A piece of a frame to send. More...
 
struct  pbl_eth_callbacks
 What the user does with what a controller reports. More...
 
struct  pbl_eth_ops
 Ethernet driver operations, called with the device lock held. More...
 
struct  pbl_eth
 Ethernet controller. More...
 

Macros

#define PBL_ETH_ADDR_LEN   6U
 Length of a MAC address.
 
#define PBL_ETH_HDR_LEN   14U
 Length of the Ethernet header: destination, source and EtherType.
 
#define PBL_ETH_MTU   1500U
 Largest payload of a frame.
 
#define PBL_ETH_FRAME_MAX   (PBL_ETH_HDR_LEN + PBL_ETH_MTU)
 Largest frame, without the FCS.
 
#define PBL_ETH_FILTER_PROMISC   PBL_BIT(0)
 Receive every frame, whatever its destination.
 
#define PBL_ETH_FILTER_ALLMULTI   PBL_BIT(1)
 Receive every multicast frame.
 
#define PBL_ETH_CAP_TX_CSUM   PBL_BIT(0)
 The controller inserts the checksums of IPv4 and IPv6 packets without extension headers: the IPv4 header checksum and the TCP, UDP, ICMP or ICMPv6 checksum, of frames sent with PBL_ETH_TX_CSUM.
 
#define PBL_ETH_TX_CSUM   PBL_BIT(0)
 Insert the checksums of the frame, an IPv4 or IPv6 packet as PBL_ETH_CAP_TX_CSUM says, whose checksum fields are zero.
 
#define PBL_ETH_STATE_DEFINE(sym)
 Define the runtime state of an Ethernet controller.
 
#define PBL_ETH_INIT(sym, _name, _parent, _ops, _phy, _addr)
 Initialize a struct pbl_eth.
 

Functions

void pbl_eth_set_callbacks (const struct pbl_eth *eth, const struct pbl_eth_callbacks *cb, void *arg)
 Set what is done with what the controller reports.
 
int pbl_eth_start (const struct pbl_eth *eth)
 Start a controller and its PHY.
 
int pbl_eth_stop (const struct pbl_eth *eth)
 Stop a controller and power its PHY down.
 
int pbl_eth_send (const struct pbl_eth *eth, const struct pbl_eth_buf *bufs, size_t num_bufs, uint32_t flags)
 Send a frame.
 
uint32_t pbl_eth_get_caps (const struct pbl_eth *eth)
 Get the offloads of a controller.
 
int pbl_eth_recv (const struct pbl_eth *eth, void *buf, size_t len)
 Receive a frame.
 
int pbl_eth_set_filter (const struct pbl_eth *eth, uint32_t flags, const uint8_t(*mcast)[PBL_ETH_ADDR_LEN], size_t num_mcast)
 Choose the frames to receive.
 
void pbl_eth_get_addr (const struct pbl_eth *eth, uint8_t addr[PBL_ETH_ADDR_LEN])
 Get the MAC address.
 
bool pbl_eth_link_is_up (const struct pbl_eth *eth)
 Check whether the link is up.
 
void pbl_eth_report_rx (const struct pbl_eth *eth)
 Report received frames waiting.
 
void pbl_eth_report_tx (const struct pbl_eth *eth)
 Report room to send coming back.
 

Variables

const struct pbl_eth *const ETHERNET
 The board's Ethernet controller, from its ethernet role.