Lines Matching refs:bundle
37 static void rxrpc_activate_bundle(struct rxrpc_bundle *bundle) in rxrpc_activate_bundle() argument
39 atomic_inc(&bundle->active); in rxrpc_activate_bundle()
76 struct rxrpc_bundle *bundle; in rxrpc_alloc_bundle() local
78 bundle = kzalloc(sizeof(*bundle), gfp); in rxrpc_alloc_bundle()
79 if (bundle) { in rxrpc_alloc_bundle()
80 bundle->local = call->local; in rxrpc_alloc_bundle()
81 bundle->peer = rxrpc_get_peer(call->peer, rxrpc_peer_get_bundle); in rxrpc_alloc_bundle()
82 bundle->key = key_get(call->key); in rxrpc_alloc_bundle()
83 bundle->security = call->security; in rxrpc_alloc_bundle()
84 bundle->exclusive = test_bit(RXRPC_CALL_EXCLUSIVE, &call->flags); in rxrpc_alloc_bundle()
85 bundle->upgrade = test_bit(RXRPC_CALL_UPGRADE, &call->flags); in rxrpc_alloc_bundle()
86 bundle->service_id = call->dest_srx.srx_service; in rxrpc_alloc_bundle()
87 bundle->security_level = call->security_level; in rxrpc_alloc_bundle()
88 refcount_set(&bundle->ref, 1); in rxrpc_alloc_bundle()
89 atomic_set(&bundle->active, 1); in rxrpc_alloc_bundle()
90 INIT_LIST_HEAD(&bundle->waiting_calls); in rxrpc_alloc_bundle()
91 trace_rxrpc_bundle(bundle->debug_id, 1, rxrpc_bundle_new); in rxrpc_alloc_bundle()
93 return bundle; in rxrpc_alloc_bundle()
96 struct rxrpc_bundle *rxrpc_get_bundle(struct rxrpc_bundle *bundle, in rxrpc_get_bundle() argument
101 __refcount_inc(&bundle->ref, &r); in rxrpc_get_bundle()
102 trace_rxrpc_bundle(bundle->debug_id, r + 1, why); in rxrpc_get_bundle()
103 return bundle; in rxrpc_get_bundle()
106 static void rxrpc_free_bundle(struct rxrpc_bundle *bundle) in rxrpc_free_bundle() argument
108 trace_rxrpc_bundle(bundle->debug_id, 1, rxrpc_bundle_free); in rxrpc_free_bundle()
109 rxrpc_put_peer(bundle->peer, rxrpc_peer_put_bundle); in rxrpc_free_bundle()
110 key_put(bundle->key); in rxrpc_free_bundle()
111 kfree(bundle); in rxrpc_free_bundle()
114 void rxrpc_put_bundle(struct rxrpc_bundle *bundle, enum rxrpc_bundle_trace why) in rxrpc_put_bundle() argument
120 if (bundle) { in rxrpc_put_bundle()
121 id = bundle->debug_id; in rxrpc_put_bundle()
122 dead = __refcount_dec_and_test(&bundle->ref, &r); in rxrpc_put_bundle()
125 rxrpc_free_bundle(bundle); in rxrpc_put_bundle()
142 rxrpc_alloc_client_connection(struct rxrpc_bundle *bundle) in rxrpc_alloc_client_connection() argument
145 struct rxrpc_local *local = bundle->local; in rxrpc_alloc_client_connection()
166 conn->bundle = rxrpc_get_bundle(bundle, rxrpc_bundle_get_client_conn); in rxrpc_alloc_client_connection()
167 conn->local = rxrpc_get_local(bundle->local, rxrpc_local_get_client_conn); in rxrpc_alloc_client_connection()
168 conn->peer = rxrpc_get_peer(bundle->peer, rxrpc_peer_get_client_conn); in rxrpc_alloc_client_connection()
169 conn->key = key_get(bundle->key); in rxrpc_alloc_client_connection()
170 conn->security = bundle->security; in rxrpc_alloc_client_connection()
171 conn->exclusive = bundle->exclusive; in rxrpc_alloc_client_connection()
172 conn->upgrade = bundle->upgrade; in rxrpc_alloc_client_connection()
173 conn->orig_service_id = bundle->service_id; in rxrpc_alloc_client_connection()
174 conn->security_level = bundle->security_level; in rxrpc_alloc_client_connection()
243 struct rxrpc_bundle *bundle, *candidate; in rxrpc_look_up_bundle() local
254 call->bundle = rxrpc_alloc_bundle(call, gfp); in rxrpc_look_up_bundle()
255 return call->bundle ? 0 : -ENOMEM; in rxrpc_look_up_bundle()
263 bundle = rb_entry(p, struct rxrpc_bundle, local_node); in rxrpc_look_up_bundle()
266 diff = (cmp(bundle->peer, call->peer) ?: in rxrpc_look_up_bundle()
267 cmp(bundle->key, call->key) ?: in rxrpc_look_up_bundle()
268 cmp(bundle->security_level, call->security_level) ?: in rxrpc_look_up_bundle()
269 cmp(bundle->upgrade, upgrade)); in rxrpc_look_up_bundle()
292 bundle = rb_entry(parent, struct rxrpc_bundle, local_node); in rxrpc_look_up_bundle()
295 diff = (cmp(bundle->peer, call->peer) ?: in rxrpc_look_up_bundle()
296 cmp(bundle->key, call->key) ?: in rxrpc_look_up_bundle()
297 cmp(bundle->security_level, call->security_level) ?: in rxrpc_look_up_bundle()
298 cmp(bundle->upgrade, upgrade)); in rxrpc_look_up_bundle()
312 call->bundle = rxrpc_get_bundle(candidate, rxrpc_bundle_get_client_call); in rxrpc_look_up_bundle()
314 _leave(" = B=%u [new]", call->bundle->debug_id); in rxrpc_look_up_bundle()
320 call->bundle = rxrpc_get_bundle(bundle, rxrpc_bundle_get_client_call); in rxrpc_look_up_bundle()
321 rxrpc_activate_bundle(bundle); in rxrpc_look_up_bundle()
323 _leave(" = B=%u [found]", call->bundle->debug_id); in rxrpc_look_up_bundle()
330 static bool rxrpc_add_conn_to_bundle(struct rxrpc_bundle *bundle, in rxrpc_add_conn_to_bundle() argument
337 old = bundle->conns[slot]; in rxrpc_add_conn_to_bundle()
339 bundle->conns[slot] = NULL; in rxrpc_add_conn_to_bundle()
344 conn = rxrpc_alloc_client_connection(bundle); in rxrpc_add_conn_to_bundle()
346 bundle->alloc_error = PTR_ERR(conn); in rxrpc_add_conn_to_bundle()
350 rxrpc_activate_bundle(bundle); in rxrpc_add_conn_to_bundle()
352 bundle->conns[slot] = conn; in rxrpc_add_conn_to_bundle()
354 set_bit(shift + i, &bundle->avail_chans); in rxrpc_add_conn_to_bundle()
362 static bool rxrpc_bundle_has_space(struct rxrpc_bundle *bundle) in rxrpc_bundle_has_space() argument
368 bundle->alloc_error = 0; in rxrpc_bundle_has_space()
372 for (i = 0; i < ARRAY_SIZE(bundle->conns); i++) { in rxrpc_bundle_has_space()
373 if (rxrpc_may_reuse_conn(bundle->conns[i])) in rxrpc_bundle_has_space()
379 if (!usable && bundle->upgrade) in rxrpc_bundle_has_space()
380 bundle->try_upgrade = true; in rxrpc_bundle_has_space()
385 if (!bundle->avail_chans && in rxrpc_bundle_has_space()
386 !bundle->try_upgrade && in rxrpc_bundle_has_space()
387 usable < ARRAY_SIZE(bundle->conns)) in rxrpc_bundle_has_space()
394 return slot >= 0 ? rxrpc_add_conn_to_bundle(bundle, slot) : false; in rxrpc_bundle_has_space()
406 struct rxrpc_bundle *bundle = conn->bundle; in rxrpc_activate_one_channel() local
407 struct rxrpc_call *call = list_entry(bundle->waiting_calls.next, in rxrpc_activate_one_channel()
421 clear_bit(conn->bundle_shift + channel, &bundle->avail_chans); in rxrpc_activate_one_channel()
460 static void rxrpc_activate_channels(struct rxrpc_bundle *bundle) in rxrpc_activate_channels() argument
468 if (bundle->try_upgrade) in rxrpc_activate_channels()
473 while (!list_empty(&bundle->waiting_calls)) { in rxrpc_activate_channels()
474 avail = bundle->avail_chans & mask; in rxrpc_activate_channels()
478 clear_bit(channel, &bundle->avail_chans); in rxrpc_activate_channels()
481 conn = bundle->conns[slot]; in rxrpc_activate_channels()
485 if (bundle->try_upgrade) in rxrpc_activate_channels()
505 struct rxrpc_bundle *bundle = call->bundle; in rxrpc_connect_client_calls() local
508 list_move_tail(&call->wait_link, &bundle->waiting_calls); in rxrpc_connect_client_calls()
511 if (rxrpc_bundle_has_space(bundle)) in rxrpc_connect_client_calls()
512 rxrpc_activate_channels(bundle); in rxrpc_connect_client_calls()
560 void rxrpc_disconnect_client_call(struct rxrpc_bundle *bundle, struct rxrpc_call *call) in rxrpc_disconnect_client_call() argument
564 struct rxrpc_local *local = bundle->local; in rxrpc_disconnect_client_call()
608 bundle->try_upgrade = false; in rxrpc_disconnect_client_call()
610 rxrpc_activate_channels(bundle); in rxrpc_disconnect_client_call()
615 if (may_reuse && !list_empty(&bundle->waiting_calls)) { in rxrpc_disconnect_client_call()
637 set_bit(conn->bundle_shift + channel, &conn->bundle->avail_chans); in rxrpc_disconnect_client_call()
660 struct rxrpc_bundle *bundle = conn->bundle; in rxrpc_unbundle_conn() local
670 if (bundle->conns[bindex] == conn) { in rxrpc_unbundle_conn()
672 bundle->conns[bindex] = NULL; in rxrpc_unbundle_conn()
674 clear_bit(conn->bundle_shift + i, &bundle->avail_chans); in rxrpc_unbundle_conn()
675 rxrpc_put_client_connection_id(bundle->local, conn); in rxrpc_unbundle_conn()
676 rxrpc_deactivate_bundle(bundle); in rxrpc_unbundle_conn()
684 void rxrpc_deactivate_bundle(struct rxrpc_bundle *bundle) in rxrpc_deactivate_bundle() argument
689 if (!bundle) in rxrpc_deactivate_bundle()
692 local = bundle->local; in rxrpc_deactivate_bundle()
693 if (atomic_dec_and_lock(&bundle->active, &local->client_bundles_lock)) { in rxrpc_deactivate_bundle()
694 if (!bundle->exclusive) { in rxrpc_deactivate_bundle()
696 rb_erase(&bundle->local_node, &local->client_bundles); in rxrpc_deactivate_bundle()
702 rxrpc_put_bundle(bundle, rxrpc_bundle_put_discard); in rxrpc_deactivate_bundle()