AM243x MCU+ SDK  09.01.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 
66 #define MAX_NUM_RX_DMA_CH_PER_INSTANCE 2
67 
71 typedef struct {
75  uint32_t enetType;
79  uint32_t instId;
83  void (*txNotifyCb)(void *cbArg);
87  void (*rxNotifyCb)(void *cbArg);
91  void *txCbArg;
95  void *rxCbArg;
100  uint8_t dstMacAddr[6];
105  uint32_t vlanId;
109  uint32_t ethType;
114  uint32_t nTxPkts;
124  uint32_t pktSize;
163  uint32_t numRxChannels;
164 } LLDEnetCfg_t;
165 
169 typedef struct {
173  uint8_t *buf;
177  uint32_t size;
181  int port;
186  int tc;
188 
195 
203 
209 void LLDEnetClose(LLDEnet_t *hLLDEnet);
210 
220 int LLDEnetFilter(LLDEnet_t *hLLDEnet, uint8_t *dstMacAddr,
221  uint32_t vlanId, uint32_t ethType);
222 
230 int LLDEnetAllocMac(LLDEnet_t *hLLDEnet, uint8_t *srcMacAddr);
231 
238 void LLDEnetFreeMac(LLDEnet_t *hLLDEnet, uint8_t *srcMacAddr);
239 
247 int LLDEnetSend(LLDEnet_t *hLLDEnet, LLDEnetFrame_t *frame);
248 
257 int LLDEnetSendMulti(LLDEnet_t *hLLDEnet, LLDEnetFrame_t *frames, uint32_t nFrames);
258 
269 int LLDEnetRecv(LLDEnet_t *hLLDEnet, LLDEnetFrame_t *frame);
270 
278 bool LLDEnetIsPortUp(LLDEnet_t *hLLDEnet, uint8_t portNum);
279 
289 int LLDEnetGetLinkInfo(LLDEnet_t *hLLDEnet, uint8_t portNum,
290  uint32_t *speed, uint32_t *duplex);
291 
300 int LLDEnetSetTxNotifyCb(LLDEnet_t *hLLDEnet, void (*txNotifyCb)(void *arg), void *arg);
301 
310 int LLDEnetSetRxNotifyCb(LLDEnet_t *hLLDEnet, void (*rxNotifyCb)(void *arg), void *arg);
311 
323  void (*rxDefaultDataCb)(void *data, int size, int port, void *arg), void *arg);
324 
334 int LLDEnetTasSetConfig(LLDEnet_t *hLLDEnet, uint8_t macPort, void *arg);
335 
347 int LLDEnetIETSetConfig(LLDEnet_t *hLLDEnet, uint8_t macPort, void *reqPrm, void *resPrm);
348 
356 #endif //LLDENET_H_
357 
LLDEnetCfg_t::dmaRxOwner
bool dmaRxOwner
Definition: lldenet.h:159
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:186
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:105
LLDEnetFrame_t::port
int port
Definition: lldenet.h:181
LLDEnetCfg_t::nTxPkts
uint32_t nTxPkts
Definition: lldenet.h:114
LLDEnetCfg_t::instId
uint32_t instId
Definition: lldenet.h:79
LLDEnetCfg_t::dmaRxShared
bool dmaRxShared
Definition: lldenet.h:149
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:144
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:71
LLDEnetFrame_t::buf
uint8_t * buf
Definition: lldenet.h:173
MAX_NUM_RX_DMA_CH_PER_INSTANCE
#define MAX_NUM_RX_DMA_CH_PER_INSTANCE
Definition: lldenet.h:66
LLDEnetIsRxTsInPkt
bool LLDEnetIsRxTsInPkt(LLDEnet_t *hLLDEnet)
Checks the receive packet timestamping mode.
LLDEnetCfg_t::ethType
uint32_t ethType
Definition: lldenet.h:109
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:91
LLDEnetCfg_t::pktSize
uint32_t pktSize
Definition: lldenet.h:124
LLDEnetFrame_t
Structure representing an Ethernet frame.
Definition: lldenet.h:169
LLDEnetCfg_t::dmaTxChId
int dmaTxChId
Definition: lldenet.h:129
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:177
LLDEnetCfg_t::numRxChannels
uint32_t numRxChannels
Definition: lldenet.h:163
LLDEnetCfg_t::enetType
uint32_t enetType
Definition: lldenet.h:75
LLDEnetCfg_t::unusedDmaRx
bool unusedDmaRx
Definition: lldenet.h:139
LLDEnetCfg_t::rxCbArg
void * rxCbArg
Definition: lldenet.h:95
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.