42#ifndef __DEV_CAN_CAN_IMPL_H
43#define __DEV_CAN_CAN_IMPL_H
67static inline int rtems_can_queue_fifo_test_flag(
72 return ( atomic_load( &fifo->
fifo_flags ) & flag ) == flag;
84static inline void rtems_can_queue_fifo_set_flag(
101static inline void rtems_can_queue_fifo_clear_flag(
119static inline int rtems_can_queue_fifo_test_and_set_flag(
124 return ( atomic_fetch_or( &fifo->
fifo_flags, flag ) & flag ) ? 1 : 0;
137static inline int rtems_can_queue_fifo_test_and_clear_fl(
142 return ( atomic_fetch_and( &fifo->
fifo_flags, ~flag ) & flag ) ? 1 : 0;
155static inline int rtems_can_queue_fifo_out_is_ready_unprotected(
159 return ( ( fifo->
head ) != NULL ) ? 1 : 0;
176static inline bool rtems_can_queue_filter_match(
181 return ( ( filter->
id^
id ) & filter->
id_mask ) ||
195static inline int rtems_can_queue_fifo_get_inslot(
205 if ( ( slot = fifo->
free_list ) == NULL ) {
237static inline int rtems_can_queue_fifo_put_inslot(
279static inline int rtems_can_queue_fifo_abort_inslot(
313static inline int rtems_can_queue_fifo_test_outslot(
322 if ( ( slot = fifo->
head ) == NULL ) {
328 if ( ( fifo->
head=slot->
next ) == NULL ) {
355static inline int rtems_can_queue_fifo_free_outslot(
371 if ( ( fifo->
head ) == NULL ) {
396static inline int rtems_can_queue_fifo_again_outslot(
404 if ( ( slot->
next = fifo->
head ) == NULL ) {
425static inline int rtems_can_queue_fifo_slot_size(
int max_data_length )
443static inline void rtems_can_queue_notify_input_ends(
465static inline void rtems_can_queue_notify_output_ends(
486static inline void rtems_can_queue_notify_both_ends(
491 rtems_can_queue_notify_input_ends( qedge, what );
492 rtems_can_queue_notify_output_ends( qedge, what );
508static inline void rtems_can_queue_activate_edge(
517 if ( qedge->
edge_prio >= RTEMS_CAN_QUEUE_PRIO_NR ) {
518 qedge->
edge_prio = RTEMS_CAN_QUEUE_PRIO_NR - 1;
521 if ( output_ends != NULL ) {
522 rtems_mutex_lock( &output_ends->
ends_lock );
526 TAILQ_REMOVE( qedge->
peershead, qedge, activepeers );
536 rtems_mutex_unlock( &output_ends->
ends_lock );
540static inline void rtems_can_queue_edge_to_idle_unprotected(
546 TAILQ_REMOVE( qedge->
peershead, qedge, activepeers );
548 TAILQ_INSERT_TAIL( &output_ends->
idle, qedge, activepeers );
560static inline void rtems_can_queue_edge_incref(
567static inline void rtems_can_queue_do_edge_decref_body(
575 if ( input_ends < output_ends ) {
576 rtems_mutex_lock( &input_ends->
ends_lock );
577 rtems_mutex_lock( &output_ends->
ends_lock );
578 if ( atomic_fetch_sub( &edge->
edge_used, 1 ) == 1 ) {
579 dead_fl = !rtems_can_queue_fifo_test_and_set_flag(
584 rtems_mutex_unlock( &output_ends->
ends_lock );
585 rtems_mutex_unlock( &input_ends->
ends_lock );
587 rtems_mutex_lock( &output_ends->
ends_lock );
588 if ( output_ends != input_ends ) {
589 rtems_mutex_lock( &input_ends->
ends_lock );
591 if ( atomic_fetch_sub( &edge->
edge_used, 1 ) == 1 ) {
592 dead_fl = !rtems_can_queue_fifo_test_and_set_flag(
597 if ( output_ends != input_ends ) {
598 rtems_mutex_unlock( &input_ends->
ends_lock );
600 rtems_mutex_unlock( &output_ends->
ends_lock );
620static inline void rtems_can_queue_edge_decref(
626 x = atomic_load_explicit( &edge->
edge_used, memory_order_relaxed );
632 }
while( !atomic_compare_exchange_strong(&edge->
edge_used, &x, x-1 ) );
642 edge = TAILQ_FIRST( &qends->
inlist );
645 edge = TAILQ_NEXT( edge, input_peers );
648 rtems_can_queue_edge_incref( edge );
663 next = TAILQ_NEXT( edge, input_peers );
666 next = TAILQ_NEXT( next, input_peers );
669 rtems_can_queue_edge_incref( next );
672 rtems_can_queue_edge_decref( edge );
676#define rtems_can_queue_for_each_inedge( qends, edge ) \
678 edge = rtems_can_queue_first_inedge( qends ); \
680 edge = rtems_can_queue_next_inedge( qends, edge ) )
690 edge = TAILQ_FIRST( &qends->
outlist );
693 edge = TAILQ_NEXT( edge, output_peers );
696 rtems_can_queue_edge_incref( edge );
711 next = TAILQ_NEXT( edge, output_peers );
714 next = TAILQ_NEXT( next, output_peers );
717 rtems_can_queue_edge_incref( next );
720 rtems_can_queue_edge_decref( edge );
724#define rtems_can_queue_for_each_outedge( qends, edge ) \
726 edge = can_queue_first_outedge( qends ); \
728 edge = rtems_can_queue_next_outedge( qends, edge ) )
This header file is part of CAN/CAN FD bus common support. It implements structure that represents fi...
This header file is part of CAN/CAN FD bus common support. It implements CAN frame structure and rela...
void rtems_can_queue_edge_do_dead(struct rtems_can_queue_edge *qedge)
This function disconnects the edge.
Definition: can-quekern.c:138
void rtems_can_queue_do_edge_decref(struct rtems_can_queue_edge *qedge)
This function decrements the edge user counter.
Definition: can-queue.c:99
This file is part of CAN/CAN FD bus common support and implements CAN FIFOs and generic hubs/ends for...
#define RTEMS_CAN_FIFOF_DEAD
This is used when FIFO is beeing destroyed.
Definition: can-queue.h:173
#define RTEMS_CAN_FIFOF_OVERRUN
This indicates attempt to acquire new slot, when FIFO is full.
Definition: can-queue.h:161
#define RTEMS_CAN_SLOTF_CMD
Macro for command associated with allocated slot.
Definition: can-queue.h:80
#define RTEMS_CAN_FIFOF_FULL
This indicates FIFO full state.
Definition: can-queue.h:165
#define RTEMS_CAN_FIFOF_INACTIVE
This indicates FIFO is inactive.
Definition: can-queue.h:177
#define RTEMS_CAN_FIFOF_EMPTY
This indicates no allocated slot in the FIFO.
Definition: can-queue.h:169
#define CAN_FRAME_FIFO_OVERFLOW
Represents local FIFO overflow.
Definition: can-frame.h:117
#define RTEMS_ALIGN_UP(_value, _alignment)
Aligns up the value to the alignment.
Definition: basedefs.h:141
#define RTEMS_ALIGNOF(_type_name)
Gets the alignment requirement of the type.
Definition: basedefs.h:176
Provide printf() PRIxxx Constante Beyond Standards.
This header file defines the RTEMS Classic API.
Header File for Status Checks.
struct can_frame_header header
This member stores the structure can_frame_header representing CAN header.
Definition: can-frame.h:539
uint8_t data[CAN_FRAME_MAX_DLEN]
This member stores CAN data.
Definition: can-frame.h:543
This structure is used to represent CAN ID and flags in one unified structure.
Definition: can-filter.h:50
uint32_t id
This member is a bitfield that holds required CAN identifier values to assign CAN frame to the FIFO q...
Definition: can-filter.h:55
uint32_t flags_mask
This member is a bitfield that holds CAN flags forbidden in CAN frame. If the frame has some of these...
Definition: can-filter.h:76
uint32_t id_mask
This member is a bitfield that holds forbidden CAN identifier values. If the frame has identifier in ...
Definition: can-filter.h:61
uint32_t flags
This member is a bitfield that holds CAN flags required in CAN frame to be assigned to the FIFO queue...
Definition: can-filter.h:68
This structure represents one direction connection from messages source ( input_ends) to message cons...
Definition: can-queue.h:231
struct rtems_can_queue_edges_list * peershead
This member holds the pointer to the activepeers head.
Definition: can-queue.h:263
int edge_prio
This member holds the the assigned queue priority from the range 0 to RTEMS_CAN_QUEUE_PRIO_NR - 1.
Definition: can-queue.h:283
struct rtems_can_queue_ends * output_ends
This member holds the pointer to the FIFO output side terminal ( rtems_can_queue_ends ).
Definition: can-queue.h:273
atomic_uint edge_used
This member holds the atomic usage counter, mainly used for safe destruction of the edge.
Definition: can-queue.h:278
struct rtems_can_queue_ends * input_ends
This member holds the pointer to the FIFO input side terminal ( rtems_can_queue_ends ).
Definition: can-queue.h:268
struct rtems_can_queue_fifo fifo
This member holds place where primitive rtems_can_queue_fifo FIFO is located.
Definition: can-queue.h:236
This structure represents place to connect edges to for CAN communication entity. The zero,...
Definition: can-queue.h:299
struct rtems_can_queue_edges_list active[RTEMS_CAN_QUEUE_PRIO_NR]
This member holds the array of the lists of active edges directed to the ends structure.
Definition: can-queue.h:304
struct rtems_can_queue_edges_list outlist
This member holds the list of all incoming edges output sides. Each of there edges is listed on one o...
Definition: can-queue.h:318
struct rtems_can_queue_edges_list idle
This member holds the list of the edges directed to the ends structure with empty FIFOs.
Definition: can-queue.h:309
rtems_mutex ends_lock
This member holds the lock synchronizing operations between threads accessing the ends.
Definition: can-queue.h:323
struct rtems_can_queue_edges_list inlist
This member holds the list of outgoing edges input sides.
Definition: can-queue.h:313
void(* notify)(struct rtems_can_queue_ends *qends, struct rtems_can_queue_edge *qedge, int what)
pointer to notify procedure. The next state changes are notified.
Definition: can-queue.h:350
This structure represents CAN FIFO queue. It is implemented as a single linked list of slots prepared...
Definition: can-queue.h:88
unsigned int out_taken
This member holds the number of elements in the fifo.
Definition: can-queue.h:103
struct rtems_can_queue_slot * free_list
This member holds the pointer to list of the free slots associated with queue.
Definition: can-queue.h:121
rtems_mutex fifo_lock
This member holds the lock to ensure atomicity of slot manipulation operations.
Definition: can-queue.h:139
struct rtems_can_queue_slot * head
This member holds the pointer to the FIFO head, oldest slot.
Definition: can-queue.h:111
atomic_uint fifo_flags
This field holds global flags describing state of the FIFO.
Definition: can-queue.h:92
struct rtems_can_queue_slot ** tail
This member holds the pointer to the location, where pointer to newly inserted slot should be added.
Definition: can-queue.h:116
This structure represents one CAN message slot in the CAN FIFO queue.
Definition: can-queue.h:60
atomic_uint slot_flags
Space for flags and optional command describing action associated with slot data.
Definition: can-queue.h:69
struct can_frame frame
This member holds can_frame structure representing one CAN frame/message.
Definition: can-queue.h:74
struct rtems_can_queue_slot * next
Pointer to next/younger slot.
Definition: can-queue.h:64
This header file provides the API of Self-Contained Objects.