Adds sitara_depot/free_rtos Original one is on server_gorbunov/SmartForce4.0/sitara_depot
140 lines
3.0 KiB
C++
140 lines
3.0 KiB
C++
/*
|
|
* eth.hpp
|
|
*
|
|
* Created on: 6 ìàð. 2023 ã.
|
|
* Author: sychev
|
|
*/
|
|
|
|
#ifndef FREE_RTOS_ETHERNET_ETH_HPP_
|
|
#define FREE_RTOS_ETHERNET_ETH_HPP_
|
|
|
|
#include "ethernet/eth_rx_flow.hpp"
|
|
#include "ethernet/eth_tx_flow.hpp"
|
|
|
|
#include "semaphore/semaphore.hpp"
|
|
#include "ethernet/eth_frame.h"
|
|
#include "task/task.hpp"
|
|
|
|
#include <networking/enet/core/include/core/enet_per.h>
|
|
#include <networking/enet/utils/include/enet_apputils.h>
|
|
#include <networking/enet/core/include/per/icssg.h>
|
|
#include <cstdint>
|
|
#include <string>
|
|
|
|
#include "ethernet/eth_types.h"
|
|
|
|
#include "ethernet_ip/eth_stack.hpp"
|
|
|
|
namespace free_rtos {
|
|
|
|
class Eth {
|
|
public:
|
|
typedef enum {
|
|
e_ethInstSwitch = 1, /// Ïîääåðæèâàåòñÿ
|
|
e_ethInstDualMac_1, /// Íå ïîääåðæèâàåòñÿ
|
|
e_ethInstDualMac_2 /// Íå ïîääåðæèâàåòñÿ
|
|
}TEthInstId;
|
|
|
|
struct Settings {
|
|
uint32_t id; /// Èäåíòèôèêàòîð ïîðòà
|
|
|
|
/* Peripheral type */
|
|
Enet_Type enetType;
|
|
|
|
/* Peripheral instance */
|
|
TEthInstId instId;
|
|
|
|
/* Peripheral's MAC ports to use */
|
|
Enet_MacPort macPort[e_ethMacTotal];
|
|
|
|
/* Number of MAC ports in macPorts array */
|
|
uint32_t macPortNum;
|
|
|
|
/* Name of this port to be used for logging */
|
|
std::string name;
|
|
|
|
uint32_t vlan_id;
|
|
|
|
EthStack::Settings eth_stack_sett;
|
|
};
|
|
|
|
Eth();
|
|
|
|
bool Init(Settings& sett);
|
|
|
|
bool Open();
|
|
|
|
void ioctl_callback();
|
|
|
|
void link_task();
|
|
|
|
EthUdpServerIface * getUdpServerPtr() {return eth_stack_.getUdpServerPtr(); }
|
|
|
|
EthTxFlowIface * getTxFlowPtr() { return &tx_flow_; }
|
|
|
|
EthStackIface * getEthStackPtr() {return ð_stack_;}
|
|
|
|
private:
|
|
enum TaskPriority {
|
|
e_linkTaskPriority = 2
|
|
};
|
|
|
|
bool host_init();
|
|
|
|
|
|
private:
|
|
enum SignalsId {
|
|
e_signalIoctl, /// Çàâåðøåíèå ïåðåäà÷è ïî ioctl
|
|
e_signalTotal
|
|
};
|
|
|
|
enum TasksId {
|
|
e_taskLink,
|
|
e_taskTotal
|
|
};
|
|
|
|
uint32_t id_; /// Èäåíòèôèêàòîð ïîðòà
|
|
std::string name_; /// Èìÿ ïîðòà
|
|
|
|
uint32_t core_id_; /// Èäåíòèôèêàòîð ÿäðà
|
|
|
|
Enet_Type enetType_; /// Òèï ïîðòà
|
|
|
|
/// Èäåíòèôèêàòîð ïåðèôåðèè mac: 1 - äëÿ ðåæèìà SWITCH, 2 è 3 äëÿ ðåæèìà DUAL MAC ( äëÿ mac1 è mac2 ñîîòâåòñòâåííî)
|
|
uint32_t instId_;
|
|
|
|
/// Èäåíòèôèêàòîðû mac ïîðòîâ
|
|
Enet_MacPort macPort_[e_ethMacTotal];
|
|
|
|
/// Êîëè÷åñòâî MAC ïîðòîâ
|
|
uint32_t macPortNum_;
|
|
|
|
/// Îñíîâíàÿ èíôîðìàöèÿ î ïîäêëþ÷åíèè äëÿ ïåðèôåðèéíîãî óñòðîéñòâà ????
|
|
EnetPer_AttachCoreOutArgs attachInfo_;
|
|
|
|
/// Enet è Udma îáðàáîò÷èê èíôîðìàöèè äëÿ ïåðèôåðèéíîãî óñòðîéñòâà.
|
|
EnetApp_HandleInfo handleInfo_;
|
|
|
|
EthTxFlow tx_flow_; ///
|
|
EthRxFlow rx_flow_[e_ethMacTotal]; /// Äâà ïîòîêà ïðèåìà â ðåæèìå SWITCH
|
|
|
|
Semaphore sem_[e_signalTotal];
|
|
|
|
Task task_[e_taskTotal];
|
|
|
|
bool linkUp_[e_ethMacTotal];
|
|
|
|
bool host_ready_;
|
|
|
|
TEthFrameMacAddr hostMacAddr_; /// ñîáñòâåííûé ìàê àäðåñ
|
|
|
|
uint32_t vlan_id_;
|
|
|
|
EthStack eth_stack_; /// Ñòåê ëîãè÷åñêèõ ïðîòîêîëîâ
|
|
};
|
|
|
|
}
|
|
|
|
|
|
#endif /* FREE_RTOS_ETHERNET_ETH_HPP_ */
|