• Home
  • History
  • Annotate
  • Raw
  • Download
  • only in /netgear-R7000-V1.0.7.12_1.2.5/components/opensource/linux/linux-2.6.36/net/rxrpc/

Lines Matching refs:call

1 /* RxRPC individual remote procedure call handling
51 * allocate a new call
55 struct rxrpc_call *call;
57 call = kmem_cache_zalloc(rxrpc_call_jar, gfp);
58 if (!call)
61 call->acks_winsz = 16;
62 call->acks_window = kmalloc(call->acks_winsz * sizeof(unsigned long),
64 if (!call->acks_window) {
65 kmem_cache_free(rxrpc_call_jar, call);
69 setup_timer(&call->lifetimer, &rxrpc_call_life_expired,
70 (unsigned long) call);
71 setup_timer(&call->deadspan, &rxrpc_dead_call_expired,
72 (unsigned long) call);
73 setup_timer(&call->ack_timer, &rxrpc_ack_time_expired,
74 (unsigned long) call);
75 setup_timer(&call->resend_timer, &rxrpc_resend_time_expired,
76 (unsigned long) call);
77 INIT_WORK(&call->destroyer, &rxrpc_destroy_call);
78 INIT_WORK(&call->processor, &rxrpc_process_call);
79 INIT_LIST_HEAD(&call->accept_link);
80 skb_queue_head_init(&call->rx_queue);
81 skb_queue_head_init(&call->rx_oos_queue);
82 init_waitqueue_head(&call->tx_waitq);
83 spin_lock_init(&call->lock);
84 rwlock_init(&call->state_lock);
85 atomic_set(&call->usage, 1);
86 call->debug_id = atomic_inc_return(&rxrpc_debug_id);
87 call->state = RXRPC_CALL_CLIENT_SEND_REQUEST;
89 memset(&call->sock_node, 0xed, sizeof(call->sock_node));
91 call->rx_data_expect = 1;
92 call->rx_data_eaten = 0;
93 call->rx_first_oos = 0;
94 call->ackr_win_top = call->rx_data_eaten + 1 + RXRPC_MAXACKS;
95 call->creation_jif = jiffies;
96 return call;
100 * allocate a new client call and attempt to get a connection slot for it
108 struct rxrpc_call *call;
117 call = rxrpc_alloc_call(gfp);
118 if (!call)
122 call->socket = rx;
123 call->rx_data_post = 1;
125 ret = rxrpc_connect_call(rx, trans, bundle, call, gfp);
127 kmem_cache_free(rxrpc_call_jar, call);
131 spin_lock(&call->conn->trans->peer->lock);
132 list_add(&call->error_link, &call->conn->trans->peer->error_targets);
133 spin_unlock(&call->conn->trans->peer->lock);
135 call->lifetimer.expires = jiffies + rxrpc_call_max_lifetime * HZ;
136 add_timer(&call->lifetimer);
138 _leave(" = %p", call);
139 return call;
143 * set up a call for the given data
153 struct rxrpc_call *call, *candidate;
166 call = rb_entry(p, struct rxrpc_call, sock_node);
168 if (user_call_ID < call->user_call_ID)
170 else if (user_call_ID > call->user_call_ID)
198 call = rb_entry(parent, struct rxrpc_call, sock_node);
200 if (user_call_ID < call->user_call_ID)
202 else if (user_call_ID > call->user_call_ID)
208 /* second search also failed; add the new call */
209 call = candidate;
211 rxrpc_get_call(call);
213 rb_link_node(&call->sock_node, parent, pp);
214 rb_insert_color(&call->sock_node, &rx->calls);
218 list_add_tail(&call->link, &rxrpc_calls);
221 _net("CALL new %d on CONN %d", call->debug_id, call->conn->debug_id);
223 _leave(" = %p [new]", call);
224 return call;
226 /* we found the call in the list immediately */
228 rxrpc_get_call(call);
230 _leave(" = %p [extant %d]", call, atomic_read(&call->usage));
231 return call;
233 /* we found the call on the second time through the list */
235 rxrpc_get_call(call);
238 _leave(" = %p [second %d]", call, atomic_read(&call->usage));
239 return call;
243 * set up an incoming call
251 struct rxrpc_call *call, *candidate;
275 /* set the channel for this call */
276 call = conn->channels[candidate->channel];
277 _debug("channel[%u] is %p", candidate->channel, call);
278 if (call && call->call_id == hdr->callNumber) {
280 _debug("extant call [%d]", call->state);
281 ASSERTCMP(call->conn, ==, conn);
283 read_lock(&call->state_lock);
284 switch (call->state) {
286 if (!test_and_set_bit(RXRPC_CALL_ABORT, &call->events))
287 rxrpc_queue_call(call);
289 read_unlock(&call->state_lock);
292 rxrpc_get_call(call);
293 read_unlock(&call->state_lock);
298 if (call) {
299 /* it seems the channel is still in use from the previous call
300 * - ditch the old binding if its call is now complete */
302 call->debug_id, rxrpc_call_states[call->state]);
304 if (call->state >= RXRPC_CALL_COMPLETE) {
305 conn->channels[call->channel] = NULL;
314 /* check the call number isn't duplicate */
321 call = rb_entry(parent, struct rxrpc_call, conn_node);
323 if (call_id < call->call_id)
325 else if (call_id > call->call_id)
331 /* make the call available */
332 _debug("new call");
333 call = candidate;
335 rb_link_node(&call->conn_node, parent, p);
336 rb_insert_color(&call->conn_node, &conn->calls);
337 conn->channels[call->channel] = call;
343 list_add(&call->error_link, &conn->trans->peer->error_targets);
347 list_add_tail(&call->link, &rxrpc_calls);
350 _net("CALL incoming %d on CONN %d", call->debug_id, call->conn->debug_id);
352 call->lifetimer.expires = jiffies + rxrpc_call_max_lifetime * HZ;
353 add_timer(&call->lifetimer);
354 _leave(" = %p {%d} [new]", call, call->debug_id);
355 return call;
360 _leave(" = %p {%d} [extant]", call, call ? call->debug_id : -1);
361 return call;
377 * find an extant server call
383 struct rxrpc_call *call;
394 call = rb_entry(p, struct rxrpc_call, sock_node);
396 if (user_call_ID < call->user_call_ID)
398 else if (user_call_ID > call->user_call_ID)
408 /* we found the call in the list immediately */
410 rxrpc_get_call(call);
412 _leave(" = %p [%d]", call, atomic_read(&call->usage));
413 return call;
417 * detach a call from a socket and set up for release
419 void rxrpc_release_call(struct rxrpc_call *call)
421 struct rxrpc_connection *conn = call->conn;
422 struct rxrpc_sock *rx = call->socket;
425 call->debug_id, atomic_read(&call->usage),
426 atomic_read(&call->ackr_not_idle),
427 call->rx_first_oos);
429 spin_lock_bh(&call->lock);
430 if (test_and_set_bit(RXRPC_CALL_RELEASED, &call->flags))
432 spin_unlock_bh(&call->lock);
435 * - the socket's ref on the call is passed to the death timer
437 _debug("RELEASE CALL %p (%d CONN %p)", call, call->debug_id, conn);
440 if (!list_empty(&call->accept_link)) {
441 _debug("unlinking once-pending call %p { e=%lx f=%lx }",
442 call, call->events, call->flags);
443 ASSERT(!test_bit(RXRPC_CALL_HAS_USERID, &call->flags));
444 list_del_init(&call->accept_link);
446 } else if (test_bit(RXRPC_CALL_HAS_USERID, &call->flags)) {
447 rb_erase(&call->sock_node, &rx->calls);
448 memset(&call->sock_node, 0xdd, sizeof(call->sock_node));
449 clear_bit(RXRPC_CALL_HAS_USERID, &call->flags);
456 write_lock(&call->state_lock);
458 if (conn->channels[call->channel] == call)
459 conn->channels[call->channel] = NULL;
490 if (call->state < RXRPC_CALL_COMPLETE &&
491 call->state != RXRPC_CALL_CLIENT_FINAL_ACK) {
492 _debug("+++ ABORTING STATE %d +++\n", call->state);
493 call->state = RXRPC_CALL_LOCALLY_ABORTED;
494 call->abort_code = RX_CALL_DEAD;
495 set_bit(RXRPC_CALL_ABORT, &call->events);
496 rxrpc_queue_call(call);
498 write_unlock(&call->state_lock);
502 if (!skb_queue_empty(&call->rx_queue) ||
503 !skb_queue_empty(&call->rx_oos_queue)) {
509 spin_lock_bh(&call->lock);
510 while ((skb = skb_dequeue(&call->rx_queue)) ||
511 (skb = skb_dequeue(&call->rx_oos_queue))) {
513 if (sp->call) {
514 ASSERTCMP(sp->call, ==, call);
515 rxrpc_put_call(call);
516 sp->call = NULL;
519 spin_unlock_bh(&call->lock);
526 spin_lock_bh(&call->lock);
528 spin_unlock_bh(&call->lock);
530 ASSERTCMP(call->state, !=, RXRPC_CALL_COMPLETE);
533 del_timer_sync(&call->resend_timer);
534 del_timer_sync(&call->ack_timer);
535 del_timer_sync(&call->lifetimer);
536 call->deadspan.expires = jiffies + rxrpc_dead_call_timeout * HZ;
537 add_timer(&call->deadspan);
543 * handle a dead call being ready for reaping
547 struct rxrpc_call *call = (struct rxrpc_call *) _call;
549 _enter("{%d}", call->debug_id);
551 write_lock_bh(&call->state_lock);
552 call->state = RXRPC_CALL_DEAD;
553 write_unlock_bh(&call->state_lock);
554 rxrpc_put_call(call);
558 * mark a call as to be released, aborting it if it's still in progress
561 static void rxrpc_mark_call_released(struct rxrpc_call *call)
565 write_lock(&call->state_lock);
566 if (call->state < RXRPC_CALL_DEAD) {
568 if (call->state < RXRPC_CALL_COMPLETE) {
569 _debug("abort call %p", call);
570 call->state = RXRPC_CALL_LOCALLY_ABORTED;
571 call->abort_code = RX_CALL_DEAD;
572 if (!test_and_set_bit(RXRPC_CALL_ABORT, &call->events))
575 if (!test_and_set_bit(RXRPC_CALL_RELEASE, &call->events))
578 rxrpc_queue_call(call);
580 write_unlock(&call->state_lock);
588 struct rxrpc_call *call;
597 call = rb_entry(p, struct rxrpc_call, sock_node);
598 rxrpc_mark_call_released(call);
602 list_for_each_entry(call, &rx->secureq, accept_link) {
603 rxrpc_mark_call_released(call);
606 list_for_each_entry(call, &rx->acceptq, accept_link) {
607 rxrpc_mark_call_released(call);
615 * release a call
617 void __rxrpc_put_call(struct rxrpc_call *call)
619 ASSERT(call != NULL);
621 _enter("%p{u=%d}", call, atomic_read(&call->usage));
623 ASSERTCMP(atomic_read(&call->usage), >, 0);
625 if (atomic_dec_and_test(&call->usage)) {
626 _debug("call %d dead", call->debug_id);
627 ASSERTCMP(call->state, ==, RXRPC_CALL_DEAD);
628 rxrpc_queue_work(&call->destroyer);
634 * clean up a call
636 static void rxrpc_cleanup_call(struct rxrpc_call *call)
638 _net("DESTROY CALL %d", call->debug_id);
640 ASSERT(call->socket);
642 memset(&call->sock_node, 0xcd, sizeof(call->sock_node));
644 del_timer_sync(&call->lifetimer);
645 del_timer_sync(&call->deadspan);
646 del_timer_sync(&call->ack_timer);
647 del_timer_sync(&call->resend_timer);
649 ASSERT(test_bit(RXRPC_CALL_RELEASED, &call->flags));
650 ASSERTCMP(call->events, ==, 0);
651 if (work_pending(&call->processor)) {
653 rxrpc_queue_work(&call->destroyer);
657 if (call->conn) {
658 spin_lock(&call->conn->trans->peer->lock);
659 list_del(&call->error_link);
660 spin_unlock(&call->conn->trans->peer->lock);
662 write_lock_bh(&call->conn->lock);
663 rb_erase(&call->conn_node, &call->conn->calls);
664 write_unlock_bh(&call->conn->lock);
665 rxrpc_put_connection(call->conn);
668 if (call->acks_window) {
670 CIRC_CNT(call->acks_head, call->acks_tail,
671 call->acks_winsz));
673 while (CIRC_CNT(call->acks_head, call->acks_tail,
674 call->acks_winsz) > 0) {
678 _skb = call->acks_window[call->acks_tail] & ~1;
682 call->acks_tail =
683 (call->acks_tail + 1) & (call->acks_winsz - 1);
686 kfree(call->acks_window);
689 rxrpc_free_skb(call->tx_pending);
691 rxrpc_purge_queue(&call->rx_queue);
692 ASSERT(skb_queue_empty(&call->rx_oos_queue));
693 sock_put(&call->socket->sk);
694 kmem_cache_free(rxrpc_call_jar, call);
698 * destroy a call
702 struct rxrpc_call *call =
706 call, atomic_read(&call->usage), call->channel, call->conn);
708 ASSERTCMP(call->state, ==, RXRPC_CALL_DEAD);
711 list_del_init(&call->link);
714 rxrpc_cleanup_call(call);
719 * preemptively destroy all the call records from a transport endpoint rather
724 struct rxrpc_call *call;
730 call = list_entry(rxrpc_calls.next, struct rxrpc_call, link);
731 _debug("Zapping call %p", call);
733 list_del_init(&call->link);
735 switch (atomic_read(&call->usage)) {
737 ASSERTCMP(call->state, ==, RXRPC_CALL_DEAD);
740 if (del_timer_sync(&call->deadspan) != 0 &&
741 call->state != RXRPC_CALL_DEAD)
742 rxrpc_dead_call_expired((unsigned long) call);
743 if (call->state != RXRPC_CALL_DEAD)
748 call, atomic_read(&call->usage),
749 atomic_read(&call->ackr_not_idle),
750 rxrpc_call_states[call->state],
751 call->flags, call->events);
752 if (!skb_queue_empty(&call->rx_queue))
754 if (!skb_queue_empty(&call->rx_oos_queue))
769 * handle call lifetime being exceeded
773 struct rxrpc_call *call = (struct rxrpc_call *) _call;
775 if (call->state >= RXRPC_CALL_COMPLETE)
778 _enter("{%d}", call->debug_id);
779 read_lock_bh(&call->state_lock);
780 if (call->state < RXRPC_CALL_COMPLETE) {
781 set_bit(RXRPC_CALL_LIFE_TIMER, &call->events);
782 rxrpc_queue_call(call);
784 read_unlock_bh(&call->state_lock);
789 * - may not take call->state_lock as this can deadlock against del_timer_sync()
793 struct rxrpc_call *call = (struct rxrpc_call *) _call;
795 _enter("{%d}", call->debug_id);
797 if (call->state >= RXRPC_CALL_COMPLETE)
800 clear_bit(RXRPC_CALL_RUN_RTIMER, &call->flags);
801 if (!test_and_set_bit(RXRPC_CALL_RESEND_TIMER, &call->events))
802 rxrpc_queue_call(call);
810 struct rxrpc_call *call = (struct rxrpc_call *) _call;
812 _enter("{%d}", call->debug_id);
814 if (call->state >= RXRPC_CALL_COMPLETE)
817 read_lock_bh(&call->state_lock);
818 if (call->state < RXRPC_CALL_COMPLETE &&
819 !test_and_set_bit(RXRPC_CALL_ACK, &call->events))
820 rxrpc_queue_call(call);
821 read_unlock_bh(&call->state_lock);