master.h File Reference

EtherCAT master structure. More...

Go to the source code of this file.

Data Structures

struct  ec_stats_t
 Cyclic statistics. More...
struct  ec_device_stats_t
 Device statistics. More...
struct  ec_master
 EtherCAT master. More...

Defines

#define EC_MASTER_INFO(master, fmt, args...)   printk(KERN_INFO "EtherCAT %u: " fmt, master->index, ##args)
 Convenience macro for printing master-specific information to syslog.
#define EC_MASTER_ERR(master, fmt, args...)   printk(KERN_ERR "EtherCAT ERROR %u: " fmt, master->index, ##args)
 Convenience macro for printing master-specific errors to syslog.
#define EC_MASTER_WARN(master, fmt, args...)   printk(KERN_WARNING "EtherCAT WARNING %u: " fmt, master->index, ##args)
 Convenience macro for printing master-specific warnings to syslog.
#define EC_MASTER_DBG(master, level, fmt, args...)
 Convenience macro for printing master-specific debug messages to syslog.
#define EC_EXT_RING_SIZE   32
 Size of the external datagram ring.
#define ec_master_num_devices(MASTER)   1
 Number of Ethernet devices.

Enumerations

enum  ec_master_phase_t { EC_ORPHANED, EC_IDLE, EC_OPERATION }
 EtherCAT master phase. More...

Functions

void ec_master_init_static (void)
 Static variables initializer.
int ec_master_init (ec_master_t *, unsigned int, const uint8_t *, const uint8_t *, dev_t, struct class *, unsigned int)
 Master constructor.
void ec_master_clear (ec_master_t *)
 Destructor.
int ec_master_enter_idle_phase (ec_master_t *)
 Transition function from ORPHANED to IDLE phase.
void ec_master_leave_idle_phase (ec_master_t *)
 Transition function from IDLE to ORPHANED phase.
int ec_master_enter_operation_phase (ec_master_t *)
 Transition function from IDLE to OPERATION phase.
void ec_master_leave_operation_phase (ec_master_t *)
 Transition function from OPERATION to IDLE phase.
void ec_master_eoe_start (ec_master_t *)
 Starts Ethernet over EtherCAT processing on demand.
void ec_master_eoe_stop (ec_master_t *)
 Stops the Ethernet over EtherCAT processing.
void ec_master_receive_datagrams (ec_master_t *, ec_device_t *, const uint8_t *, size_t)
 Processes a received frame.
void ec_master_queue_datagram (ec_master_t *, ec_datagram_t *)
 Places a datagram in the datagram queue.
void ec_master_queue_datagram_ext (ec_master_t *, ec_datagram_t *)
 Places a datagram in the non-application datagram queue.
void ec_master_set_send_interval (ec_master_t *, unsigned int)
 Sets the expected interval between calls to ecrt_master_send and calculates the maximum amount of data to queue.
void ec_master_attach_slave_configs (ec_master_t *)
 Attaches the slave configurations to the slaves.
ec_slave_tec_master_find_slave (ec_master_t *, uint16_t, uint16_t)
 Finds a slave in the bus, given the alias and position.
const ec_slave_tec_master_find_slave_const (const ec_master_t *, uint16_t, uint16_t)
 Finds a slave in the bus, given the alias and position.
void ec_master_output_stats (ec_master_t *)
 Output master statistics.
void ec_master_clear_eoe_handlers (ec_master_t *)
 Clear and free all EoE handlers.
void ec_master_clear_slaves (ec_master_t *)
 Clear all slaves.
unsigned int ec_master_config_count (const ec_master_t *)
 Get the number of slave configurations provided by the application.
ec_slave_config_tec_master_get_config (const ec_master_t *, unsigned int)
 Get a slave configuration via its position in the list.
const ec_slave_config_tec_master_get_config_const (const ec_master_t *, unsigned int)
 Get a slave configuration via its position in the list.
unsigned int ec_master_domain_count (const ec_master_t *)
 Get the number of domains.
ec_domain_tec_master_find_domain (ec_master_t *, unsigned int)
 Get a domain via its position in the list.
const ec_domain_tec_master_find_domain_const (const ec_master_t *, unsigned int)
 Get a domain via its position in the list.
uint16_t ec_master_eoe_handler_count (const ec_master_t *)
 Get the number of EoE handlers.
const ec_eoe_tec_master_get_eoe_handler_const (const ec_master_t *, uint16_t)
 Get an EoE handler via its position in the list.
int ec_master_debug_level (ec_master_t *, unsigned int)
 Set the debug level.
ec_domain_tecrt_master_create_domain_err (ec_master_t *)
 Same as ecrt_master_create_domain(), but with ERR_PTR() return value.
ec_slave_config_tecrt_master_slave_config_err (ec_master_t *, uint16_t, uint16_t, uint32_t, uint32_t)
 Same as ecrt_master_slave_config(), but with ERR_PTR() return value.
void ec_master_calc_dc (ec_master_t *)
 Distributed-clocks calculations.
void ec_master_request_op (ec_master_t *)
 Request OP state for configured slaves.
void ec_master_internal_send_cb (void *)
 Internal sending callback.
void ec_master_internal_receive_cb (void *)
 Internal receiving callback.

Variables

const unsigned int rate_intervals [EC_RATE_COUNT]
 List of intervals for statistics [s].


Detailed Description

EtherCAT master structure.

Definition in file master.h.


Define Documentation

#define EC_MASTER_INFO ( master,
fmt,
args...   )     printk(KERN_INFO "EtherCAT %u: " fmt, master->index, ##args)

Convenience macro for printing master-specific information to syslog.

This will print the message in fmt with a prefixed "EtherCAT <INDEX>: ", where INDEX is the master index.

Parameters:
master EtherCAT master
fmt format string (like in printf())
args arguments (optional)

Definition at line 73 of file master.h.

#define EC_MASTER_ERR ( master,
fmt,
args...   )     printk(KERN_ERR "EtherCAT ERROR %u: " fmt, master->index, ##args)

Convenience macro for printing master-specific errors to syslog.

This will print the message in fmt with a prefixed "EtherCAT <INDEX>: ", where INDEX is the master index.

Parameters:
master EtherCAT master
fmt format string (like in printf())
args arguments (optional)

Definition at line 85 of file master.h.

#define EC_MASTER_WARN ( master,
fmt,
args...   )     printk(KERN_WARNING "EtherCAT WARNING %u: " fmt, master->index, ##args)

Convenience macro for printing master-specific warnings to syslog.

This will print the message in fmt with a prefixed "EtherCAT <INDEX>: ", where INDEX is the master index.

Parameters:
master EtherCAT master
fmt format string (like in printf())
args arguments (optional)

Definition at line 97 of file master.h.

#define EC_MASTER_DBG ( master,
level,
fmt,
args...   ) 

Value:

do { \
        if (master->debug_level >= level) { \
            printk(KERN_DEBUG "EtherCAT DEBUG %u: " fmt, \
                    master->index, ##args); \
        } \
    } while (0)
Convenience macro for printing master-specific debug messages to syslog.

This will print the message in fmt with a prefixed "EtherCAT <INDEX>: ", where INDEX is the master index.

Parameters:
master EtherCAT master
level Debug level. Master's debug level must be >= level for output.
fmt format string (like in printf())
args arguments (optional)

Definition at line 111 of file master.h.

#define EC_EXT_RING_SIZE   32

Size of the external datagram ring.

The external datagram ring is used for slave FSMs.

Definition at line 124 of file master.h.


Enumeration Type Documentation

EtherCAT master phase.

Enumerator:
EC_ORPHANED  Orphaned phase.

The master has no Ethernet device attached.

EC_IDLE  Idle phase.

An Ethernet device is attached, but the master is not in use, yet.

EC_OPERATION  Operation phase.

The master was requested by a realtime application.

Definition at line 130 of file master.h.


Function Documentation

int ec_master_init ( ec_master_t master,
unsigned int  index,
const uint8_t *  main_mac,
const uint8_t *  backup_mac,
dev_t  device_number,
struct class class,
unsigned int  debug_level 
)

Master constructor.

Returns:
0 in case of success, else < 0
Parameters:
master  EtherCAT master
index  master index
main_mac  MAC address of main device
backup_mac  MAC address of backup device
device_number  Character device number.
class  Device class.
debug_level  Debug level (module parameter).

Definition at line 133 of file master.c.

int ec_master_enter_idle_phase ( ec_master_t master  ) 

Transition function from ORPHANED to IDLE phase.

Returns:
Zero on success, otherwise a negative error code.
Parameters:
master  EtherCAT master

Definition at line 625 of file master.c.

int ec_master_enter_operation_phase ( ec_master_t master  ) 

Transition function from IDLE to OPERATION phase.

Returns:
Zero on success, otherwise a negative error code.
Parameters:
master  EtherCAT master

Definition at line 682 of file master.c.

void ec_master_receive_datagrams ( ec_master_t master,
ec_device_t device,
const uint8_t *  frame_data,
size_t  size 
)

Processes a received frame.

This function is called by the network driver for every received frame.

Returns:
0 in case of success, else < 0
Parameters:
master  EtherCAT master
device  EtherCAT device
frame_data  frame data
size  size of the received data

Definition at line 1121 of file master.c.

ec_slave_t* ec_master_find_slave ( ec_master_t master,
uint16_t  alias,
uint16_t  position 
)

Finds a slave in the bus, given the alias and position.

Returns:
Search result, or NULL.
Parameters:
master  EtherCAT master.
alias  Slave alias.
position  Slave position.

Definition at line 1815 of file master.c.

const ec_slave_t* ec_master_find_slave_const ( const ec_master_t master,
uint16_t  alias,
uint16_t  position 
)

Finds a slave in the bus, given the alias and position.

Const version.

Returns:
Search result, or NULL.
Parameters:
master  EtherCAT master.
alias  Slave alias.
position  Slave position.

Definition at line 1831 of file master.c.

void ec_master_output_stats ( ec_master_t master  ) 

Output master statistics.

This function outputs statistical data on demand, but not more often than necessary. The output happens at most once a second.

Parameters:
master  EtherCAT master

Definition at line 1259 of file master.c.

unsigned int ec_master_config_count ( const ec_master_t master  ) 

Get the number of slave configurations provided by the application.

Returns:
Number of configurations.
Parameters:
master  EtherCAT master.

Definition at line 1847 of file master.c.

ec_slave_config_t* ec_master_get_config ( const ec_master_t master,
unsigned int  pos 
)

Get a slave configuration via its position in the list.

Returns:
Slave configuration or NULL.
Parameters:
master  EtherCAT master.
pos  List position.

Definition at line 1880 of file master.c.

const ec_slave_config_t* ec_master_get_config_const ( const ec_master_t master,
unsigned int  pos 
)

Get a slave configuration via its position in the list.

Const version.

Returns:
Slave configuration or NULL.
Parameters:
master  EtherCAT master.
pos  List position.

Definition at line 1895 of file master.c.

unsigned int ec_master_domain_count ( const ec_master_t master  ) 

Get the number of domains.

Returns:
Number of domains.
Parameters:
master  EtherCAT master.

Definition at line 1910 of file master.c.

ec_domain_t* ec_master_find_domain ( ec_master_t master,
unsigned int  index 
)

Get a domain via its position in the list.

Returns:
Domain pointer, or NULL if not found.
Parameters:
master  EtherCAT master.
index  Domain index.

Definition at line 1944 of file master.c.

const ec_domain_t* ec_master_find_domain_const ( const ec_master_t master,
unsigned int  index 
)

Get a domain via its position in the list.

Const version.

Returns:
Domain pointer, or NULL if not found.
Parameters:
master  EtherCAT master.
index  Domain index.

Definition at line 1959 of file master.c.

uint16_t ec_master_eoe_handler_count ( const ec_master_t master  ) 

Get the number of EoE handlers.

Returns:
Number of EoE handlers.
Parameters:
master  EtherCAT master.

Definition at line 1976 of file master.c.

const ec_eoe_t* ec_master_get_eoe_handler_const ( const ec_master_t master,
uint16_t  index 
)

Get an EoE handler via its position in the list.

Const version.

Returns:
EoE handler pointer, or NULL if not found.
Parameters:
master  EtherCAT master.
index  EoE handler index.

Definition at line 1998 of file master.c.

int ec_master_debug_level ( ec_master_t master,
unsigned int  level 
)

Set the debug level.

Return values:
0 Success.
-EINVAL Invalid debug level.
Parameters:
master  EtherCAT master.
level  Debug level. May be 0, 1 or 2.

Definition at line 2023 of file master.c.

ec_domain_t* ecrt_master_create_domain_err ( ec_master_t master  ) 

Same as ecrt_master_create_domain(), but with ERR_PTR() return value.

Returns:
New domain, or ERR_PTR() return value.
Parameters:
master  master

Definition at line 2241 of file master.c.


Generated on Mon Jun 20 09:31:31 2016 for IgH EtherCAT Master by  doxygen 1.5.6