Lines Matching refs:conn
49 static int rxrpc_get_client_connection_id(struct rxrpc_connection *conn, in rxrpc_get_client_connection_id() argument
52 struct rxrpc_net *rxnet = conn->params.local->rxnet; in rxrpc_get_client_connection_id()
60 id = idr_alloc_cyclic(&rxrpc_client_conn_ids, conn, in rxrpc_get_client_connection_id()
68 conn->proto.epoch = rxnet->epoch; in rxrpc_get_client_connection_id()
69 conn->proto.cid = id << RXRPC_CIDSHIFT; in rxrpc_get_client_connection_id()
70 set_bit(RXRPC_CONN_HAS_IDR, &conn->flags); in rxrpc_get_client_connection_id()
71 _leave(" [CID %x]", conn->proto.cid); in rxrpc_get_client_connection_id()
84 static void rxrpc_put_client_connection_id(struct rxrpc_connection *conn) in rxrpc_put_client_connection_id() argument
86 if (test_bit(RXRPC_CONN_HAS_IDR, &conn->flags)) { in rxrpc_put_client_connection_id()
89 conn->proto.cid >> RXRPC_CIDSHIFT); in rxrpc_put_client_connection_id()
99 struct rxrpc_connection *conn; in rxrpc_destroy_client_conn_ids() local
103 idr_for_each_entry(&rxrpc_client_conn_ids, conn, id) { in rxrpc_destroy_client_conn_ids()
105 conn, refcount_read(&conn->ref)); in rxrpc_destroy_client_conn_ids()
163 struct rxrpc_connection *conn; in rxrpc_alloc_client_connection() local
169 conn = rxrpc_alloc_connection(gfp); in rxrpc_alloc_client_connection()
170 if (!conn) { in rxrpc_alloc_client_connection()
175 refcount_set(&conn->ref, 1); in rxrpc_alloc_client_connection()
176 conn->bundle = bundle; in rxrpc_alloc_client_connection()
177 conn->params = bundle->params; in rxrpc_alloc_client_connection()
178 conn->out_clientflag = RXRPC_CLIENT_INITIATED; in rxrpc_alloc_client_connection()
179 conn->state = RXRPC_CONN_CLIENT; in rxrpc_alloc_client_connection()
180 conn->service_id = conn->params.service_id; in rxrpc_alloc_client_connection()
182 ret = rxrpc_get_client_connection_id(conn, gfp); in rxrpc_alloc_client_connection()
186 ret = rxrpc_init_client_conn_security(conn); in rxrpc_alloc_client_connection()
192 list_add_tail(&conn->proc_link, &rxnet->conn_proc_list); in rxrpc_alloc_client_connection()
196 rxrpc_get_peer(conn->params.peer); in rxrpc_alloc_client_connection()
197 rxrpc_get_local(conn->params.local); in rxrpc_alloc_client_connection()
198 key_get(conn->params.key); in rxrpc_alloc_client_connection()
200 trace_rxrpc_conn(conn->debug_id, rxrpc_conn_new_client, in rxrpc_alloc_client_connection()
201 refcount_read(&conn->ref), in rxrpc_alloc_client_connection()
205 trace_rxrpc_client(conn, -1, rxrpc_client_alloc); in rxrpc_alloc_client_connection()
206 _leave(" = %p", conn); in rxrpc_alloc_client_connection()
207 return conn; in rxrpc_alloc_client_connection()
210 rxrpc_put_client_connection_id(conn); in rxrpc_alloc_client_connection()
212 kfree(conn); in rxrpc_alloc_client_connection()
220 static bool rxrpc_may_reuse_conn(struct rxrpc_connection *conn) in rxrpc_may_reuse_conn() argument
225 if (!conn) in rxrpc_may_reuse_conn()
228 rxnet = conn->params.local->rxnet; in rxrpc_may_reuse_conn()
229 if (test_bit(RXRPC_CONN_DONT_REUSE, &conn->flags)) in rxrpc_may_reuse_conn()
232 if (conn->state != RXRPC_CONN_CLIENT || in rxrpc_may_reuse_conn()
233 conn->proto.epoch != rxnet->epoch) in rxrpc_may_reuse_conn()
243 id = conn->proto.cid >> RXRPC_CIDSHIFT; in rxrpc_may_reuse_conn()
254 set_bit(RXRPC_CONN_DONT_REUSE, &conn->flags); in rxrpc_may_reuse_conn()
508 static void rxrpc_activate_one_channel(struct rxrpc_connection *conn, in rxrpc_activate_one_channel() argument
511 struct rxrpc_channel *chan = &conn->channels[channel]; in rxrpc_activate_one_channel()
512 struct rxrpc_bundle *bundle = conn->bundle; in rxrpc_activate_one_channel()
517 _enter("C=%x,%u", conn->debug_id, channel); in rxrpc_activate_one_channel()
519 trace_rxrpc_client(conn, channel, rxrpc_client_chan_activate); in rxrpc_activate_one_channel()
524 clear_bit(RXRPC_CONN_FINAL_ACK_0 + channel, &conn->flags); in rxrpc_activate_one_channel()
525 clear_bit(conn->bundle_shift + channel, &bundle->avail_chans); in rxrpc_activate_one_channel()
529 call->peer = rxrpc_get_peer(conn->params.peer); in rxrpc_activate_one_channel()
530 call->conn = rxrpc_get_connection(conn); in rxrpc_activate_one_channel()
531 call->cid = conn->proto.cid | channel; in rxrpc_activate_one_channel()
533 call->security = conn->security; in rxrpc_activate_one_channel()
534 call->security_ix = conn->security_ix; in rxrpc_activate_one_channel()
535 call->service_id = conn->service_id; in rxrpc_activate_one_channel()
539 call->cid, call->call_id, call->debug_id, conn->debug_id); in rxrpc_activate_one_channel()
566 static void rxrpc_unidle_conn(struct rxrpc_bundle *bundle, struct rxrpc_connection *conn) in rxrpc_unidle_conn() argument
571 if (!list_empty(&conn->cache_link)) { in rxrpc_unidle_conn()
574 if (!list_empty(&conn->cache_link)) { in rxrpc_unidle_conn()
575 list_del_init(&conn->cache_link); in rxrpc_unidle_conn()
580 rxrpc_put_connection(conn); in rxrpc_unidle_conn()
590 struct rxrpc_connection *conn; in rxrpc_activate_channels_locked() local
607 conn = bundle->conns[slot]; in rxrpc_activate_channels_locked()
608 if (!conn) in rxrpc_activate_channels_locked()
612 set_bit(RXRPC_CONN_PROBING_FOR_UPGRADE, &conn->flags); in rxrpc_activate_channels_locked()
613 rxrpc_unidle_conn(bundle, conn); in rxrpc_activate_channels_locked()
616 conn->act_chans |= 1 << channel; in rxrpc_activate_channels_locked()
617 rxrpc_activate_one_channel(conn, channel); in rxrpc_activate_channels_locked()
743 trace_rxrpc_client(call->conn, ret, rxrpc_client_chan_wait_failed); in rxrpc_connect_call()
756 struct rxrpc_connection *conn = call->conn; in rxrpc_expose_client_call() local
757 struct rxrpc_channel *chan = &conn->channels[channel]; in rxrpc_expose_client_call()
767 set_bit(RXRPC_CONN_DONT_REUSE, &conn->flags); in rxrpc_expose_client_call()
768 trace_rxrpc_client(conn, channel, rxrpc_client_exposed); in rxrpc_expose_client_call()
791 struct rxrpc_connection *conn; in rxrpc_disconnect_client_call() local
806 conn = call->conn; in rxrpc_disconnect_client_call()
807 if (!conn) { in rxrpc_disconnect_client_call()
817 chan = &conn->channels[channel]; in rxrpc_disconnect_client_call()
818 trace_rxrpc_client(conn, channel, rxrpc_client_chan_disconnect); in rxrpc_disconnect_client_call()
825 may_reuse = rxrpc_may_reuse_conn(conn); in rxrpc_disconnect_client_call()
838 __rxrpc_disconnect_call(conn, call); in rxrpc_disconnect_client_call()
840 if (test_and_clear_bit(RXRPC_CONN_PROBING_FOR_UPGRADE, &conn->flags)) { in rxrpc_disconnect_client_call()
841 trace_rxrpc_client(conn, channel, rxrpc_client_to_active); in rxrpc_disconnect_client_call()
851 trace_rxrpc_client(conn, channel, rxrpc_client_chan_pass); in rxrpc_disconnect_client_call()
852 rxrpc_activate_one_channel(conn, channel); in rxrpc_disconnect_client_call()
866 set_bit(RXRPC_CONN_FINAL_ACK_0 + channel, &conn->flags); in rxrpc_disconnect_client_call()
867 rxrpc_reduce_conn_timer(conn, final_ack_at); in rxrpc_disconnect_client_call()
872 set_bit(conn->bundle_shift + channel, &conn->bundle->avail_chans); in rxrpc_disconnect_client_call()
873 conn->act_chans &= ~(1 << channel); in rxrpc_disconnect_client_call()
879 if (!conn->act_chans) { in rxrpc_disconnect_client_call()
880 trace_rxrpc_client(conn, channel, rxrpc_client_to_idle); in rxrpc_disconnect_client_call()
881 conn->idle_timestamp = jiffies; in rxrpc_disconnect_client_call()
883 rxrpc_get_connection(conn); in rxrpc_disconnect_client_call()
885 list_move_tail(&conn->cache_link, &rxnet->idle_client_conns); in rxrpc_disconnect_client_call()
900 static void rxrpc_unbundle_conn(struct rxrpc_connection *conn) in rxrpc_unbundle_conn() argument
902 struct rxrpc_bundle *bundle = conn->bundle; in rxrpc_unbundle_conn()
908 _enter("C=%x", conn->debug_id); in rxrpc_unbundle_conn()
910 if (conn->flags & RXRPC_CONN_FINAL_ACK_MASK) in rxrpc_unbundle_conn()
911 rxrpc_process_delayed_final_acks(conn, true); in rxrpc_unbundle_conn()
914 bindex = conn->bundle_shift / RXRPC_MAXCALLS; in rxrpc_unbundle_conn()
915 if (bundle->conns[bindex] == conn) { in rxrpc_unbundle_conn()
919 clear_bit(conn->bundle_shift + i, &bundle->avail_chans); in rxrpc_unbundle_conn()
944 rxrpc_put_connection(conn); in rxrpc_unbundle_conn()
951 static void rxrpc_kill_client_conn(struct rxrpc_connection *conn) in rxrpc_kill_client_conn() argument
953 struct rxrpc_local *local = conn->params.local; in rxrpc_kill_client_conn()
956 _enter("C=%x", conn->debug_id); in rxrpc_kill_client_conn()
958 trace_rxrpc_client(conn, -1, rxrpc_client_cleanup); in rxrpc_kill_client_conn()
961 rxrpc_put_client_connection_id(conn); in rxrpc_kill_client_conn()
962 rxrpc_kill_connection(conn); in rxrpc_kill_client_conn()
968 void rxrpc_put_client_conn(struct rxrpc_connection *conn) in rxrpc_put_client_conn() argument
971 unsigned int debug_id = conn->debug_id; in rxrpc_put_client_conn()
975 dead = __refcount_dec_and_test(&conn->ref, &r); in rxrpc_put_client_conn()
978 rxrpc_kill_client_conn(conn); in rxrpc_put_client_conn()
990 struct rxrpc_connection *conn; in rxrpc_discard_expired_client_conns() local
1020 conn = list_entry(rxnet->idle_client_conns.next, in rxrpc_discard_expired_client_conns()
1032 if (conn->params.local->service_closed) in rxrpc_discard_expired_client_conns()
1035 conn_expires_at = conn->idle_timestamp + expiry; in rxrpc_discard_expired_client_conns()
1042 trace_rxrpc_client(conn, -1, rxrpc_client_discard); in rxrpc_discard_expired_client_conns()
1043 list_del_init(&conn->cache_link); in rxrpc_discard_expired_client_conns()
1047 rxrpc_unbundle_conn(conn); in rxrpc_discard_expired_client_conns()
1048 rxrpc_put_connection(conn); /* Drop the ->cache_link ref */ in rxrpc_discard_expired_client_conns()
1096 struct rxrpc_connection *conn, *tmp; in rxrpc_clean_up_local_conns() local
1104 list_for_each_entry_safe(conn, tmp, &rxnet->idle_client_conns, in rxrpc_clean_up_local_conns()
1106 if (conn->params.local == local) { in rxrpc_clean_up_local_conns()
1107 trace_rxrpc_client(conn, -1, rxrpc_client_discard); in rxrpc_clean_up_local_conns()
1108 list_move(&conn->cache_link, &graveyard); in rxrpc_clean_up_local_conns()
1115 conn = list_entry(graveyard.next, in rxrpc_clean_up_local_conns()
1117 list_del_init(&conn->cache_link); in rxrpc_clean_up_local_conns()
1118 rxrpc_unbundle_conn(conn); in rxrpc_clean_up_local_conns()
1119 rxrpc_put_connection(conn); in rxrpc_clean_up_local_conns()