AM263x MCU+ SDK  10.00.00
lldenet.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2023 Texas Instruments Incorporated
3  * Copyright (c) 2023 Excelfore Corporation (https://excelfore.com)
4  *
5  * All rights reserved not granted herein.
6  * Limited License.
7  *
8  * Texas Instruments Incorporated grants a world-wide, royalty-free,
9  * non-exclusive license under copyrights and patents it now or hereafter
10  * owns or controls to make, have made, use, import, offer to sell and sell ("Utilize")
11  * this software subject to the terms herein. With respect to the foregoing patent
12  * license, such license is granted solely to the extent that any such patent is necessary
13  * to Utilize the software alone. The patent license shall not apply to any combinations which
14  * include this software, other than combinations with devices manufactured by or for TI ("TI Devices").
15  * No hardware patent is licensed hereunder.
16  *
17  * Redistributions must preserve existing copyright notices and reproduce this license (including the
18  * above copyright notice and the disclaimer and (if applicable) source code license limitations below)
19  * in the documentation and/or other materials provided with the distribution
20  *
21  * Redistribution and use in binary form, without modification, are permitted provided that the following
22  * conditions are met:
23  *
24  * * No reverse engineering, decompilation, or disassembly of this software is permitted with respect to any
25  * software provided in binary form.
26  * * any redistribution and use are licensed by TI for use only with TI Devices.
27  * * Nothing shall obligate TI to provide you with source code for the software licensed and provided to you in object code.
28  *
29  * If software source code is provided to you, modification and redistribution of the source code are permitted
30  * provided that the following conditions are met:
31  *
32  * * any redistribution and use of the source code, including any resulting derivative works, are licensed by
33  * TI for use only with TI Devices.
34  * * any redistribution and use of any object code compiled from the source code and any resulting derivative
35  * works, are licensed by TI for use only with TI Devices.
36  *
37  * Neither the name of Texas Instruments Incorporated nor the names of its suppliers may be used to endorse or
38  * promote products derived from this software without specific prior written permission.
39  *
40  * DISCLAIMER.
41  *
42  * THIS SOFTWARE IS PROVIDED BY TI AND TI"S LICENSORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING,
43  * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
44  * IN NO EVENT SHALL TI AND TI"S LICENSORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
45  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
46  * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
47  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
48  * POSSIBILITY OF SUCH DAMAGE.
49 */
56 #ifndef LLDENET_H_
57 #define LLDENET_H_
58 
59 #include "lldtype.h"
60 
64 typedef struct LLDEnet LLDEnet_t;
65 
69 typedef struct {
73  uint32_t enetType;
77  uint32_t instId;
81  void (*txNotifyCb)(void *cbArg);
85  void (*rxNotifyCb)(void *cbArg);
89  void *txCbArg;
93  void *rxCbArg;
98  uint8_t dstMacAddr[6];
103  uint32_t vlanId;
107  uint32_t ethType;
112  uint32_t nTxPkts;
122  uint32_t pktSize;
165  uint32_t numRxChannels;
166 } LLDEnetCfg_t;
167 
171 typedef struct {
175  uint8_t *buf;
179  uint32_t size;
183  int port;
188  int tc;
192  uint64_t rxts;
194 
198 #define MAX_BUF_IN_SCATTER_FRAME 32
199 
203 typedef struct {
211  uint16_t size[MAX_BUF_IN_SCATTER_FRAME];
215  uint8_t nBufs;
219  int8_t port;
224  int8_t tc;
228  uint64_t rxts;
230 
237 
245 
251 void LLDEnetClose(LLDEnet_t *hLLDEnet);
252 
262 int LLDEnetFilter(LLDEnet_t *hLLDEnet, uint8_t *dstMacAddr,
263  uint32_t vlanId, uint32_t ethType);
264 
272 int LLDEnetAllocMac(LLDEnet_t *hLLDEnet, uint8_t *srcMacAddr);
273 
280 void LLDEnetFreeMac(LLDEnet_t *hLLDEnet, uint8_t *srcMacAddr);
281 
289 int LLDEnetSend(LLDEnet_t *hLLDEnet, LLDEnetFrame_t *frame);
290 
299 int LLDEnetSendMulti(LLDEnet_t *hLLDEnet, LLDEnetFrame_t *frames, uint32_t nFrames);
300 
308 
317  uint32_t nFrames);
318 
329 int LLDEnetRecv(LLDEnet_t *hLLDEnet, LLDEnetFrame_t *frame);
330 
337 typedef void (*LLDEnetRecvCb_t)(LLDEnetFrame_t *frame, void *cbArg);
338 
347 int LLDEnetRecvZeroCopy(LLDEnet_t *hLLDEnet, LLDEnetRecvCb_t LLDEnetRecvCb, void *cbArg);
348 
356 bool LLDEnetIsPortUp(LLDEnet_t *hLLDEnet, uint8_t portNum);
357 
367 int LLDEnetGetLinkInfo(LLDEnet_t *hLLDEnet, uint8_t portNum,
368  uint32_t *speed, uint32_t *duplex);
369 
378 int LLDEnetSetTxNotifyCb(LLDEnet_t *hLLDEnet, void (*txNotifyCb)(void *arg), void *arg);
379 
388 int LLDEnetSetRxNotifyCb(LLDEnet_t *hLLDEnet, void (*rxNotifyCb)(void *arg), void *arg);
389 
401  void (*rxDefaultDataCb)(void *data, int size, int port, void *arg), void *arg);
402 
410 
411 #endif //LLDENET_H_
412 
LLDEnetCfg_t::dmaRxOwner
bool dmaRxOwner
Definition: lldenet.h:161
LLDEnetSendMulti
int LLDEnetSendMulti(LLDEnet_t *hLLDEnet, LLDEnetFrame_t *frames, uint32_t nFrames)
Sends multiple Ethernet frames using LLDEnet.
LLDEnetFilter
int LLDEnetFilter(LLDEnet_t *hLLDEnet, uint8_t *dstMacAddr, uint32_t vlanId, uint32_t ethType)
Filter RX packets by using the destination MAC address and VLAN ID.
LLDEnetSetDefaultRxDataCb
int LLDEnetSetDefaultRxDataCb(LLDEnet_t *hLLDEnet, void(*rxDefaultDataCb)(void *data, int size, int port, void *arg), void *arg)
Sets the receive data callback function for LLDEnet when filter does not match. This callback is supp...
LLDEnetFrame_t::tc
int tc
Definition: lldenet.h:188
LLDEnetSetRxNotifyCb
int LLDEnetSetRxNotifyCb(LLDEnet_t *hLLDEnet, void(*rxNotifyCb)(void *arg), void *arg)
Sets the receive notification callback function for LLDEnet.
LLDEnetCfg_t::vlanId
uint32_t vlanId
Definition: lldenet.h:103
MAX_BUF_IN_SCATTER_FRAME
#define MAX_BUF_IN_SCATTER_FRAME
Maximum number of buffers in a scatter frame.
Definition: lldenet.h:198
LLDEnetFrame_t::port
int port
Definition: lldenet.h:183
LLDEnetCfg_t::nTxPkts
uint32_t nTxPkts
Definition: lldenet.h:112
LLDEnetRecvCb_t
void(* LLDEnetRecvCb_t)(LLDEnetFrame_t *frame, void *cbArg)
Receives callback an Ethernet frame using LLDEnet in the Zero-Copy way.
Definition: lldenet.h:337
LLDEnetCfg_t::instId
uint32_t instId
Definition: lldenet.h:77
LLDEnetCfg_t::dmaRxShared
bool dmaRxShared
Definition: lldenet.h:152
LLDEnetRecv
int LLDEnetRecv(LLDEnet_t *hLLDEnet, LLDEnetFrame_t *frame)
Receives an Ethernet frame using LLDEnet.
LLDEnetCfg_t::unusedDmaTx
bool unusedDmaTx
Definition: lldenet.h:142
LLDEnetFrameScatter_t::nBufs
uint8_t nBufs
Definition: lldenet.h:215
LLDEnetSend
int LLDEnetSend(LLDEnet_t *hLLDEnet, LLDEnetFrame_t *frame)
Sends an Ethernet frame using LLDEnet.
lldtype.h
Data types and macros for TI Enet LLD abstract APIs.
LLDEnetCfg_t
Configuration structure for LLDEnet.
Definition: lldenet.h:69
LLDEnetSendScatter
int LLDEnetSendScatter(LLDEnet_t *hLLDEnet, LLDEnetFrameScatter_t *frame)
Sends an ethernet frame of scatter buffers.
LLDEnetFrame_t::buf
uint8_t * buf
Definition: lldenet.h:175
MAX_NUM_RX_DMA_CH_PER_INSTANCE
#define MAX_NUM_RX_DMA_CH_PER_INSTANCE
Definition: lldtype.h:114
LLDEnetFrameScatter_t
Structure representing an Ethernet frame.
Definition: lldenet.h:203
LLDEnetIsRxTsInPkt
bool LLDEnetIsRxTsInPkt(LLDEnet_t *hLLDEnet)
Checks the receive packet timestamping mode.
LLDEnetCfg_t::ethType
uint32_t ethType
Definition: lldenet.h:107
LLDEnetIsPortUp
bool LLDEnetIsPortUp(LLDEnet_t *hLLDEnet, uint8_t portNum)
Checks if the specified port is up.
LLDEnetCfgInit
void LLDEnetCfgInit(LLDEnetCfg_t *cfg)
Initializes the LLDEnetCfg_t structure.
LLDEnetGetLinkInfo
int LLDEnetGetLinkInfo(LLDEnet_t *hLLDEnet, uint8_t portNum, uint32_t *speed, uint32_t *duplex)
Retrieves the link speed and duplex information for the specified port.
LLDEnetCfg_t::txCbArg
void * txCbArg
Definition: lldenet.h:89
LLDEnetCfg_t::pktSize
uint32_t pktSize
Definition: lldenet.h:122
LLDEnetRecvZeroCopy
int LLDEnetRecvZeroCopy(LLDEnet_t *hLLDEnet, LLDEnetRecvCb_t LLDEnetRecvCb, void *cbArg)
Receives an Ethernet frame using LLDEnet in the Zero-Copy way.
LLDEnetFrame_t
Structure representing an Ethernet frame.
Definition: lldenet.h:171
LLDEnetCfg_t::dmaTxShared
bool dmaTxShared
Definition: lldenet.h:147
LLDEnetCfg_t::dmaTxChId
int dmaTxChId
Definition: lldenet.h:127
LLDEnetFreeMac
void LLDEnetFreeMac(LLDEnet_t *hLLDEnet, uint8_t *srcMacAddr)
Frees a previously allocated MAC address.
LLDEnetAllocMac
int LLDEnetAllocMac(LLDEnet_t *hLLDEnet, uint8_t *srcMacAddr)
Allocates a source MAC address.
LLDEnetFrame_t::size
uint32_t size
Definition: lldenet.h:179
LLDEnetCfg_t::numRxChannels
uint32_t numRxChannels
Definition: lldenet.h:165
LLDEnetCfg_t::enetType
uint32_t enetType
Definition: lldenet.h:73
LLDEnetCfg_t::unusedDmaRx
bool unusedDmaRx
Definition: lldenet.h:137
LLDEnetCfg_t::rxCbArg
void * rxCbArg
Definition: lldenet.h:93
LLDEnetFrameScatter_t::port
int8_t port
Definition: lldenet.h:219
LLDEnetSendMultiScatter
int LLDEnetSendMultiScatter(LLDEnet_t *hLLDEnet, LLDEnetFrameScatter_t *frames, uint32_t nFrames)
Sends multiples ethernet frames of scatter buffers.
LLDEnet_t
struct LLDEnet LLDEnet_t
Structure representing the LLDEnet instance.
Definition: lldenet.h:64
LLDEnetClose
void LLDEnetClose(LLDEnet_t *hLLDEnet)
Closes an instance of LLDEnet.
LLDEnetFrame_t::rxts
uint64_t rxts
Definition: lldenet.h:192
LLDEnetOpen
LLDEnet_t * LLDEnetOpen(LLDEnetCfg_t *cfg)
Opens an instance of LLDEnet.
LLDEnetSetTxNotifyCb
int LLDEnetSetTxNotifyCb(LLDEnet_t *hLLDEnet, void(*txNotifyCb)(void *arg), void *arg)
Sets the transmit notification callback function for LLDEnet.
LLDEnetFrameScatter_t::rxts
uint64_t rxts
Definition: lldenet.h:228
LLDEnetFrameScatter_t::tc
int8_t tc
Definition: lldenet.h:224