AM64x 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;
161  uint32_t numRxChannels;
162 } LLDEnetCfg_t;
163 
167 typedef struct {
171  uint8_t *buf;
175  uint32_t size;
179  int port;
184  int tc;
188  uint64_t rxts;
190 
197 
205 
211 void LLDEnetClose(LLDEnet_t *hLLDEnet);
212 
222 int LLDEnetFilter(LLDEnet_t *hLLDEnet, uint8_t *dstMacAddr,
223  uint32_t vlanId, uint32_t ethType);
224 
232 int LLDEnetAllocMac(LLDEnet_t *hLLDEnet, uint8_t *srcMacAddr);
233 
240 void LLDEnetFreeMac(LLDEnet_t *hLLDEnet, uint8_t *srcMacAddr);
241 
249 int LLDEnetSend(LLDEnet_t *hLLDEnet, LLDEnetFrame_t *frame);
250 
259 int LLDEnetSendMulti(LLDEnet_t *hLLDEnet, LLDEnetFrame_t *frames, uint32_t nFrames);
260 
271 int LLDEnetRecv(LLDEnet_t *hLLDEnet, LLDEnetFrame_t *frame);
272 
282  void (*LLDEnetRecvCb)(LLDEnetFrame_t *frame, void *cbArg), void *cbArg);
283 
291 bool LLDEnetIsPortUp(LLDEnet_t *hLLDEnet, uint8_t portNum);
292 
302 int LLDEnetGetLinkInfo(LLDEnet_t *hLLDEnet, uint8_t portNum,
303  uint32_t *speed, uint32_t *duplex);
304 
313 int LLDEnetSetTxNotifyCb(LLDEnet_t *hLLDEnet, void (*txNotifyCb)(void *arg), void *arg);
314 
323 int LLDEnetSetRxNotifyCb(LLDEnet_t *hLLDEnet, void (*rxNotifyCb)(void *arg), void *arg);
324 
336  void (*rxDefaultDataCb)(void *data, int size, int port, void *arg), void *arg);
337 
345 
346 #endif //LLDENET_H_
347 
LLDEnetCfg_t::dmaRxOwner
bool dmaRxOwner
Definition: lldenet.h:157
LLDEnetSendMulti
int LLDEnetSendMulti(LLDEnet_t *hLLDEnet, LLDEnetFrame_t *frames, uint32_t nFrames)
Sends multiple Ethernet frames using LLDEnet.
size
uint16_t size
Definition: tisci_boardcfg.h:1
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:184
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
LLDEnetFrame_t::port
int port
Definition: lldenet.h:179
LLDEnetCfg_t::nTxPkts
uint32_t nTxPkts
Definition: lldenet.h:112
LLDEnetCfg_t::instId
uint32_t instId
Definition: lldenet.h:77
LLDEnetCfg_t::dmaRxShared
bool dmaRxShared
Definition: lldenet.h:147
LLDEnetRecv
int LLDEnetRecv(LLDEnet_t *hLLDEnet, LLDEnetFrame_t *frame)
Receives an Ethernet frame using LLDEnet.
data
uint32_t data
Definition: tisci_rm_psil.h:1
LLDEnetCfg_t::unusedDmaTx
bool unusedDmaTx
Definition: lldenet.h:142
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
LLDEnetFrame_t::buf
uint8_t * buf
Definition: lldenet.h:171
MAX_NUM_RX_DMA_CH_PER_INSTANCE
#define MAX_NUM_RX_DMA_CH_PER_INSTANCE
Definition: lldtype.h:114
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
LLDEnetFrame_t
Structure representing an Ethernet frame.
Definition: lldenet.h:167
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:175
LLDEnetCfg_t::numRxChannels
uint32_t numRxChannels
Definition: lldenet.h:161
LLDEnetCfg_t::enetType
uint32_t enetType
Definition: lldenet.h:73
LLDEnetRecvZeroCopy
int LLDEnetRecvZeroCopy(LLDEnet_t *hLLDEnet, void(*LLDEnetRecvCb)(LLDEnetFrame_t *frame, void *cbArg), void *cbArg)
Receives an Ethernet frame using LLDEnet in the Zero-Copy way.
LLDEnetCfg_t::unusedDmaRx
bool unusedDmaRx
Definition: lldenet.h:137
LLDEnetCfg_t::rxCbArg
void * rxCbArg
Definition: lldenet.h:93
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:188
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.