blob: 4828a8fe9038d02da66e21a27027b8523d4efae3 [file] [log] [blame]
Harald Welte9b455bf2010-03-14 15:45:01 +08001#ifndef _GPRS_LLC_H
2#define _GPRS_LLC_H
3
Harald Welteeaa614c2010-05-02 11:26:34 +02004#include <stdint.h>
5
Harald Welte9b455bf2010-03-14 15:45:01 +08006/* Section 4.7 LLC Layer Structure */
7enum gprs_llc_sapi {
8 GPRS_SAPI_GMM = 1,
9 GPRS_SAPI_TOM2 = 2,
10 GPRS_SAPI_SNDCP3 = 3,
11 GPRS_SAPI_SNDCP5 = 5,
12 GPRS_SAPI_SMS = 7,
13 GPRS_SAPI_TOM8 = 8,
14 GPRS_SAPI_SNDCP9 = 9,
15 GPRS_SAPI_SNDCP11 = 11,
16};
17
Harald Welte10997d02010-05-03 12:28:12 +020018/* Section 6.4 Commands and Responses */
19enum gprs_llc_u_cmd {
20 GPRS_LLC_U_DM_RESP = 0x01,
21 GPRS_LLC_U_DISC_CMD = 0x04,
22 GPRS_LLC_U_UA_RESP = 0x06,
23 GPRS_LLC_U_SABM_CMD = 0x07,
24 GPRS_LLC_U_FRMR_RESP = 0x08,
25 GPRS_LLC_U_XID = 0x0b,
26 GPRS_LLC_U_NULL_CMD = 0x00,
27};
Harald Welte9b455bf2010-03-14 15:45:01 +080028
Harald Welte1ae09c72010-05-13 19:22:55 +020029/* TS 04.64 Section 7.1.2 Table 7: LLC layer primitives (GMM/SNDCP/SMS/TOM) */
30/* TS 04.65 Section 5.1.2 Table 2: Service primitives used by SNDCP */
31enum gprs_llc_primitive {
32 /* GMM <-> LLME */
33 LLGMM_ASSIGN_REQ, /* GMM tells us new TLLI: TLLI old, TLLI new, Kc, CiphAlg */
34 LLGMM_RESET_REQ, /* GMM tells us to perform XID negotiation: TLLI */
35 LLGMM_RESET_CNF, /* LLC informs GMM that XID has completed: TLLI */
36 LLGMM_SUSPEND_REQ, /* GMM tells us MS has suspended: TLLI, Page */
37 LLGMM_RESUME_REQ, /* GMM tells us MS has resumed: TLLI */
38 LLGMM_PAGE_IND, /* LLC asks GMM to page MS: TLLI */
39 LLGMM_IOV_REQ, /* GMM tells us to perform XID: TLLI */
40 LLGMM_STATUS_IND, /* LLC informs GMM about error: TLLI, Cause */
41 /* LLE <-> (GMM/SNDCP/SMS/TOM) */
42 LL_RESET_IND, /* TLLI */
43 LL_ESTABLISH_REQ, /* TLLI, XID Req */
44 LL_ESTABLISH_IND, /* TLLI, XID Req, N201-I, N201-U */
45 LL_ESTABLISH_RESP, /* TLLI, XID Negotiated */
46 LL_ESTABLISH_CONF, /* TLLI, XID Neg, N201-i, N201-U */
47 LL_RELEASE_REQ, /* TLLI, Local */
48 LL_RELEASE_IND, /* TLLI, Cause */
49 LL_RELEASE_CONF, /* TLLI */
50 LL_XID_REQ, /* TLLI, XID Requested */
51 LL_XID_IND, /* TLLI, XID Req, N201-I, N201-U */
52 LL_XID_RESP, /* TLLI, XID Negotiated */
53 LL_XID_CONF, /* TLLI, XID Neg, N201-I, N201-U */
54 LL_DATA_REQ, /* TLLI, SN-PDU, Ref, QoS, Radio Prio, Ciph */
55 LL_DATA_IND, /* TLLI, SN-PDU */
56 LL_DATA_CONF, /* TLLI, Ref */
57 LL_UNITDATA_REQ, /* TLLI, SN-PDU, Ref, QoS, Radio Prio, Ciph */
58 LL_UNITDATA_IND, /* TLLI, SN-PDU */
59 LL_STATUS_IND, /* TLLI, Cause */
60};
61
Harald Welte2e918a82010-05-18 12:20:12 +020062/* Section 4.5.2 Logical Link States + Annex C.2 */
63enum gprs_llc_ll_state {
64 GPRS_LLS_UNASSIGNED = 1, /* No TLLI yet */
65 GPRS_LLS_ASSIGNED_ADM = 2, /* TLLI assigned */
66 GPRS_LLS_LOCAL_EST = 3, /* Local Establishment */
67 GPRS_LLS_REMOTE_EST = 4, /* Remote Establishment */
68 GPRS_LLS_ABM = 5,
69 GPRS_LLS_LOCAL_REL = 6, /* Local Release */
70 GPRS_LLS_TIMER_REC = 7, /* Timer Recovery */
71};
72
73/* Section 4.7.1: Logical Link Entity: One per DLCI (TLLI + SAPI) */
74struct gprs_llc_lle {
75 struct llist_head list;
76
77 struct timer_list t200;
78 struct timer_list t201; /* wait for acknowledgement */
79
80 enum gprs_llc_ll_state state;
81
82 uint32_t tlli;
83 uint32_t sapi;
84
Harald Welte6bdee6a2010-05-30 21:51:58 +020085 uint16_t v_sent;
86 uint16_t v_ack;
87 uint16_t v_recv;
88
89 uint16_t vu_send;
90 uint16_t vu_recv;
Harald Welte2e918a82010-05-18 12:20:12 +020091
92 unsigned int n200;
93 unsigned int retrans_ctr;
94
95 /* over which BSSGP BTS ctx do we need to transmit */
96 uint16_t bvci;
97 uint16_t nsei;
98};
99
100extern struct llist_head gprs_llc_lles;
101
Harald Welte1ae09c72010-05-13 19:22:55 +0200102/* BSSGP-UL-UNITDATA.ind */
Harald Welte9b455bf2010-03-14 15:45:01 +0800103int gprs_llc_rcvmsg(struct msgb *msg, struct tlv_parsed *tv);
Harald Welte1ae09c72010-05-13 19:22:55 +0200104
105/* LL-UNITDATA.req */
Harald Welteeaa614c2010-05-02 11:26:34 +0200106int gprs_llc_tx_ui(struct msgb *msg, uint8_t sapi, int command);
Harald Welte9b455bf2010-03-14 15:45:01 +0800107
Harald Welte2e918a82010-05-18 12:20:12 +0200108int gprs_llc_vty_init(void);
109
Harald Welte9b455bf2010-03-14 15:45:01 +0800110#endif