Lines Matching defs:p_port
65 tPORT *p_port = &rfc_cb.port.port[0];
73 p_port = &rfc_cb.port.port[yy];
74 if (!p_port->in_use)
76 memset (p_port, 0, sizeof (tPORT));
78 p_port->in_use = TRUE;
79 p_port->inx = yy + 1;
81 p_port->dlci = dlci;
82 memcpy (p_port->bd_addr, bd_addr, BD_ADDR_LEN);
85 port_set_defaults (p_port);
88 RFCOMM_TRACE_DEBUG("rfc_cb.port.port[%d]:%p allocated, last_port:%d", yy, p_port, rfc_cb.rfc.last_port);
91 return (p_port);
108 void port_set_defaults (tPORT *p_port)
110 p_port->ev_mask = 0;
111 p_port->p_callback = NULL;
112 p_port->port_ctrl = 0;
113 p_port->error = 0;
114 p_port->line_status = 0;
115 p_port->rx_flag_ev_pending = FALSE;
116 p_port->peer_mtu = RFCOMM_DEFAULT_MTU;
118 p_port->user_port_pars = default_port_pars;
119 p_port->peer_port_pars = default_port_pars;
121 p_port->credit_tx = 0;
122 p_port->credit_rx = 0;
123 /* p_port->credit_rx_max = PORT_CREDIT_RX_MAX; Determined later */
124 /* p_port->credit_rx_low = PORT_CREDIT_RX_LOW; Determined later */
126 memset (&p_port->local_ctrl, 0, sizeof (p_port->local_ctrl));
127 memset (&p_port->peer_ctrl, 0, sizeof (p_port->peer_ctrl));
128 memset (&p_port->rx, 0, sizeof (p_port->rx));
129 memset (&p_port->tx, 0, sizeof (p_port->tx));
143 void port_select_mtu (tPORT *p_port)
148 if (p_port->mtu == 0)
151 packet_size = btm_get_max_packet_size (p_port->bd_addr);
156 p_port->mtu = RFCOMM_DEFAULT_MTU;
170 p_port->mtu = ((L2CAP_MTU_SIZE + L2CAP_PKT_OVERHEAD) / packet_size * packet_size) - RFCOMM_DATA_OVERHEAD - L2CAP_PKT_OVERHEAD;
171 RFCOMM_TRACE_DEBUG ("port_select_mtu selected %d based on connection speed", p_port->mtu);
175 p_port->mtu = L2CAP_MTU_SIZE - RFCOMM_DATA_OVERHEAD;
176 RFCOMM_TRACE_DEBUG ("port_select_mtu selected %d based on l2cap PDU size", p_port->mtu);
182 RFCOMM_TRACE_DEBUG ("port_select_mtu application selected %d", p_port->mtu);
184 p_port->credit_rx_max = (PORT_RX_HIGH_WM / p_port->mtu);
185 if( p_port->credit_rx_max > PORT_RX_BUF_HIGH_WM )
186 p_port->credit_rx_max = PORT_RX_BUF_HIGH_WM;
187 p_port->credit_rx_low = (PORT_RX_LOW_WM / p_port->mtu);
188 if( p_port->credit_rx_low > PORT_RX_BUF_LOW_WM )
189 p_port->credit_rx_low = PORT_RX_BUF_LOW_WM;
190 p_port->rx_buf_critical = (PORT_RX_CRITICAL_WM / p_port->mtu);
191 if( p_port->rx_buf_critical > PORT_RX_BUF_CRITICAL_WM )
192 p_port->rx_buf_critical = PORT_RX_BUF_CRITICAL_WM;
194 p_port->credit_rx_max, p_port->credit_rx_low, p_port->rx_buf_critical);
207 void port_release_port (tPORT *p_port)
215 RFCOMM_TRACE_DEBUG("port_release_port, p_port:%p", p_port);
216 while ((p_buf = (BT_HDR *)GKI_dequeue (&p_port->rx.queue)) != NULL)
219 p_port->rx.queue_size = 0;
221 while ((p_buf = (BT_HDR *)GKI_dequeue (&p_port->tx.queue)) != NULL)
224 p_port->tx.queue_size = 0;
228 p_port->state = PORT_STATE_CLOSED;
230 if (p_port->rfc.state == RFC_STATE_CLOSED)
233 if (p_port->rfc.p_mcb)
235 p_port->rfc.p_mcb->port_inx[p_port->dlci] = 0;
238 rfc_check_mcb_active (p_port->rfc.p_mcb);
240 rfc_port_timer_stop (p_port);
241 RFCOMM_TRACE_DEBUG ("port_release_port:p_port->keep_port_handle:%d", p_port->keep_port_handle);
242 if( p_port->keep_port_handle )
244 RFCOMM_TRACE_DEBUG ("port_release_port:Initialize handle:%d", p_port->inx);
246 mask = p_port->ev_mask;
247 p_port_cb = p_port->p_callback;
248 user_port_pars = p_port->user_port_pars;
250 port_set_defaults(p_port);
252 p_port->ev_mask = mask;
253 p_port->p_callback = p_port_cb;
254 p_port->user_port_pars = user_port_pars;
255 p_port->mtu = p_port->keep_mtu;
257 p_port->state = PORT_STATE_OPENING;
258 p_port->rfc.p_mcb = NULL;
259 if(p_port->is_server)
260 p_port->dlci &= 0xfe;
262 p_port->local_ctrl.modem_signal = p_port->default_signal_state;
263 memcpy (p_port->bd_addr, BT_BD_ANY, BD_ADDR_LEN);
267 RFCOMM_TRACE_DEBUG ("port_release_port:Clean-up handle:%d", p_port->inx);
268 memset (p_port, 0, sizeof (tPORT));
350 tPORT *p_port;
354 p_port = &rfc_cb.port.port[i];
356 if (p_port->in_use && (p_port->rfc.p_mcb == NULL))
358 if (p_port->dlci == dlci)
360 return (p_port);
362 else if ((dlci & 0x01) && (p_port->dlci == (dlci - 1)))
364 p_port->dlci++;
365 return (p_port);
385 tPORT *p_port;
389 p_port = &rfc_cb.port.port[i];
390 if (p_port->in_use
391 && (p_port->dlci == dlci)
392 && !memcmp (p_port->bd_addr, bd_addr, BD_ADDR_LEN))
394 return (p_port);
412 UINT32 port_flow_control_user (tPORT *p_port)
419 BOOLEAN fc = p_port->tx.peer_fc
420 || !p_port->rfc.p_mcb
421 || !p_port->rfc.p_mcb->peer_ready
422 || (p_port->tx.queue_size > PORT_TX_HIGH_WM)
423 || (p_port->tx.queue.count > PORT_TX_BUF_HIGH_WM);
425 if (p_port->tx.user_fc == fc)
428 p_port->tx.user_fc = fc;
448 UINT32 port_get_signal_changes (tPORT *p_port, UINT8 old_signals, UINT8 signal)
480 return (p_port->ev_mask & events);
494 void port_flow_control_peer(tPORT *p_port, BOOLEAN enable, UINT16 count)
496 if (!p_port
500 if (p_port->rfc.p_mcb->flow == PORT_FC_CREDIT)
506 if (count > p_port->credit_rx)
508 p_port->credit_rx = 0;
512 p_port->credit_rx -= count;
518 if ((p_port->credit_rx <= p_port->credit_rx_low)
519 && !p_port->rx.user_fc
520 && (p_port->credit_rx_max > p_port->credit_rx))
522 rfc_send_credit(p_port->rfc.p_mcb, p_port->dlci,
523 (UINT8) (p_port->credit_rx_max - p_port->credit_rx));
525 p_port->credit_rx = p_port->credit_rx_max;
527 p_port->rx.peer_fc = FALSE;
534 if (p_port->p_data_callback || p_port->p_data_co_callback)
536 p_port->rx.peer_fc = TRUE;
539 else if (p_port->rx.queue.count >= p_port->credit_rx_max)
541 p_port->rx.peer_fc = TRUE;
553 if (p_port->rx.peer_fc
554 && (p_port->rx.queue_size < PORT_RX_LOW_WM)
555 && (p_port->rx.queue.count < PORT_RX_BUF_LOW_WM))
557 p_port->rx.peer_fc = FALSE;
560 if (!p_port->rx.user_fc)
561 RFCOMM_FlowReq (p_port->rfc.p_mcb, p_port->dlci, TRUE);
568 if (p_port->p_data_callback || p_port->p_data_co_callback)
570 p_port->rx.peer_fc = TRUE;
571 RFCOMM_FlowReq (p_port->rfc.p_mcb, p_port->dlci, FALSE);
575 else if ( ((p_port->rx.queue_size > PORT_RX_HIGH_WM)
576 || (p_port->rx.queue.count > PORT_RX_BUF_HIGH_WM))
577 && !p_port->rx.peer_fc)
581 p_port->rx.peer_fc = TRUE;
582 RFCOMM_FlowReq (p_port->rfc.p_mcb, p_port->dlci, FALSE);