AM243x MCU+ SDK  09.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;
104 
109  uint32_t nTxPkts;
114  uint32_t nRxPkts;
119  uint32_t pktSize;
130 
134  bool unusedDma;
135 } LLDEnetCfg_t;
136 
140 typedef struct {
144  uint8_t *buf;
148  uint32_t size;
152  int port;
157  int tc;
159 
166 
174 
180 void LLDEnetClose(LLDEnet_t *hLLDEnet);
181 
190 int LLDEnetFilter(LLDEnet_t *hLLDEnet, uint8_t *dstMacAddr, uint32_t vlanId);
191 
199 int LLDEnetAllocMac(LLDEnet_t *hLLDEnet, uint8_t *srcMacAddr);
200 
207 void LLDEnetFreeMac(LLDEnet_t *hLLDEnet, uint8_t *srcMacAddr);
208 
216 int LLDEnetSend(LLDEnet_t *hLLDEnet, LLDEnetFrame_t *frame);
217 
226 int LLDEnetSendMulti(LLDEnet_t *hLLDEnet, LLDEnetFrame_t *frames, uint32_t nFrames);
227 
235 int LLDEnetRecv(LLDEnet_t *hLLDEnet, LLDEnetFrame_t *frame);
236 
244 bool LLDEnetIsPortUp(LLDEnet_t *hLLDEnet, uint8_t portNum);
245 
255 int LLDEnetGetLinkInfo(LLDEnet_t *hLLDEnet, uint8_t portNum,
256  uint32_t *speed, uint32_t *duplex);
257 
266 int LLDEnetSetTxNotifyCb(LLDEnet_t *hLLDEnet, void (*txNotifyCb)(void *arg), void *arg);
267 
276 int LLDEnetSetRxNotifyCb(LLDEnet_t *hLLDEnet, void (*rxNotifyCb)(void *arg), void *arg);
277 
287 int LLDEnetTasSetConfig(LLDEnet_t *hLLDEnet, uint8_t macPort, void *arg);
288 
300 int LLDEnetIETSetConfig(LLDEnet_t *hLLDEnet, uint8_t macPort, void *reqPrm, void *resPrm);
301 #endif //LLDENET_H_
302 
LLDEnetCfg_t::nRxPkts
uint32_t nRxPkts
Definition: lldenet.h:114
LLDEnetSendMulti
int LLDEnetSendMulti(LLDEnet_t *hLLDEnet, LLDEnetFrame_t *frames, uint32_t nFrames)
Sends multiple Ethernet frames using LLDEnet.
LLDEnetFrame_t::tc
int tc
Definition: lldenet.h:157
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
LLDEnetFilter
int LLDEnetFilter(LLDEnet_t *hLLDEnet, uint8_t *dstMacAddr, uint32_t vlanId)
Filter RX packets by using the destination MAC address and VLAN ID.
LLDEnetCfg_t::dmaRxChId
int dmaRxChId
Definition: lldenet.h:129
LLDEnetFrame_t::port
int port
Definition: lldenet.h:152
LLDEnetCfg_t::nTxPkts
uint32_t nTxPkts
Definition: lldenet.h:109
LLDEnetCfg_t::instId
uint32_t instId
Definition: lldenet.h:77
LLDEnetRecv
int LLDEnetRecv(LLDEnet_t *hLLDEnet, LLDEnetFrame_t *frame)
Receives an Ethernet frame using LLDEnet.
LLDEnetSend
int LLDEnetSend(LLDEnet_t *hLLDEnet, LLDEnetFrame_t *frame)
Sends an Ethernet frame using LLDEnet.
LLDEnetCfg_t::unusedDma
bool unusedDma
Definition: lldenet.h:134
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:144
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:119
LLDEnetFrame_t
Structure representing an Ethernet frame.
Definition: lldenet.h:140
LLDEnetCfg_t::dmaTxChId
int dmaTxChId
Definition: lldenet.h:124
LLDEnetIETSetConfig
int LLDEnetIETSetConfig(LLDEnet_t *hLLDEnet, uint8_t macPort, void *reqPrm, void *resPrm)
Set frame preemption parameters for the port indicated by macPort.
LLDEnetTasSetConfig
int LLDEnetTasSetConfig(LLDEnet_t *hLLDEnet, uint8_t macPort, void *arg)
Set parameters for schedule traffic.
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:148
LLDEnetCfg_t::enetType
uint32_t enetType
Definition: lldenet.h:73
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.
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.