/* Timeout to receive the abort signal over loop back. In case CAN * bus is open, the timeout should be triggered.
*/ #define J1939_XTP_ABORT_TIMEOUT_MS 500 #define J1939_SIMPLE_ECHO_TIMEOUT_MS (10 * 1000)
/* indicates that this ecu successfully claimed @sa as its address */ struct hrtimer ac_timer; struct kref kref; struct j1939_priv *priv;
/* count users, to help transport protocol decide for interaction */ int nusers;
};
struct j1939_priv { struct list_head ecus; /* local list entry in priv * These allow irq (& softirq) context lookups on j1939 devices * This approach (separate lists) is done as the other 2 alternatives * are not easier or even wrong * 1) using the pure kobject methods involves mutexes, which are not * allowed in irq context. * 2) duplicating data structures would require a lot of synchronization * code * usage:
*/
/* segments need a lock to protect the above list */
rwlock_t lock;
struct net_device *ndev;
/* list of 256 ecu ptrs, that cache the claimed addresses. * also protected by the above lock
*/ struct j1939_addr_ent { struct j1939_ecu *ecu; /* count users, to help transport protocol */ int nusers;
} ents[256];
struct kref kref;
/* List of active sessions to prevent start of conflicting * one. * * Do not start two sessions of same type, addresses and * direction.
*/ struct list_head active_session_list;
/* lock for j1939_socks list */
rwlock_t j1939_socks_lock; struct list_head j1939_socks;
struct kref rx_kref;
u32 rx_tskey;
};
void j1939_ecu_put(struct j1939_ecu *ecu);
/* keep the cache of what is local */ int j1939_local_ecu_get(struct j1939_priv *priv, name_t name, u8 sa); void j1939_local_ecu_put(struct j1939_priv *priv, name_t name, u8 sa);
/* control buffer of the sk_buff */ struct j1939_sk_buff_cb { /* Offset in bytes within one ETP session */
u32 offset;
/* for tx, MSG_SYN will be used to sync on sockets */
u32 msg_flags;
u32 tskey;
struct j1939_addr addr;
/* Flags for quick lookups during skb processing. * These are set in the receive path only.
*/ #define J1939_ECU_LOCAL_SRC BIT(0) #define J1939_ECU_LOCAL_DST BIT(1)
u8 flags;
/* notify/alert all j1939 sockets bound to ifindex */ void j1939_sk_netdev_event_netdown(struct j1939_priv *priv); void j1939_sk_netdev_event_unregister(struct j1939_priv *priv); int j1939_cancel_active_session(struct j1939_priv *priv, struct sock *sk); void j1939_tp_init(struct j1939_priv *priv);
/* decrement pending skb for a j1939 socket */ void j1939_sock_pending_del(struct sock *sk);
enum j1939_session_state {
J1939_SESSION_NEW,
J1939_SESSION_ACTIVE, /* waiting for abort signal on the bus */
J1939_SESSION_WAITING_ABORT,
J1939_SESSION_ACTIVE_MAX,
J1939_SESSION_DONE,
};
/* ifindex, src, dst, pgn define the session block * the are _never_ modified after insertion in the list * this decreases locking problems a _lot_
*/ struct j1939_sk_buff_cb skcb; struct sk_buff_head skb_queue;
/* all tx related stuff (last_txcmd, pkt.tx) * is protected (modified only) with the txtimer hrtimer * 'total' & 'block' are never changed, * last_cmd, last & block are protected by ->lock * this means that the tx may run after cts is received that should * have stopped tx, but this time discrepancy is never avoided anyhow
*/
u8 last_cmd, last_txcmd; bool transmission; bool extd; /* Total message size, number of bytes */ unsignedint total_message_size; /* Total number of bytes queue from socket to the session */ unsignedint total_queued_size; unsignedint tx_retry;
int err;
u32 tskey; enum j1939_session_state state;
/* Packets counters for a (extended) transfer session. The packet is * maximal of 7 bytes.
*/ struct { /* total - total number of packets for this session */ unsignedint total; /* last - last packet of a transfer block after which * responder should send ETP.CM_CTS and originator * ETP.CM_DPO
*/ unsignedint last; /* tx - number of packets send by originator node. * this counter can be set back if responder node * didn't received all packets send by originator.
*/ unsignedint tx; unsignedint tx_acked; /* rx - number of packets received */ unsignedint rx; /* block - amount of packets expected in one block */ unsignedint block; /* dpo - ETP.CM_DPO, Data Packet Offset */ unsignedint dpo;
} pkt; struct hrtimer txtimer, rxtimer;
};
struct j1939_sock { struct sock sk; /* must be first to skip with memset */ struct j1939_priv *priv; struct list_head list;
int ifindex; struct j1939_addr addr;
spinlock_t filters_lock; struct j1939_filter *filters; int nfilters;
pgn_t pgn_rx_filter;
/* j1939 may emit equal PGN (!= equal CAN-id's) out of order * when transport protocol comes in. * To allow emitting in order, keep a 'pending' nr. of packets
*/
atomic_t skb_pending;
wait_queue_head_t waitq;
/* lock for the sk_session_queue list */
spinlock_t sk_session_queue_lock; struct list_head sk_session_queue;
};
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.