Home | History | Annotate | Download | only in int
      1 /******************************************************************************
      2  *
      3  *  Copyright (C) 2010-2013 Broadcom Corporation
      4  *
      5  *  Licensed under the Apache License, Version 2.0 (the "License");
      6  *  you may not use this file except in compliance with the License.
      7  *  You may obtain a copy of the License at:
      8  *
      9  *  http://www.apache.org/licenses/LICENSE-2.0
     10  *
     11  *  Unless required by applicable law or agreed to in writing, software
     12  *  distributed under the License is distributed on an "AS IS" BASIS,
     13  *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     14  *  See the License for the specific language governing permissions and
     15  *  limitations under the License.
     16  *
     17  ******************************************************************************/
     18 
     19 
     20 /******************************************************************************
     21  *
     22  *  This is the private interface file for the NFA P2P.
     23  *
     24  ******************************************************************************/
     25 #ifndef NFA_P2P_INT_H
     26 #define NFA_P2P_INT_H
     27 
     28 #if (defined (NFA_P2P_INCLUDED) && (NFA_P2P_INCLUDED==TRUE))
     29 #include "nfa_p2p_api.h"
     30 #include "nfa_dm_int.h"
     31 
     32 /*****************************************************************************
     33 **  Constants and data types
     34 *****************************************************************************/
     35 #define NFA_P2P_DEBUG   BT_TRACE_VERBOSE
     36 
     37 /* NFA P2P LLCP link state */
     38 enum
     39 {
     40     NFA_P2P_LLCP_STATE_IDLE,
     41     NFA_P2P_LLCP_STATE_LISTENING,
     42     NFA_P2P_LLCP_STATE_ACTIVATED,
     43 
     44     NFA_P2P_LLCP_STATE_MAX
     45 };
     46 
     47 typedef UINT8 tNFA_P2P_LLCP_STATE;
     48 
     49 /* NFA P2P events */
     50 enum
     51 {
     52     NFA_P2P_API_REG_SERVER_EVT  = NFA_SYS_EVT_START (NFA_ID_P2P),
     53     NFA_P2P_API_REG_CLIENT_EVT,
     54     NFA_P2P_API_DEREG_EVT,
     55     NFA_P2P_API_ACCEPT_CONN_EVT,
     56     NFA_P2P_API_REJECT_CONN_EVT,
     57     NFA_P2P_API_DISCONNECT_EVT,
     58     NFA_P2P_API_CONNECT_EVT,
     59     NFA_P2P_API_SEND_UI_EVT,
     60     NFA_P2P_API_SEND_DATA_EVT,
     61     NFA_P2P_API_SET_LOCAL_BUSY_EVT,
     62     NFA_P2P_API_GET_LINK_INFO_EVT,
     63     NFA_P2P_API_GET_REMOTE_SAP_EVT,
     64     NFA_P2P_API_SET_LLCP_CFG_EVT,
     65     NFA_P2P_INT_RESTART_RF_DISC_EVT,
     66 
     67     NFA_P2P_LAST_EVT
     68 };
     69 
     70 /* data type for NFA_P2P_API_REG_SERVER_EVT */
     71 typedef struct
     72 {
     73     BT_HDR              hdr;
     74     UINT8               server_sap;
     75     tNFA_P2P_LINK_TYPE  link_type;
     76     char                service_name[LLCP_MAX_SN_LEN + 1];
     77     tNFA_P2P_CBACK     *p_cback;
     78 } tNFA_P2P_API_REG_SERVER;
     79 
     80 /* data type for NFA_P2P_API_REG_CLIENT_EVT */
     81 typedef struct
     82 {
     83     BT_HDR              hdr;
     84     tNFA_P2P_LINK_TYPE  link_type;
     85     tNFA_P2P_CBACK     *p_cback;
     86 } tNFA_P2P_API_REG_CLIENT;
     87 
     88 /* data type for NFA_P2P_API_DEREG_EVT */
     89 typedef struct
     90 {
     91     BT_HDR              hdr;
     92     tNFA_HANDLE         handle;
     93 } tNFA_P2P_API_DEREG;
     94 
     95 /* data type for NFA_P2P_API_ACCEPT_CONN_EVT */
     96 typedef struct
     97 {
     98     BT_HDR              hdr;
     99     tNFA_HANDLE         conn_handle;
    100     UINT16              miu;
    101     UINT8               rw;
    102 } tNFA_P2P_API_ACCEPT_CONN;
    103 
    104 /* data type for NFA_P2P_API_REJECT_CONN_EVT */
    105 typedef struct
    106 {
    107     BT_HDR              hdr;
    108     tNFA_HANDLE         conn_handle;
    109 } tNFA_P2P_API_REJECT_CONN;
    110 
    111 /* data type for NFA_P2P_API_DISCONNECT_EVT */
    112 typedef struct
    113 {
    114     BT_HDR              hdr;
    115     tNFA_HANDLE         conn_handle;
    116     BOOLEAN             flush;
    117 } tNFA_P2P_API_DISCONNECT;
    118 
    119 /* data type for NFA_P2P_API_CONNECT_EVT */
    120 typedef struct
    121 {
    122     BT_HDR              hdr;
    123     tNFA_HANDLE         client_handle;
    124     char                service_name[LLCP_MAX_SN_LEN + 1];
    125     UINT8               dsap;
    126     UINT16              miu;
    127     UINT8               rw;
    128 } tNFA_P2P_API_CONNECT;
    129 
    130 /* data type for NFA_P2P_API_SEND_UI_EVT */
    131 typedef struct
    132 {
    133     BT_HDR              hdr;
    134     tNFA_HANDLE         handle;
    135     UINT8               dsap;
    136     BT_HDR             *p_msg;
    137 } tNFA_P2P_API_SEND_UI;
    138 
    139 /* data type for NFA_P2P_API_SEND_DATA_EVT */
    140 typedef struct
    141 {
    142     BT_HDR              hdr;
    143     tNFA_HANDLE         conn_handle;
    144     BT_HDR             *p_msg;
    145 } tNFA_P2P_API_SEND_DATA;
    146 
    147 /* data type for NFA_P2P_API_SET_LOCAL_BUSY_EVT */
    148 typedef struct
    149 {
    150     BT_HDR              hdr;
    151     tNFA_HANDLE         conn_handle;
    152     BOOLEAN             is_busy;
    153 } tNFA_P2P_API_SET_LOCAL_BUSY;
    154 
    155 /* data type for NFA_P2P_API_GET_LINK_INFO_EVT */
    156 typedef struct
    157 {
    158     BT_HDR              hdr;
    159     tNFA_HANDLE         handle;
    160 } tNFA_P2P_API_GET_LINK_INFO;
    161 
    162 /* data type for NFA_P2P_API_GET_REMOTE_SAP_EVT */
    163 typedef struct
    164 {
    165     BT_HDR              hdr;
    166     tNFA_HANDLE         handle;
    167     char                service_name[LLCP_MAX_SN_LEN + 1];
    168 } tNFA_P2P_API_GET_REMOTE_SAP;
    169 
    170 /* data type for NFA_P2P_API_SET_LLCP_CFG_EVT */
    171 typedef struct
    172 {
    173     BT_HDR              hdr;
    174     UINT16              link_miu;
    175     UINT8               opt;
    176     UINT8               wt;
    177     UINT16              link_timeout;
    178     UINT16              inact_timeout_init;
    179     UINT16              inact_timeout_target;
    180     UINT16              symm_delay;
    181     UINT16              data_link_timeout;
    182     UINT16              delay_first_pdu_timeout;
    183 } tNFA_P2P_API_SET_LLCP_CFG;
    184 
    185 /* union of all event data types */
    186 typedef union
    187 {
    188     BT_HDR                      hdr;
    189     tNFA_P2P_API_REG_SERVER     api_reg_server;
    190     tNFA_P2P_API_REG_CLIENT     api_reg_client;
    191     tNFA_P2P_API_DEREG          api_dereg;
    192     tNFA_P2P_API_ACCEPT_CONN    api_accept;
    193     tNFA_P2P_API_REJECT_CONN    api_reject;
    194     tNFA_P2P_API_DISCONNECT     api_disconnect;
    195     tNFA_P2P_API_CONNECT        api_connect;
    196     tNFA_P2P_API_SEND_UI        api_send_ui;
    197     tNFA_P2P_API_SEND_DATA      api_send_data;
    198     tNFA_P2P_API_SET_LOCAL_BUSY api_local_busy;
    199     tNFA_P2P_API_GET_LINK_INFO  api_link_info;
    200     tNFA_P2P_API_GET_REMOTE_SAP api_remote_sap;
    201     tNFA_P2P_API_SET_LLCP_CFG   api_set_llcp_cfg;
    202 } tNFA_P2P_MSG;
    203 
    204 /*****************************************************************************
    205 **  control block
    206 *****************************************************************************/
    207 #define NFA_P2P_HANDLE_FLAG_CONN             0x80   /* Bit flag for connection handle           */
    208 
    209 /* NFA P2P Connection block */
    210 #define NFA_P2P_CONN_FLAG_IN_USE             0x01   /* Connection control block is used         */
    211 #define NFA_P2P_CONN_FLAG_REMOTE_RW_ZERO     0x02   /* Remote set RW to 0 (flow off)            */
    212 #define NFA_P2P_CONN_FLAG_CONGESTED          0x04   /* data link connection is congested        */
    213 
    214 typedef struct
    215 {
    216     UINT8               flags;                      /* internal flags for data link connection  */
    217     UINT8               local_sap;                  /* local SAP of data link connection        */
    218     UINT8               remote_sap;                 /* remote SAP of data link connection       */
    219     UINT16              remote_miu;                 /* MIU of remote end point                  */
    220     UINT8               num_pending_i_pdu;          /* number of tx I PDU not processed by NFA  */
    221 } tNFA_P2P_CONN_CB;
    222 
    223 /* NFA P2P SAP control block */
    224 #define NFA_P2P_SAP_FLAG_SERVER             0x01    /* registered server                        */
    225 #define NFA_P2P_SAP_FLAG_CLIENT             0x02    /* registered client                        */
    226 #define NFA_P2P_SAP_FLAG_LLINK_CONGESTED    0x04    /* logical link connection is congested     */
    227 
    228 typedef struct
    229 {
    230     UINT8              flags;                       /* internal flags for local SAP             */
    231     tNFA_P2P_CBACK     *p_cback;                    /* callback function for local SAP          */
    232     UINT8              num_pending_ui_pdu;          /* number of tx UI PDU not processed by NFA */
    233 } tNFA_P2P_SAP_CB;
    234 
    235 /* NFA P2P SDP control block */
    236 typedef struct
    237 {
    238     UINT8            tid;                           /* transaction ID */
    239     UINT8            local_sap;
    240 } tNFA_P2P_SDP_CB;
    241 
    242 #define NFA_P2P_NUM_SAP         64
    243 
    244 /* NFA P2P control block */
    245 typedef struct
    246 {
    247     tNFA_HANDLE         dm_disc_handle;
    248 
    249     tNFA_DM_RF_DISC_STATE rf_disc_state;
    250     tNFA_P2P_LLCP_STATE llcp_state;
    251     BOOLEAN             is_initiator;
    252     BOOLEAN             is_active_mode;
    253     UINT16              local_link_miu;
    254     UINT16              remote_link_miu;
    255 
    256     tNFA_TECHNOLOGY_MASK listen_tech_mask;          /* for P2P listening */
    257     tNFA_TECHNOLOGY_MASK listen_tech_mask_to_restore;/* to retry without active listen mode */
    258     TIMER_LIST_ENT      active_listen_restore_timer; /* timer to restore active listen mode */
    259     BOOLEAN             is_p2p_listening;
    260     BOOLEAN             is_cho_listening;
    261     BOOLEAN             is_snep_listening;
    262 
    263     tNFA_P2P_SAP_CB     sap_cb[NFA_P2P_NUM_SAP];
    264     tNFA_P2P_CONN_CB    conn_cb[LLCP_MAX_DATA_LINK];
    265     tNFA_P2P_SDP_CB     sdp_cb[LLCP_MAX_SDP_TRANSAC];
    266 
    267     UINT8               total_pending_ui_pdu;       /* total number of tx UI PDU not processed by NFA */
    268     UINT8               total_pending_i_pdu;        /* total number of tx I PDU not processed by NFA */
    269 
    270     UINT8               trace_level;
    271 } tNFA_P2P_CB;
    272 
    273 /*****************************************************************************
    274 **  External variables
    275 *****************************************************************************/
    276 
    277 /* NFA P2P control block */
    278 #if NFA_DYNAMIC_MEMORY == FALSE
    279 extern tNFA_P2P_CB nfa_p2p_cb;
    280 #else
    281 extern tNFA_P2P_CB *nfa_p2p_cb_ptr;
    282 #define nfa_p2p_cb (*nfa_p2p_cb_ptr)
    283 #endif
    284 
    285 /*****************************************************************************
    286 **  External functions
    287 *****************************************************************************/
    288 /*
    289 **  nfa_p2p_main.c
    290 */
    291 void nfa_p2p_init (void);
    292 void nfa_p2p_update_listen_tech (tNFA_TECHNOLOGY_MASK tech_mask);
    293 void nfa_p2p_enable_listening (tNFA_SYS_ID sys_id, BOOLEAN update_wks);
    294 void nfa_p2p_disable_listening (tNFA_SYS_ID sys_id, BOOLEAN update_wks);
    295 void nfa_p2p_activate_llcp (tNFC_DISCOVER *p_data);
    296 void nfa_p2p_deactivate_llcp (void);
    297 void nfa_p2p_set_config (tNFA_DM_DISC_TECH_PROTO_MASK disc_mask);
    298 
    299 /*
    300 **  nfa_p2p_act.c
    301 */
    302 void nfa_p2p_proc_llcp_data_ind (tLLCP_SAP_CBACK_DATA  *p_data);
    303 void nfa_p2p_proc_llcp_connect_ind (tLLCP_SAP_CBACK_DATA  *p_data);
    304 void nfa_p2p_proc_llcp_connect_resp (tLLCP_SAP_CBACK_DATA  *p_data);
    305 void nfa_p2p_proc_llcp_disconnect_ind (tLLCP_SAP_CBACK_DATA  *p_data);
    306 void nfa_p2p_proc_llcp_disconnect_resp (tLLCP_SAP_CBACK_DATA  *p_data);
    307 void nfa_p2p_proc_llcp_congestion (tLLCP_SAP_CBACK_DATA  *p_data);
    308 void nfa_p2p_proc_llcp_link_status (tLLCP_SAP_CBACK_DATA  *p_data);
    309 
    310 BOOLEAN nfa_p2p_start_sdp (char *p_service_name, UINT8 local_sap);
    311 
    312 BOOLEAN nfa_p2p_reg_server (tNFA_P2P_MSG *p_msg);
    313 BOOLEAN nfa_p2p_reg_client (tNFA_P2P_MSG *p_msg);
    314 BOOLEAN nfa_p2p_dereg (tNFA_P2P_MSG *p_msg);
    315 BOOLEAN nfa_p2p_accept_connection (tNFA_P2P_MSG *p_msg);
    316 BOOLEAN nfa_p2p_reject_connection (tNFA_P2P_MSG *p_msg);
    317 BOOLEAN nfa_p2p_disconnect (tNFA_P2P_MSG *p_msg);
    318 BOOLEAN nfa_p2p_create_data_link_connection (tNFA_P2P_MSG *p_msg);
    319 BOOLEAN nfa_p2p_send_ui (tNFA_P2P_MSG *p_msg);
    320 BOOLEAN nfa_p2p_send_data (tNFA_P2P_MSG *p_msg);
    321 BOOLEAN nfa_p2p_set_local_busy (tNFA_P2P_MSG *p_msg);
    322 BOOLEAN nfa_p2p_get_link_info (tNFA_P2P_MSG *p_msg);
    323 BOOLEAN nfa_p2p_get_remote_sap (tNFA_P2P_MSG *p_msg);
    324 BOOLEAN nfa_p2p_set_llcp_cfg (tNFA_P2P_MSG *p_msg);
    325 BOOLEAN nfa_p2p_restart_rf_discovery (tNFA_P2P_MSG *p_msg);
    326 
    327 #if (BT_TRACE_VERBOSE == TRUE)
    328 char *nfa_p2p_evt_code (UINT16 evt_code);
    329 #endif
    330 
    331 #else
    332 
    333 #define nfa_p2p_init ()
    334 #define nfa_p2p_activate_llcp (a) {};
    335 #define nfa_p2p_deactivate_llcp ()
    336 #define nfa_p2p_set_config ()
    337 
    338 #endif /* (defined (NFA_P2P_INCLUDED) && (NFA_P2P_INCLUDED==TRUE)) */
    339 #endif /* NFA_P2P_INT_H */
    340