# Real-time Ethernet Driver selection The EC-Monitor currently supports a variety of different Real-time Ethernet Driver modules, each contained in a single library file, which is loaded by the core library dynamically. The EC-Monitor shipment consist of a core library and one (or more) libraries each containing support for one specific Real-time Ethernet Driver module (type of hardware card). Which library actually is loaded depends on the Real-time Ethernet Driver parameters at runtime. Real-time means operating directly on the network adapter’s register set instead of using the operating system’s native driver. The principle of Real-time Ethernet Driver selection is that the name of the Real-time Ethernet Driver (Real-time Ethernet Driver Identification) is used to determine the location and name of a registration function, which is called by the EC-Monitor and registers function pointers which allow access to the Real-time Ethernet Driver functional entries. The EtherCAT® Real-time Ethernet Driver will be initialized using a Real-time Ethernet Driver specific configuration parameter set. A pointer to this parameter set is part of the EC-Monitor initialization settings. The EC-Monitor supports two Real-time Ethernet Driver operating modes: > - Interrupt mode all received Ethernet frames will be processed immediately in the context of the Real-time Ethernet Driver receiver task. > - Polling mode the EC-Monitor will call the Real-time Ethernet Driver receiver polling function prior to processing received frames. ## Real-time Ethernet Driver and PHY OS Driver Some operating systems, e.g. Linux and Xenomai, provide drivers for most common Ethernet controllers and their related physical transceivers (PHY). The manufacturer specific PHY circuits can be handled by a dedicated driver. Using the PHY OS Driver interface it is possible to use the manufacturer’s dedicated PHY driver without modification of the Real-time Ethernet Driver driver. Depending on the hardware architecture, an additional module from acontis, e.g. atemsys for Linux, grants access to the MDIO bus to the OS drivers, or request MDIO operations from the OS drivers. ![PHY OS Driver interface architecture showing how the Real-time Ethernet Driver communicates with manufacturer-specific PHY drivers via an OS abstraction module such as atemsys on Linux](../../EcMaster/Media/emll_phy_os_driver_architecture.png) #### NOTE Real-time Ethernet Driver modules not listed here may be available if purchased additionally ## Real-time Ethernet Driver selection and initialization The different Real-time Ethernet Driver modules are selected and parameterized by a common structure [`EC_T_LINK_PARMS`](#_CPPv415EC_T_LINK_PARMS) shared by all Real-time Ethernet Driver and a Real-time Ethernet Driver specific structure, pointed to by an element within the common structure. This parameter set is given to [`EC_T_MONITOR_INIT_PARMS::pLinkParms`](api_general.html.md#_CPPv4N23EC_T_MONITOR_INIT_PARMS10pLinkParmsE) with the call of [`emonInitMonitor()`](api_general.html.md#_CPPv415emonInitMonitor10EC_T_DWORDPK23EC_T_MONITOR_INIT_PARMS). ### struct EC_T_LINK_PARMS ### Public Members ### [EC_T_DWORD](api.html.md#_CPPv410EC_T_DWORD) dwSignature [in] Signature of the adapter specific structure containing the [EC_T_LINK_PARMS](#d1/d58/struct_e_c___t___l_i_n_k___p_a_r_m_s) structure ### [EC_T_DWORD](api.html.md#_CPPv410EC_T_DWORD) dwSize [in] Size of the adapter specific structure containing the [EC_T_LINK_PARMS](#d1/d58/struct_e_c___t___l_i_n_k___p_a_r_m_s) structure ### [EC_T_LOG_PARMS](api_general.html.md#_CPPv414EC_T_LOG_PARMS) LogParms [in] Logging parameters ### [EC_T_CHAR](api.html.md#_CPPv49EC_T_CHAR) szDriverIdent[EC_DRIVER_IDENT_NAME_SIZE] [in] Name of Link Layer module (driver identification) for Link Layer Selection ### [EC_T_DWORD](api.html.md#_CPPv410EC_T_DWORD) dwInstance [in] Instance of the adapter. If EC_LINKUNIT_PCILOCATION is set: contains PCI address. ### EC_T_LINKMODE eLinkMode [in] Mode of operation ### EC_T_CPUSET cpuIstCpuAffinityMask [in] Interrupt service thread CPU affinity mask ### [EC_T_DWORD](api.html.md#_CPPv410EC_T_DWORD) dwIstPriority [in] Task priority of the interrupt service task (not used in polling mode) ### [EC_T_DWORD](api.html.md#_CPPv410EC_T_DWORD) dwIstStackSize [in] Task stack size ### [EC_T_DWORD](api.html.md#_CPPv410EC_T_DWORD) dwLinkSpeed [in] 10, 100, 1000 Mbit/s ### [EC_T_LINKLAYER_TIMINGTASK](#_CPPv425EC_T_LINKLAYER_TIMINGTASK) oLinkLayerTimingTask [in] LinkLayer timimg task parameters ### [EC_T_CHAR](api.html.md#_CPPv49EC_T_CHAR) szLoadPath[EC_DRIVER_PATH_SIZE] [in] Path from which the libraries should be loaded ### struct EC_T_LINKLAYER_TIMINGTASK ### Public Members ### EC_T_LINKLAYER_TIMING eLinkLayerTiming [in] LinkLayer timing task mode ### [EC_T_DWORD](api.html.md#_CPPv410EC_T_DWORD) dwCycleTimeNsec [in] Cycle time between 2 pfnStartCycle calls in ns. Will be set by the master stack for the link layer. ### EC_T_LINK_STARTCYCLE_CALLBACK pfnStartCycle [in] Callback function called cyclically according to dwCycleTimeNsec ### EC_T_VOID \*pvStartCycleContext [in] Context passed to each pfnStartCycle call ### [EC_T_DWORD](api.html.md#_CPPv410EC_T_DWORD) dwTtsSendOffsetUsec [in] Time between pfnStartCycle call and TTS frame transmission ### [EC_T_UINT64](api.html.md#_CPPv411EC_T_UINT64) nSystemTime [in] System ## Real-time Ethernet Driver instance selection via PCI location For some operating systems it is possible to address the Real-time Ethernet Driver instance using its PCI address as an alternative. To do this, EC_LINKUNIT_PCILOCATION (0x01000000) and the PCI location must be set as [`EC_T_LINK_PARMS::dwInstance`](#_CPPv4N15EC_T_LINK_PARMS10dwInstanceE). On Linux the PCI address can be shown using e.g.: ```console $ lspci | grep Ethernet ``` ```console $ 00:19.0 Ethernet controller: Intel Corporation Ethernet Connection I217-LM (rev 04) $ 04:00.0 Ethernet controller: Intel Corporation 82574L Gigabit Network Connection $ 05:00.0 Ethernet controller: Intel Corporation 82574L Gigabit Network Connection ``` The format of [`EC_T_LINK_PARMS::dwInstance`](#_CPPv4N15EC_T_LINK_PARMS10dwInstanceE) using PCI bus address is: 0x01bbddff : - bb Bus Number - dd Device Number - ff Function Number ```cpp EC_T_LINK_PARMS::dwInstance = 0x01001900; //"0000:00:19.0" ``` On Windows the integer value displayed in properties dialog must be converted to HEX. E.g the number from the following dialog (PCI bus 11, device 0, function 0) corresponds to 0x010B0000 (bus 0x0B). ![Windows network connection properties dialog showing PCI bus, device, and function numbers for determining the Real-time Ethernet Driver instance address](../Media/NetworkConnectionProps_Windows.png)