net/nfc/hci/llc_shdlc.c
Source file repositories/reference/linux-study-clean/net/nfc/hci/llc_shdlc.c
File Facts
- System
- Linux kernel
- Corpus path
net/nfc/hci/llc_shdlc.c- Extension
.c- Size
- 19056 bytes
- Lines
- 827
- Domain
- Networking Core
- Bucket
- Sockets, Protocols, Packet Path, And Network Policy
- Inferred role
- Networking Core: implementation source
- Status
- source implementation candidate
Why This File Exists
Networking stack implementation surface: socket APIs, protocol dispatch, packet flow, routing, filtering, and network namespaces.
- Networking stack implementation surface: socket APIs, protocol dispatch, packet flow, routing, filtering, and network namespaces.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- Allocates kernel memory; connect allocation flags and lifetime to context constraints.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/types.hlinux/sched.hlinux/wait.hlinux/slab.hlinux/skbuff.hllc.h
Detected Declarations
struct llc_shdlcenum shdlc_stateenum sframe_typeenum uframe_modifierfunction llc_shdlc_x_lt_y_lteq_zfunction llc_shdlc_x_lteq_y_lt_zfunction llc_shdlc_send_s_framefunction llc_shdlc_send_u_framefunction llc_shdlc_reset_t2function llc_shdlc_rcv_i_framefunction llc_shdlc_rcv_ackfunction llc_shdlc_requeue_ack_pendingfunction llc_shdlc_rcv_rejfunction llc_shdlc_rcv_s_framefunction llc_shdlc_connect_completefunction llc_shdlc_connect_initiatefunction llc_shdlc_connect_send_uafunction llc_shdlc_rcv_u_framefunction llc_shdlc_handle_rcv_queuefunction llc_shdlc_w_usedfunction llc_shdlc_handle_send_queuefunction llc_shdlc_connect_timeoutfunction llc_shdlc_t1_timeoutfunction llc_shdlc_t2_timeoutfunction llc_shdlc_sm_workfunction llc_shdlc_connectfunction llc_shdlc_disconnectfunction llc_shdlc_recv_framefunction llc_shdlc_deinitfunction llc_shdlc_startfunction llc_shdlc_stopfunction llc_shdlc_rcv_from_drvfunction llc_shdlc_xmit_from_hcifunction nfc_llc_shdlc_register
Annotated Snippet
struct llc_shdlc {
struct nfc_hci_dev *hdev;
xmit_to_drv_t xmit_to_drv;
rcv_to_hci_t rcv_to_hci;
struct mutex state_mutex;
enum shdlc_state state;
int hard_fault;
wait_queue_head_t *connect_wq;
int connect_tries;
int connect_result;
struct timer_list connect_timer;/* aka T3 in spec 10.6.1 */
u8 w; /* window size */
bool srej_support;
struct timer_list t1_timer; /* send ack timeout */
bool t1_active;
struct timer_list t2_timer; /* guard/retransmit timeout */
bool t2_active;
int ns; /* next seq num for send */
int nr; /* next expected seq num for receive */
int dnr; /* oldest sent unacked seq num */
struct sk_buff_head rcv_q;
struct sk_buff_head send_q;
bool rnr; /* other side is not ready to receive */
struct sk_buff_head ack_pending_q;
struct work_struct sm_work;
int tx_headroom;
int tx_tailroom;
llc_failure_t llc_failure;
};
#define SHDLC_LLC_HEAD_ROOM 2
#define SHDLC_MAX_WINDOW 4
#define SHDLC_SREJ_SUPPORT false
#define SHDLC_CONTROL_HEAD_MASK 0xe0
#define SHDLC_CONTROL_HEAD_I 0x80
#define SHDLC_CONTROL_HEAD_I2 0xa0
#define SHDLC_CONTROL_HEAD_S 0xc0
#define SHDLC_CONTROL_HEAD_U 0xe0
#define SHDLC_CONTROL_NS_MASK 0x38
#define SHDLC_CONTROL_NR_MASK 0x07
#define SHDLC_CONTROL_TYPE_MASK 0x18
#define SHDLC_CONTROL_M_MASK 0x1f
enum sframe_type {
S_FRAME_RR = 0x00,
S_FRAME_REJ = 0x01,
S_FRAME_RNR = 0x02,
S_FRAME_SREJ = 0x03
};
enum uframe_modifier {
U_FRAME_UA = 0x06,
U_FRAME_RSET = 0x19
};
#define SHDLC_CONNECT_VALUE_MS 5
#define SHDLC_T1_VALUE_MS(w) ((5 * w) / 4)
#define SHDLC_T2_VALUE_MS 300
#define SHDLC_DUMP_SKB(info, skb) \
do { \
pr_debug("%s:\n", info); \
print_hex_dump(KERN_DEBUG, "shdlc: ", DUMP_PREFIX_OFFSET, \
16, 1, skb->data, skb->len, 0); \
} while (0)
/* checks x < y <= z modulo 8 */
static bool llc_shdlc_x_lt_y_lteq_z(int x, int y, int z)
{
if (x < z)
return ((x < y) && (y <= z)) ? true : false;
else
return ((y > x) || (y <= z)) ? true : false;
}
Annotation
- Immediate include surface: `linux/types.h`, `linux/sched.h`, `linux/wait.h`, `linux/slab.h`, `linux/skbuff.h`, `llc.h`.
- Detected declarations: `struct llc_shdlc`, `enum shdlc_state`, `enum sframe_type`, `enum uframe_modifier`, `function llc_shdlc_x_lt_y_lteq_z`, `function llc_shdlc_x_lteq_y_lt_z`, `function llc_shdlc_send_s_frame`, `function llc_shdlc_send_u_frame`, `function llc_shdlc_reset_t2`, `function llc_shdlc_rcv_i_frame`.
- Atlas domain: Networking Core / Sockets, Protocols, Packet Path, And Network Policy.
- Implementation status: source implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.