2023-05-03 14:01:32 +03:00
|
|
|
|
/*
|
|
|
|
|
|
* eth.hpp
|
|
|
|
|
|
*
|
2024-02-21 10:41:56 +03:00
|
|
|
|
* Created on: 6 мар. 2023 г.
|
2023-05-03 14:01:32 +03:00
|
|
|
|
* Author: sychev
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
#ifndef FREE_RTOS_ETHERNET_ETH_HPP_
|
|
|
|
|
|
#define FREE_RTOS_ETHERNET_ETH_HPP_
|
|
|
|
|
|
|
2023-06-26 18:22:30 +03:00
|
|
|
|
#include "free_rtos/ethernet/eth_task_settings.hpp"
|
|
|
|
|
|
#include "free_rtos/ethernet/eth_rx_flow.hpp"
|
|
|
|
|
|
#include "free_rtos/ethernet/eth_tx_flow.hpp"
|
2023-05-03 14:01:32 +03:00
|
|
|
|
|
2023-06-26 18:22:30 +03:00
|
|
|
|
#include "free_rtos/semaphore/semaphore.hpp"
|
|
|
|
|
|
#include "free_rtos/ethernet/eth_frame.h"
|
|
|
|
|
|
#include "free_rtos/task/task.hpp"
|
2023-05-03 14:01:32 +03:00
|
|
|
|
|
|
|
|
|
|
#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>
|
|
|
|
|
|
|
2023-06-26 18:22:30 +03:00
|
|
|
|
#include "free_rtos/ethernet/eth_types.h"
|
2023-05-03 14:01:32 +03:00
|
|
|
|
|
2023-06-26 18:22:30 +03:00
|
|
|
|
#include "free_rtos/ethernet_ip/eth_stack.hpp"
|
2023-05-03 14:01:32 +03:00
|
|
|
|
|
|
|
|
|
|
namespace free_rtos {
|
|
|
|
|
|
|
|
|
|
|
|
class Eth {
|
|
|
|
|
|
public:
|
|
|
|
|
|
typedef enum {
|
2024-02-21 10:41:56 +03:00
|
|
|
|
e_ethInstSwitch = 1,
|
|
|
|
|
|
e_ethInstDualMac_1,
|
|
|
|
|
|
e_ethInstDualMac_2
|
2023-05-03 14:01:32 +03:00
|
|
|
|
}TEthInstId;
|
|
|
|
|
|
|
|
|
|
|
|
struct Settings {
|
2024-02-21 10:41:56 +03:00
|
|
|
|
uint32_t id;
|
2023-05-03 14:01:32 +03:00
|
|
|
|
|
|
|
|
|
|
/* Peripheral type */
|
|
|
|
|
|
Enet_Type enetType;
|
|
|
|
|
|
|
|
|
|
|
|
/* Peripheral instance */
|
|
|
|
|
|
TEthInstId instId;
|
|
|
|
|
|
|
|
|
|
|
|
/* Peripheral's MAC ports to use */
|
|
|
|
|
|
Enet_MacPort macPort[e_ethMacTotal];
|
2023-09-22 10:59:11 +03:00
|
|
|
|
UBaseType_t rxTaskPriority[e_ethMacTotal];
|
|
|
|
|
|
UBaseType_t rxTaskStackSize[e_ethMacTotal];
|
2023-05-03 14:01:32 +03:00
|
|
|
|
|
|
|
|
|
|
/* 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 {
|
2024-02-21 10:41:56 +03:00
|
|
|
|
e_signalIoctl,
|
2023-05-03 14:01:32 +03:00
|
|
|
|
e_signalTotal
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
enum TasksId {
|
|
|
|
|
|
e_taskLink,
|
|
|
|
|
|
e_taskTotal
|
|
|
|
|
|
};
|
|
|
|
|
|
|
2024-02-21 10:41:56 +03:00
|
|
|
|
uint32_t id_;
|
|
|
|
|
|
std::string name_;
|
2023-05-03 14:01:32 +03:00
|
|
|
|
|
2024-02-21 10:41:56 +03:00
|
|
|
|
uint32_t core_id_;
|
|
|
|
|
|
|
|
|
|
|
|
Enet_Type enetType_;
|
2023-05-03 14:01:32 +03:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
uint32_t instId_;
|
|
|
|
|
|
|
2024-02-21 10:41:56 +03:00
|
|
|
|
|
2023-05-03 14:01:32 +03:00
|
|
|
|
Enet_MacPort macPort_[e_ethMacTotal];
|
2023-09-22 10:59:11 +03:00
|
|
|
|
UBaseType_t rxTaskPriority_[e_ethMacTotal];
|
|
|
|
|
|
UBaseType_t rxTaskStackSize_[e_ethMacTotal];
|
2023-05-03 14:01:32 +03:00
|
|
|
|
|
2024-02-21 10:41:56 +03:00
|
|
|
|
|
2023-05-03 14:01:32 +03:00
|
|
|
|
uint32_t macPortNum_;
|
|
|
|
|
|
|
2024-02-21 10:41:56 +03:00
|
|
|
|
|
2023-05-03 14:01:32 +03:00
|
|
|
|
EnetPer_AttachCoreOutArgs attachInfo_;
|
|
|
|
|
|
|
2024-02-21 10:41:56 +03:00
|
|
|
|
|
2023-05-03 14:01:32 +03:00
|
|
|
|
EnetApp_HandleInfo handleInfo_;
|
|
|
|
|
|
|
|
|
|
|
|
EthTxFlow tx_flow_; ///
|
2024-02-21 10:41:56 +03:00
|
|
|
|
EthRxFlow rx_flow_[e_ethMacTotal];
|
2023-05-03 14:01:32 +03:00
|
|
|
|
|
|
|
|
|
|
Semaphore sem_[e_signalTotal];
|
|
|
|
|
|
|
|
|
|
|
|
Task task_[e_taskTotal];
|
|
|
|
|
|
|
|
|
|
|
|
bool linkUp_[e_ethMacTotal];
|
|
|
|
|
|
|
|
|
|
|
|
bool host_ready_;
|
|
|
|
|
|
|
2024-02-21 10:41:56 +03:00
|
|
|
|
TEthFrameMacAddr hostMacAddr_;
|
2023-05-03 14:01:32 +03:00
|
|
|
|
|
|
|
|
|
|
uint32_t vlan_id_;
|
|
|
|
|
|
|
2024-02-21 10:41:56 +03:00
|
|
|
|
EthStack eth_stack_;
|
2023-05-03 14:01:32 +03:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#endif /* FREE_RTOS_ETHERNET_ETH_HPP_ */
|