Searched refs:cm_id_priv (Results 1 - 2 of 2) sorted by relevance

/linux-4.1.27/drivers/infiniband/core/
H A Dcm.c249 static inline void cm_deref_id(struct cm_id_private *cm_id_priv) cm_deref_id() argument
251 if (atomic_dec_and_test(&cm_id_priv->refcount)) cm_deref_id()
252 complete(&cm_id_priv->comp); cm_deref_id()
255 static int cm_alloc_msg(struct cm_id_private *cm_id_priv, cm_alloc_msg() argument
262 mad_agent = cm_id_priv->av.port->mad_agent; cm_alloc_msg()
263 ah = ib_create_ah(mad_agent->qp->pd, &cm_id_priv->av.ah_attr); cm_alloc_msg()
267 m = ib_create_send_mad(mad_agent, cm_id_priv->id.remote_cm_qpn, cm_alloc_msg()
268 cm_id_priv->av.pkey_index, cm_alloc_msg()
278 m->retries = cm_id_priv->max_cm_retries; cm_alloc_msg()
280 atomic_inc(&cm_id_priv->refcount); cm_alloc_msg()
281 m->context[0] = cm_id_priv; cm_alloc_msg()
333 static void cm_set_private_data(struct cm_id_private *cm_id_priv, cm_set_private_data() argument
336 if (cm_id_priv->private_data && cm_id_priv->private_data_len) cm_set_private_data()
337 kfree(cm_id_priv->private_data); cm_set_private_data()
339 cm_id_priv->private_data = private_data; cm_set_private_data()
340 cm_id_priv->private_data_len = private_data_len; cm_set_private_data()
388 static int cm_alloc_id(struct cm_id_private *cm_id_priv) cm_alloc_id() argument
396 id = idr_alloc_cyclic(&cm.local_id_table, cm_id_priv, 0, 0, GFP_NOWAIT); cm_alloc_id()
401 cm_id_priv->id.local_id = (__force __be32)id ^ cm.random_id_operand; cm_alloc_id()
415 struct cm_id_private *cm_id_priv; cm_get_id() local
417 cm_id_priv = idr_find(&cm.local_id_table, cm_get_id()
419 if (cm_id_priv) { cm_get_id()
420 if (cm_id_priv->id.remote_id == remote_id) cm_get_id()
421 atomic_inc(&cm_id_priv->refcount); cm_get_id()
423 cm_id_priv = NULL; cm_get_id()
426 return cm_id_priv; cm_get_id()
431 struct cm_id_private *cm_id_priv; cm_acquire_id() local
434 cm_id_priv = cm_get_id(local_id, remote_id); cm_acquire_id()
437 return cm_id_priv; cm_acquire_id()
499 static struct cm_id_private * cm_insert_listen(struct cm_id_private *cm_id_priv) cm_insert_listen() argument
504 __be64 service_id = cm_id_priv->id.service_id; cm_insert_listen()
505 __be64 service_mask = cm_id_priv->id.service_mask; cm_insert_listen()
512 data_cmp = cm_compare_data(cm_id_priv->compare_data, cm_insert_listen()
516 (cm_id_priv->id.device == cur_cm_id_priv->id.device) && cm_insert_listen()
520 if (cm_id_priv->id.device < cur_cm_id_priv->id.device) cm_insert_listen()
522 else if (cm_id_priv->id.device > cur_cm_id_priv->id.device) cm_insert_listen()
533 rb_link_node(&cm_id_priv->service_node, parent, link); cm_insert_listen()
534 rb_insert_color(&cm_id_priv->service_node, &cm.listen_service_table); cm_insert_listen()
543 struct cm_id_private *cm_id_priv; cm_find_listen() local
547 cm_id_priv = rb_entry(node, struct cm_id_private, service_node); cm_find_listen()
549 cm_id_priv->compare_data); cm_find_listen()
550 if ((cm_id_priv->id.service_mask & service_id) == cm_find_listen()
551 cm_id_priv->id.service_id && cm_find_listen()
552 (cm_id_priv->id.device == device) && !data_cmp) cm_find_listen()
553 return cm_id_priv; cm_find_listen()
555 if (device < cm_id_priv->id.device) cm_find_listen()
557 else if (device > cm_id_priv->id.device) cm_find_listen()
559 else if (be64_lt(service_id, cm_id_priv->id.service_id)) cm_find_listen()
561 else if (be64_gt(service_id, cm_id_priv->id.service_id)) cm_find_listen()
655 *cm_id_priv) cm_insert_remote_sidr()
660 union ib_gid *port_gid = &cm_id_priv->av.dgid; cm_insert_remote_sidr()
661 __be32 remote_id = cm_id_priv->id.remote_id; cm_insert_remote_sidr()
683 rb_link_node(&cm_id_priv->sidr_id_node, parent, link); cm_insert_remote_sidr()
684 rb_insert_color(&cm_id_priv->sidr_id_node, &cm.remote_sidr_table); cm_insert_remote_sidr()
688 static void cm_reject_sidr_req(struct cm_id_private *cm_id_priv, cm_reject_sidr_req() argument
695 ib_send_cm_sidr_rep(&cm_id_priv->id, &param); cm_reject_sidr_req()
702 struct cm_id_private *cm_id_priv; ib_create_cm_id() local
705 cm_id_priv = kzalloc(sizeof *cm_id_priv, GFP_KERNEL); ib_create_cm_id()
706 if (!cm_id_priv) ib_create_cm_id()
709 cm_id_priv->id.state = IB_CM_IDLE; ib_create_cm_id()
710 cm_id_priv->id.device = device; ib_create_cm_id()
711 cm_id_priv->id.cm_handler = cm_handler; ib_create_cm_id()
712 cm_id_priv->id.context = context; ib_create_cm_id()
713 cm_id_priv->id.remote_cm_qpn = 1; ib_create_cm_id()
714 ret = cm_alloc_id(cm_id_priv); ib_create_cm_id()
718 spin_lock_init(&cm_id_priv->lock); ib_create_cm_id()
719 init_completion(&cm_id_priv->comp); ib_create_cm_id()
720 INIT_LIST_HEAD(&cm_id_priv->work_list); ib_create_cm_id()
721 atomic_set(&cm_id_priv->work_count, -1); ib_create_cm_id()
722 atomic_set(&cm_id_priv->refcount, 1); ib_create_cm_id()
723 return &cm_id_priv->id; ib_create_cm_id()
726 kfree(cm_id_priv); ib_create_cm_id()
731 static struct cm_work * cm_dequeue_work(struct cm_id_private *cm_id_priv) cm_dequeue_work() argument
735 if (list_empty(&cm_id_priv->work_list)) cm_dequeue_work()
738 work = list_entry(cm_id_priv->work_list.next, struct cm_work, list); cm_dequeue_work()
802 static void cm_enter_timewait(struct cm_id_private *cm_id_priv) cm_enter_timewait() argument
808 cm_cleanup_timewait(cm_id_priv->timewait_info); cm_enter_timewait()
809 list_add_tail(&cm_id_priv->timewait_info->list, &cm.timewait_list); cm_enter_timewait()
817 cm_id_priv->id.state = IB_CM_TIMEWAIT; cm_enter_timewait()
818 wait_time = cm_convert_to_ms(cm_id_priv->av.timeout); cm_enter_timewait()
819 queue_delayed_work(cm.wq, &cm_id_priv->timewait_info->work.work, cm_enter_timewait()
821 cm_id_priv->timewait_info = NULL; cm_enter_timewait()
824 static void cm_reset_to_idle(struct cm_id_private *cm_id_priv) cm_reset_to_idle() argument
828 cm_id_priv->id.state = IB_CM_IDLE; cm_reset_to_idle()
829 if (cm_id_priv->timewait_info) { cm_reset_to_idle()
831 cm_cleanup_timewait(cm_id_priv->timewait_info); cm_reset_to_idle()
833 kfree(cm_id_priv->timewait_info); cm_reset_to_idle()
834 cm_id_priv->timewait_info = NULL; cm_reset_to_idle()
840 struct cm_id_private *cm_id_priv; cm_destroy_id() local
843 cm_id_priv = container_of(cm_id, struct cm_id_private, id); cm_destroy_id()
845 spin_lock_irq(&cm_id_priv->lock); cm_destroy_id()
849 spin_unlock_irq(&cm_id_priv->lock); cm_destroy_id()
851 rb_erase(&cm_id_priv->service_node, &cm.listen_service_table); cm_destroy_id()
856 ib_cancel_mad(cm_id_priv->av.port->mad_agent, cm_id_priv->msg); cm_destroy_id()
857 spin_unlock_irq(&cm_id_priv->lock); cm_destroy_id()
860 spin_unlock_irq(&cm_id_priv->lock); cm_destroy_id()
861 cm_reject_sidr_req(cm_id_priv, IB_SIDR_REJECT); cm_destroy_id()
863 if (!RB_EMPTY_NODE(&cm_id_priv->sidr_id_node)) cm_destroy_id()
864 rb_erase(&cm_id_priv->sidr_id_node, cm_destroy_id()
870 ib_cancel_mad(cm_id_priv->av.port->mad_agent, cm_id_priv->msg); cm_destroy_id()
871 spin_unlock_irq(&cm_id_priv->lock); cm_destroy_id()
873 &cm_id_priv->id.device->node_guid, cm_destroy_id()
874 sizeof cm_id_priv->id.device->node_guid, cm_destroy_id()
880 cm_reset_to_idle(cm_id_priv); cm_destroy_id()
881 spin_unlock_irq(&cm_id_priv->lock); cm_destroy_id()
883 spin_unlock_irq(&cm_id_priv->lock); cm_destroy_id()
890 ib_cancel_mad(cm_id_priv->av.port->mad_agent, cm_id_priv->msg); cm_destroy_id()
895 spin_unlock_irq(&cm_id_priv->lock); cm_destroy_id()
900 spin_unlock_irq(&cm_id_priv->lock); cm_destroy_id()
901 if (cm_id_priv->qp_type == IB_QPT_XRC_TGT) cm_destroy_id()
906 ib_cancel_mad(cm_id_priv->av.port->mad_agent, cm_id_priv->msg); cm_destroy_id()
907 cm_enter_timewait(cm_id_priv); cm_destroy_id()
908 spin_unlock_irq(&cm_id_priv->lock); cm_destroy_id()
911 spin_unlock_irq(&cm_id_priv->lock); cm_destroy_id()
915 spin_unlock_irq(&cm_id_priv->lock); cm_destroy_id()
920 cm_deref_id(cm_id_priv); cm_destroy_id()
921 wait_for_completion(&cm_id_priv->comp); cm_destroy_id()
922 while ((work = cm_dequeue_work(cm_id_priv)) != NULL) cm_destroy_id()
924 kfree(cm_id_priv->compare_data); cm_destroy_id()
925 kfree(cm_id_priv->private_data); cm_destroy_id()
926 kfree(cm_id_priv); cm_destroy_id()
938 struct cm_id_private *cm_id_priv, *cur_cm_id_priv; ib_cm_listen() local
948 cm_id_priv = container_of(cm_id, struct cm_id_private, id); ib_cm_listen()
953 cm_id_priv->compare_data = kzalloc(sizeof *compare_data, ib_cm_listen()
955 if (!cm_id_priv->compare_data) ib_cm_listen()
957 cm_mask_copy(cm_id_priv->compare_data->data, ib_cm_listen()
959 memcpy(cm_id_priv->compare_data->mask, compare_data->mask, ib_cm_listen()
973 cur_cm_id_priv = cm_insert_listen(cm_id_priv); ib_cm_listen()
978 kfree(cm_id_priv->compare_data); ib_cm_listen()
979 cm_id_priv->compare_data = NULL; ib_cm_listen()
986 static __be64 cm_form_tid(struct cm_id_private *cm_id_priv, cm_form_tid() argument
991 hi_tid = ((u64) cm_id_priv->av.port->mad_agent->hi_tid) << 32; cm_form_tid()
992 low_tid = (u64) ((__force u32)cm_id_priv->id.local_id | cm_form_tid()
1009 struct cm_id_private *cm_id_priv, cm_format_req()
1016 cm_form_tid(cm_id_priv, CM_MSG_SEQUENCE_REQ)); cm_format_req()
1018 req_msg->local_comm_id = cm_id_priv->id.local_id; cm_format_req()
1020 req_msg->local_ca_guid = cm_id_priv->id.device->node_guid; cm_format_req()
1058 cm_ack_timeout(cm_id_priv->av.port->cm_dev->ack_delay, cm_format_req()
1079 cm_ack_timeout(cm_id_priv->av.port->cm_dev->ack_delay, cm_format_req()
1116 struct cm_id_private *cm_id_priv; ib_send_cm_req() local
1126 cm_id_priv = container_of(cm_id, struct cm_id_private, id); ib_send_cm_req()
1127 spin_lock_irqsave(&cm_id_priv->lock, flags); ib_send_cm_req()
1129 spin_unlock_irqrestore(&cm_id_priv->lock, flags); ib_send_cm_req()
1133 spin_unlock_irqrestore(&cm_id_priv->lock, flags); ib_send_cm_req()
1135 cm_id_priv->timewait_info = cm_create_timewait_info(cm_id_priv-> ib_send_cm_req()
1137 if (IS_ERR(cm_id_priv->timewait_info)) { ib_send_cm_req()
1138 ret = PTR_ERR(cm_id_priv->timewait_info); ib_send_cm_req()
1142 ret = cm_init_av_by_path(param->primary_path, &cm_id_priv->av); ib_send_cm_req()
1147 &cm_id_priv->alt_av); ib_send_cm_req()
1153 cm_id_priv->timeout_ms = cm_convert_to_ms( ib_send_cm_req()
1157 cm_id_priv->max_cm_retries = param->max_cm_retries; ib_send_cm_req()
1158 cm_id_priv->initiator_depth = param->initiator_depth; ib_send_cm_req()
1159 cm_id_priv->responder_resources = param->responder_resources; ib_send_cm_req()
1160 cm_id_priv->retry_count = param->retry_count; ib_send_cm_req()
1161 cm_id_priv->path_mtu = param->primary_path->mtu; ib_send_cm_req()
1162 cm_id_priv->pkey = param->primary_path->pkey; ib_send_cm_req()
1163 cm_id_priv->qp_type = param->qp_type; ib_send_cm_req()
1165 ret = cm_alloc_msg(cm_id_priv, &cm_id_priv->msg); ib_send_cm_req()
1169 req_msg = (struct cm_req_msg *) cm_id_priv->msg->mad; ib_send_cm_req()
1170 cm_format_req(req_msg, cm_id_priv, param); ib_send_cm_req()
1171 cm_id_priv->tid = req_msg->hdr.tid; ib_send_cm_req()
1172 cm_id_priv->msg->timeout_ms = cm_id_priv->timeout_ms; ib_send_cm_req()
1173 cm_id_priv->msg->context[1] = (void *) (unsigned long) IB_CM_REQ_SENT; ib_send_cm_req()
1175 cm_id_priv->local_qpn = cm_req_get_local_qpn(req_msg); ib_send_cm_req()
1176 cm_id_priv->rq_psn = cm_req_get_starting_psn(req_msg); ib_send_cm_req()
1178 spin_lock_irqsave(&cm_id_priv->lock, flags); ib_send_cm_req()
1179 ret = ib_post_send_mad(cm_id_priv->msg, NULL); ib_send_cm_req()
1181 spin_unlock_irqrestore(&cm_id_priv->lock, flags); ib_send_cm_req()
1186 spin_unlock_irqrestore(&cm_id_priv->lock, flags); ib_send_cm_req()
1189 error2: cm_free_msg(cm_id_priv->msg); ib_send_cm_req()
1190 error1: kfree(cm_id_priv->timewait_info); ib_send_cm_req()
1287 struct cm_id_private *cm_id_priv, cm_format_req_event()
1296 param->port = cm_id_priv->av.port->port_num; cm_format_req_event()
1320 static void cm_process_work(struct cm_id_private *cm_id_priv, cm_process_work() argument
1326 ret = cm_id_priv->id.cm_handler(&cm_id_priv->id, &work->cm_event); cm_process_work()
1329 while (!ret && !atomic_add_negative(-1, &cm_id_priv->work_count)) { cm_process_work()
1330 spin_lock_irq(&cm_id_priv->lock); cm_process_work()
1331 work = cm_dequeue_work(cm_id_priv); cm_process_work()
1332 spin_unlock_irq(&cm_id_priv->lock); cm_process_work()
1334 ret = cm_id_priv->id.cm_handler(&cm_id_priv->id, cm_process_work()
1338 cm_deref_id(cm_id_priv); cm_process_work()
1340 cm_destroy_id(&cm_id_priv->id, ret); cm_process_work()
1344 struct cm_id_private *cm_id_priv, cm_format_mra()
1348 cm_format_mad_hdr(&mra_msg->hdr, CM_MRA_ATTR_ID, cm_id_priv->tid); cm_format_mra()
1350 mra_msg->local_comm_id = cm_id_priv->id.local_id; cm_format_mra()
1351 mra_msg->remote_comm_id = cm_id_priv->id.remote_id; cm_format_mra()
1359 struct cm_id_private *cm_id_priv, cm_format_rej()
1366 cm_format_mad_hdr(&rej_msg->hdr, CM_REJ_ATTR_ID, cm_id_priv->tid); cm_format_rej()
1367 rej_msg->remote_comm_id = cm_id_priv->id.remote_id; cm_format_rej()
1369 switch(cm_id_priv->id.state) { cm_format_rej()
1375 rej_msg->local_comm_id = cm_id_priv->id.local_id; cm_format_rej()
1380 rej_msg->local_comm_id = cm_id_priv->id.local_id; cm_format_rej()
1384 rej_msg->local_comm_id = cm_id_priv->id.local_id; cm_format_rej()
1400 struct cm_id_private *cm_id_priv) cm_dup_req_handler()
1409 if (cm_id_priv->id.state == IB_CM_REQ_RCVD) cm_dup_req_handler()
1416 spin_lock_irq(&cm_id_priv->lock); cm_dup_req_handler()
1417 switch (cm_id_priv->id.state) { cm_dup_req_handler()
1419 cm_format_mra((struct cm_mra_msg *) msg->mad, cm_id_priv, cm_dup_req_handler()
1420 CM_MSG_RESPONSE_REQ, cm_id_priv->service_timeout, cm_dup_req_handler()
1421 cm_id_priv->private_data, cm_dup_req_handler()
1422 cm_id_priv->private_data_len); cm_dup_req_handler()
1425 cm_format_rej((struct cm_rej_msg *) msg->mad, cm_id_priv, cm_dup_req_handler()
1431 spin_unlock_irq(&cm_id_priv->lock); cm_dup_req_handler()
1438 unlock: spin_unlock_irq(&cm_id_priv->lock); cm_dup_req_handler()
1443 struct cm_id_private *cm_id_priv) cm_match_req()
1453 timewait_info = cm_insert_remote_id(cm_id_priv->timewait_info); cm_match_req()
1466 timewait_info = cm_insert_remote_qpn(cm_id_priv->timewait_info); cm_match_req()
1468 cm_cleanup_timewait(cm_id_priv->timewait_info); cm_match_req()
1477 listen_cm_id_priv = cm_find_listen(cm_id_priv->id.device, cm_match_req()
1481 cm_cleanup_timewait(cm_id_priv->timewait_info); cm_match_req()
1489 atomic_inc(&cm_id_priv->refcount); cm_match_req()
1490 cm_id_priv->id.state = IB_CM_REQ_RCVD; cm_match_req()
1491 atomic_inc(&cm_id_priv->work_count); cm_match_req()
1528 struct cm_id_private *cm_id_priv, *listen_cm_id_priv; cm_req_handler() local
1538 cm_id_priv = container_of(cm_id, struct cm_id_private, id); cm_req_handler()
1539 cm_id_priv->id.remote_id = req_msg->local_comm_id; cm_req_handler()
1542 &cm_id_priv->av); cm_req_handler()
1543 cm_id_priv->timewait_info = cm_create_timewait_info(cm_id_priv-> cm_req_handler()
1545 if (IS_ERR(cm_id_priv->timewait_info)) { cm_req_handler()
1546 ret = PTR_ERR(cm_id_priv->timewait_info); cm_req_handler()
1549 cm_id_priv->timewait_info->work.remote_id = req_msg->local_comm_id; cm_req_handler()
1550 cm_id_priv->timewait_info->remote_ca_guid = req_msg->local_ca_guid; cm_req_handler()
1551 cm_id_priv->timewait_info->remote_qpn = cm_req_get_local_qpn(req_msg); cm_req_handler()
1553 listen_cm_id_priv = cm_match_req(work, cm_id_priv); cm_req_handler()
1556 kfree(cm_id_priv->timewait_info); cm_req_handler()
1560 cm_id_priv->id.cm_handler = listen_cm_id_priv->id.cm_handler; cm_req_handler()
1561 cm_id_priv->id.context = listen_cm_id_priv->id.context; cm_req_handler()
1562 cm_id_priv->id.service_id = req_msg->service_id; cm_req_handler()
1563 cm_id_priv->id.service_mask = ~cpu_to_be64(0); cm_req_handler()
1568 memcpy(work->path[0].dmac, cm_id_priv->av.ah_attr.dmac, ETH_ALEN); cm_req_handler()
1569 work->path[0].vlan_id = cm_id_priv->av.ah_attr.vlan_id; cm_req_handler()
1570 ret = cm_init_av_by_path(&work->path[0], &cm_id_priv->av); cm_req_handler()
1580 ret = cm_init_av_by_path(&work->path[1], &cm_id_priv->alt_av); cm_req_handler()
1588 cm_id_priv->tid = req_msg->hdr.tid; cm_req_handler()
1589 cm_id_priv->timeout_ms = cm_convert_to_ms( cm_req_handler()
1591 cm_id_priv->max_cm_retries = cm_req_get_max_cm_retries(req_msg); cm_req_handler()
1592 cm_id_priv->remote_qpn = cm_req_get_local_qpn(req_msg); cm_req_handler()
1593 cm_id_priv->initiator_depth = cm_req_get_resp_res(req_msg); cm_req_handler()
1594 cm_id_priv->responder_resources = cm_req_get_init_depth(req_msg); cm_req_handler()
1595 cm_id_priv->path_mtu = cm_req_get_path_mtu(req_msg); cm_req_handler()
1596 cm_id_priv->pkey = req_msg->pkey; cm_req_handler()
1597 cm_id_priv->sq_psn = cm_req_get_starting_psn(req_msg); cm_req_handler()
1598 cm_id_priv->retry_count = cm_req_get_retry_count(req_msg); cm_req_handler()
1599 cm_id_priv->rnr_retry_count = cm_req_get_rnr_retry_count(req_msg); cm_req_handler()
1600 cm_id_priv->qp_type = cm_req_get_qp_type(req_msg); cm_req_handler()
1602 cm_format_req_event(work, cm_id_priv, &listen_cm_id_priv->id); cm_req_handler()
1603 cm_process_work(cm_id_priv, work); cm_req_handler()
1608 atomic_dec(&cm_id_priv->refcount); cm_req_handler()
1616 struct cm_id_private *cm_id_priv, cm_format_rep()
1619 cm_format_mad_hdr(&rep_msg->hdr, CM_REP_ATTR_ID, cm_id_priv->tid); cm_format_rep()
1620 rep_msg->local_comm_id = cm_id_priv->id.local_id; cm_format_rep()
1621 rep_msg->remote_comm_id = cm_id_priv->id.remote_id; cm_format_rep()
1625 cm_id_priv->av.port->cm_dev->ack_delay); cm_format_rep()
1628 rep_msg->local_ca_guid = cm_id_priv->id.device->node_guid; cm_format_rep()
1630 if (cm_id_priv->qp_type != IB_QPT_XRC_TGT) { cm_format_rep()
1648 struct cm_id_private *cm_id_priv; ib_send_cm_rep() local
1658 cm_id_priv = container_of(cm_id, struct cm_id_private, id); ib_send_cm_rep()
1659 spin_lock_irqsave(&cm_id_priv->lock, flags); ib_send_cm_rep()
1666 ret = cm_alloc_msg(cm_id_priv, &msg); ib_send_cm_rep()
1671 cm_format_rep(rep_msg, cm_id_priv, param); ib_send_cm_rep()
1672 msg->timeout_ms = cm_id_priv->timeout_ms; ib_send_cm_rep()
1677 spin_unlock_irqrestore(&cm_id_priv->lock, flags); ib_send_cm_rep()
1683 cm_id_priv->msg = msg; ib_send_cm_rep()
1684 cm_id_priv->initiator_depth = param->initiator_depth; ib_send_cm_rep()
1685 cm_id_priv->responder_resources = param->responder_resources; ib_send_cm_rep()
1686 cm_id_priv->rq_psn = cm_rep_get_starting_psn(rep_msg); ib_send_cm_rep()
1687 cm_id_priv->local_qpn = cpu_to_be32(param->qp_num & 0xFFFFFF); ib_send_cm_rep()
1689 out: spin_unlock_irqrestore(&cm_id_priv->lock, flags); ib_send_cm_rep()
1695 struct cm_id_private *cm_id_priv, cm_format_rtu()
1699 cm_format_mad_hdr(&rtu_msg->hdr, CM_RTU_ATTR_ID, cm_id_priv->tid); cm_format_rtu()
1700 rtu_msg->local_comm_id = cm_id_priv->id.local_id; cm_format_rtu()
1701 rtu_msg->remote_comm_id = cm_id_priv->id.remote_id; cm_format_rtu()
1711 struct cm_id_private *cm_id_priv; ib_send_cm_rtu() local
1724 cm_id_priv = container_of(cm_id, struct cm_id_private, id); ib_send_cm_rtu()
1725 spin_lock_irqsave(&cm_id_priv->lock, flags); ib_send_cm_rtu()
1732 ret = cm_alloc_msg(cm_id_priv, &msg); ib_send_cm_rtu()
1736 cm_format_rtu((struct cm_rtu_msg *) msg->mad, cm_id_priv, ib_send_cm_rtu()
1741 spin_unlock_irqrestore(&cm_id_priv->lock, flags); ib_send_cm_rtu()
1748 cm_set_private_data(cm_id_priv, data, private_data_len); ib_send_cm_rtu()
1749 spin_unlock_irqrestore(&cm_id_priv->lock, flags); ib_send_cm_rtu()
1752 error: spin_unlock_irqrestore(&cm_id_priv->lock, flags); ib_send_cm_rtu()
1781 struct cm_id_private *cm_id_priv; cm_dup_rep_handler() local
1787 cm_id_priv = cm_acquire_id(rep_msg->remote_comm_id, cm_dup_rep_handler()
1789 if (!cm_id_priv) cm_dup_rep_handler()
1798 spin_lock_irq(&cm_id_priv->lock); cm_dup_rep_handler()
1799 if (cm_id_priv->id.state == IB_CM_ESTABLISHED) cm_dup_rep_handler()
1800 cm_format_rtu((struct cm_rtu_msg *) msg->mad, cm_id_priv, cm_dup_rep_handler()
1801 cm_id_priv->private_data, cm_dup_rep_handler()
1802 cm_id_priv->private_data_len); cm_dup_rep_handler()
1803 else if (cm_id_priv->id.state == IB_CM_MRA_REP_SENT) cm_dup_rep_handler()
1804 cm_format_mra((struct cm_mra_msg *) msg->mad, cm_id_priv, cm_dup_rep_handler()
1805 CM_MSG_RESPONSE_REP, cm_id_priv->service_timeout, cm_dup_rep_handler()
1806 cm_id_priv->private_data, cm_dup_rep_handler()
1807 cm_id_priv->private_data_len); cm_dup_rep_handler()
1810 spin_unlock_irq(&cm_id_priv->lock); cm_dup_rep_handler()
1817 unlock: spin_unlock_irq(&cm_id_priv->lock); cm_dup_rep_handler()
1819 deref: cm_deref_id(cm_id_priv); cm_dup_rep_handler()
1824 struct cm_id_private *cm_id_priv; cm_rep_handler() local
1829 cm_id_priv = cm_acquire_id(rep_msg->remote_comm_id, 0); cm_rep_handler()
1830 if (!cm_id_priv) { cm_rep_handler()
1835 cm_format_rep_event(work, cm_id_priv->qp_type); cm_rep_handler()
1837 spin_lock_irq(&cm_id_priv->lock); cm_rep_handler()
1838 switch (cm_id_priv->id.state) { cm_rep_handler()
1843 spin_unlock_irq(&cm_id_priv->lock); cm_rep_handler()
1848 cm_id_priv->timewait_info->work.remote_id = rep_msg->local_comm_id; cm_rep_handler()
1849 cm_id_priv->timewait_info->remote_ca_guid = rep_msg->local_ca_guid; cm_rep_handler()
1850 cm_id_priv->timewait_info->remote_qpn = cm_rep_get_qpn(rep_msg, cm_id_priv->qp_type); cm_rep_handler()
1854 if (cm_insert_remote_id(cm_id_priv->timewait_info)) { cm_rep_handler()
1856 spin_unlock_irq(&cm_id_priv->lock); cm_rep_handler()
1861 if (cm_insert_remote_qpn(cm_id_priv->timewait_info)) { cm_rep_handler()
1862 rb_erase(&cm_id_priv->timewait_info->remote_id_node, cm_rep_handler()
1864 cm_id_priv->timewait_info->inserted_remote_id = 0; cm_rep_handler()
1866 spin_unlock_irq(&cm_id_priv->lock); cm_rep_handler()
1875 cm_id_priv->id.state = IB_CM_REP_RCVD; cm_rep_handler()
1876 cm_id_priv->id.remote_id = rep_msg->local_comm_id; cm_rep_handler()
1877 cm_id_priv->remote_qpn = cm_rep_get_qpn(rep_msg, cm_id_priv->qp_type); cm_rep_handler()
1878 cm_id_priv->initiator_depth = rep_msg->resp_resources; cm_rep_handler()
1879 cm_id_priv->responder_resources = rep_msg->initiator_depth; cm_rep_handler()
1880 cm_id_priv->sq_psn = cm_rep_get_starting_psn(rep_msg); cm_rep_handler()
1881 cm_id_priv->rnr_retry_count = cm_rep_get_rnr_retry_count(rep_msg); cm_rep_handler()
1882 cm_id_priv->target_ack_delay = cm_rep_get_target_ack_delay(rep_msg); cm_rep_handler()
1883 cm_id_priv->av.timeout = cm_rep_handler()
1884 cm_ack_timeout(cm_id_priv->target_ack_delay, cm_rep_handler()
1885 cm_id_priv->av.timeout - 1); cm_rep_handler()
1886 cm_id_priv->alt_av.timeout = cm_rep_handler()
1887 cm_ack_timeout(cm_id_priv->target_ack_delay, cm_rep_handler()
1888 cm_id_priv->alt_av.timeout - 1); cm_rep_handler()
1892 ib_cancel_mad(cm_id_priv->av.port->mad_agent, cm_id_priv->msg); cm_rep_handler()
1893 ret = atomic_inc_and_test(&cm_id_priv->work_count); cm_rep_handler()
1895 list_add_tail(&work->list, &cm_id_priv->work_list); cm_rep_handler()
1896 spin_unlock_irq(&cm_id_priv->lock); cm_rep_handler()
1899 cm_process_work(cm_id_priv, work); cm_rep_handler()
1901 cm_deref_id(cm_id_priv); cm_rep_handler()
1905 cm_deref_id(cm_id_priv); cm_rep_handler()
1911 struct cm_id_private *cm_id_priv; cm_establish_handler() local
1915 cm_id_priv = cm_acquire_id(work->local_id, work->remote_id); cm_establish_handler()
1916 if (!cm_id_priv) cm_establish_handler()
1919 spin_lock_irq(&cm_id_priv->lock); cm_establish_handler()
1920 if (cm_id_priv->id.state != IB_CM_ESTABLISHED) { cm_establish_handler()
1921 spin_unlock_irq(&cm_id_priv->lock); cm_establish_handler()
1925 ib_cancel_mad(cm_id_priv->av.port->mad_agent, cm_id_priv->msg); cm_establish_handler()
1926 ret = atomic_inc_and_test(&cm_id_priv->work_count); cm_establish_handler()
1928 list_add_tail(&work->list, &cm_id_priv->work_list); cm_establish_handler()
1929 spin_unlock_irq(&cm_id_priv->lock); cm_establish_handler()
1932 cm_process_work(cm_id_priv, work); cm_establish_handler()
1934 cm_deref_id(cm_id_priv); cm_establish_handler()
1937 cm_deref_id(cm_id_priv); cm_establish_handler()
1943 struct cm_id_private *cm_id_priv; cm_rtu_handler() local
1948 cm_id_priv = cm_acquire_id(rtu_msg->remote_comm_id, cm_rtu_handler()
1950 if (!cm_id_priv) cm_rtu_handler()
1955 spin_lock_irq(&cm_id_priv->lock); cm_rtu_handler()
1956 if (cm_id_priv->id.state != IB_CM_REP_SENT && cm_rtu_handler()
1957 cm_id_priv->id.state != IB_CM_MRA_REP_RCVD) { cm_rtu_handler()
1958 spin_unlock_irq(&cm_id_priv->lock); cm_rtu_handler()
1963 cm_id_priv->id.state = IB_CM_ESTABLISHED; cm_rtu_handler()
1965 ib_cancel_mad(cm_id_priv->av.port->mad_agent, cm_id_priv->msg); cm_rtu_handler()
1966 ret = atomic_inc_and_test(&cm_id_priv->work_count); cm_rtu_handler()
1968 list_add_tail(&work->list, &cm_id_priv->work_list); cm_rtu_handler()
1969 spin_unlock_irq(&cm_id_priv->lock); cm_rtu_handler()
1972 cm_process_work(cm_id_priv, work); cm_rtu_handler()
1974 cm_deref_id(cm_id_priv); cm_rtu_handler()
1977 cm_deref_id(cm_id_priv); cm_rtu_handler()
1982 struct cm_id_private *cm_id_priv, cm_format_dreq()
1987 cm_form_tid(cm_id_priv, CM_MSG_SEQUENCE_DREQ)); cm_format_dreq()
1988 dreq_msg->local_comm_id = cm_id_priv->id.local_id; cm_format_dreq()
1989 dreq_msg->remote_comm_id = cm_id_priv->id.remote_id; cm_format_dreq()
1990 cm_dreq_set_remote_qpn(dreq_msg, cm_id_priv->remote_qpn); cm_format_dreq()
2000 struct cm_id_private *cm_id_priv; ib_send_cm_dreq() local
2008 cm_id_priv = container_of(cm_id, struct cm_id_private, id); ib_send_cm_dreq()
2009 spin_lock_irqsave(&cm_id_priv->lock, flags); ib_send_cm_dreq()
2017 ib_cancel_mad(cm_id_priv->av.port->mad_agent, cm_id_priv->msg); ib_send_cm_dreq()
2019 ret = cm_alloc_msg(cm_id_priv, &msg); ib_send_cm_dreq()
2021 cm_enter_timewait(cm_id_priv); ib_send_cm_dreq()
2025 cm_format_dreq((struct cm_dreq_msg *) msg->mad, cm_id_priv, ib_send_cm_dreq()
2027 msg->timeout_ms = cm_id_priv->timeout_ms; ib_send_cm_dreq()
2032 cm_enter_timewait(cm_id_priv); ib_send_cm_dreq()
2033 spin_unlock_irqrestore(&cm_id_priv->lock, flags); ib_send_cm_dreq()
2039 cm_id_priv->msg = msg; ib_send_cm_dreq()
2040 out: spin_unlock_irqrestore(&cm_id_priv->lock, flags); ib_send_cm_dreq()
2046 struct cm_id_private *cm_id_priv, cm_format_drep()
2050 cm_format_mad_hdr(&drep_msg->hdr, CM_DREP_ATTR_ID, cm_id_priv->tid); cm_format_drep()
2051 drep_msg->local_comm_id = cm_id_priv->id.local_id; cm_format_drep()
2052 drep_msg->remote_comm_id = cm_id_priv->id.remote_id; cm_format_drep()
2062 struct cm_id_private *cm_id_priv; ib_send_cm_drep() local
2075 cm_id_priv = container_of(cm_id, struct cm_id_private, id); ib_send_cm_drep()
2076 spin_lock_irqsave(&cm_id_priv->lock, flags); ib_send_cm_drep()
2078 spin_unlock_irqrestore(&cm_id_priv->lock, flags); ib_send_cm_drep()
2083 cm_set_private_data(cm_id_priv, data, private_data_len); ib_send_cm_drep()
2084 cm_enter_timewait(cm_id_priv); ib_send_cm_drep()
2086 ret = cm_alloc_msg(cm_id_priv, &msg); ib_send_cm_drep()
2090 cm_format_drep((struct cm_drep_msg *) msg->mad, cm_id_priv, ib_send_cm_drep()
2095 spin_unlock_irqrestore(&cm_id_priv->lock, flags); ib_send_cm_drep()
2100 out: spin_unlock_irqrestore(&cm_id_priv->lock, flags); ib_send_cm_drep()
2133 struct cm_id_private *cm_id_priv; cm_dreq_handler() local
2139 cm_id_priv = cm_acquire_id(dreq_msg->remote_comm_id, cm_dreq_handler()
2141 if (!cm_id_priv) { cm_dreq_handler()
2150 spin_lock_irq(&cm_id_priv->lock); cm_dreq_handler()
2151 if (cm_id_priv->local_qpn != cm_dreq_get_remote_qpn(dreq_msg)) cm_dreq_handler()
2154 switch (cm_id_priv->id.state) { cm_dreq_handler()
2157 ib_cancel_mad(cm_id_priv->av.port->mad_agent, cm_id_priv->msg); cm_dreq_handler()
2160 if (cm_id_priv->id.lap_state == IB_CM_LAP_SENT || cm_dreq_handler()
2161 cm_id_priv->id.lap_state == IB_CM_MRA_LAP_RCVD) cm_dreq_handler()
2162 ib_cancel_mad(cm_id_priv->av.port->mad_agent, cm_id_priv->msg); cm_dreq_handler()
2172 cm_format_drep((struct cm_drep_msg *) msg->mad, cm_id_priv, cm_dreq_handler()
2173 cm_id_priv->private_data, cm_dreq_handler()
2174 cm_id_priv->private_data_len); cm_dreq_handler()
2175 spin_unlock_irq(&cm_id_priv->lock); cm_dreq_handler()
2187 cm_id_priv->id.state = IB_CM_DREQ_RCVD; cm_dreq_handler()
2188 cm_id_priv->tid = dreq_msg->hdr.tid; cm_dreq_handler()
2189 ret = atomic_inc_and_test(&cm_id_priv->work_count); cm_dreq_handler()
2191 list_add_tail(&work->list, &cm_id_priv->work_list); cm_dreq_handler()
2192 spin_unlock_irq(&cm_id_priv->lock); cm_dreq_handler()
2195 cm_process_work(cm_id_priv, work); cm_dreq_handler()
2197 cm_deref_id(cm_id_priv); cm_dreq_handler()
2200 unlock: spin_unlock_irq(&cm_id_priv->lock); cm_dreq_handler()
2201 deref: cm_deref_id(cm_id_priv); cm_dreq_handler()
2207 struct cm_id_private *cm_id_priv; cm_drep_handler() local
2212 cm_id_priv = cm_acquire_id(drep_msg->remote_comm_id, cm_drep_handler()
2214 if (!cm_id_priv) cm_drep_handler()
2219 spin_lock_irq(&cm_id_priv->lock); cm_drep_handler()
2220 if (cm_id_priv->id.state != IB_CM_DREQ_SENT && cm_drep_handler()
2221 cm_id_priv->id.state != IB_CM_DREQ_RCVD) { cm_drep_handler()
2222 spin_unlock_irq(&cm_id_priv->lock); cm_drep_handler()
2225 cm_enter_timewait(cm_id_priv); cm_drep_handler()
2227 ib_cancel_mad(cm_id_priv->av.port->mad_agent, cm_id_priv->msg); cm_drep_handler()
2228 ret = atomic_inc_and_test(&cm_id_priv->work_count); cm_drep_handler()
2230 list_add_tail(&work->list, &cm_id_priv->work_list); cm_drep_handler()
2231 spin_unlock_irq(&cm_id_priv->lock); cm_drep_handler()
2234 cm_process_work(cm_id_priv, work); cm_drep_handler()
2236 cm_deref_id(cm_id_priv); cm_drep_handler()
2239 cm_deref_id(cm_id_priv); cm_drep_handler()
2250 struct cm_id_private *cm_id_priv; ib_send_cm_rej() local
2259 cm_id_priv = container_of(cm_id, struct cm_id_private, id); ib_send_cm_rej()
2261 spin_lock_irqsave(&cm_id_priv->lock, flags); ib_send_cm_rej()
2269 ret = cm_alloc_msg(cm_id_priv, &msg); ib_send_cm_rej()
2272 cm_id_priv, reason, ari, ari_length, ib_send_cm_rej()
2275 cm_reset_to_idle(cm_id_priv); ib_send_cm_rej()
2279 ret = cm_alloc_msg(cm_id_priv, &msg); ib_send_cm_rej()
2282 cm_id_priv, reason, ari, ari_length, ib_send_cm_rej()
2285 cm_enter_timewait(cm_id_priv); ib_send_cm_rej()
2299 out: spin_unlock_irqrestore(&cm_id_priv->lock, flags); ib_send_cm_rej()
2320 struct cm_id_private *cm_id_priv; cm_acquire_rejected_id() local
2333 cm_id_priv = idr_find(&cm.local_id_table, (__force int) cm_acquire_rejected_id()
2336 if (cm_id_priv) { cm_acquire_rejected_id()
2337 if (cm_id_priv->id.remote_id == remote_id) cm_acquire_rejected_id()
2338 atomic_inc(&cm_id_priv->refcount); cm_acquire_rejected_id()
2340 cm_id_priv = NULL; cm_acquire_rejected_id()
2344 cm_id_priv = cm_acquire_id(rej_msg->remote_comm_id, 0); cm_acquire_rejected_id()
2346 cm_id_priv = cm_acquire_id(rej_msg->remote_comm_id, remote_id); cm_acquire_rejected_id()
2348 return cm_id_priv; cm_acquire_rejected_id()
2353 struct cm_id_private *cm_id_priv; cm_rej_handler() local
2358 cm_id_priv = cm_acquire_rejected_id(rej_msg); cm_rej_handler()
2359 if (!cm_id_priv) cm_rej_handler()
2364 spin_lock_irq(&cm_id_priv->lock); cm_rej_handler()
2365 switch (cm_id_priv->id.state) { cm_rej_handler()
2370 ib_cancel_mad(cm_id_priv->av.port->mad_agent, cm_id_priv->msg); cm_rej_handler()
2375 cm_enter_timewait(cm_id_priv); cm_rej_handler()
2377 cm_reset_to_idle(cm_id_priv); cm_rej_handler()
2380 ib_cancel_mad(cm_id_priv->av.port->mad_agent, cm_id_priv->msg); cm_rej_handler()
2384 cm_enter_timewait(cm_id_priv); cm_rej_handler()
2387 if (cm_id_priv->id.lap_state == IB_CM_LAP_UNINIT || cm_rej_handler()
2388 cm_id_priv->id.lap_state == IB_CM_LAP_SENT) { cm_rej_handler()
2389 if (cm_id_priv->id.lap_state == IB_CM_LAP_SENT) cm_rej_handler()
2390 ib_cancel_mad(cm_id_priv->av.port->mad_agent, cm_rej_handler()
2391 cm_id_priv->msg); cm_rej_handler()
2392 cm_enter_timewait(cm_id_priv); cm_rej_handler()
2397 spin_unlock_irq(&cm_id_priv->lock); cm_rej_handler()
2402 ret = atomic_inc_and_test(&cm_id_priv->work_count); cm_rej_handler()
2404 list_add_tail(&work->list, &cm_id_priv->work_list); cm_rej_handler()
2405 spin_unlock_irq(&cm_id_priv->lock); cm_rej_handler()
2408 cm_process_work(cm_id_priv, work); cm_rej_handler()
2410 cm_deref_id(cm_id_priv); cm_rej_handler()
2413 cm_deref_id(cm_id_priv); cm_rej_handler()
2422 struct cm_id_private *cm_id_priv; ib_send_cm_mra() local
2438 cm_id_priv = container_of(cm_id, struct cm_id_private, id); ib_send_cm_mra()
2440 spin_lock_irqsave(&cm_id_priv->lock, flags); ib_send_cm_mra()
2441 switch(cm_id_priv->id.state) { ib_send_cm_mra()
2465 ret = cm_alloc_msg(cm_id_priv, &msg); ib_send_cm_mra()
2469 cm_format_mra((struct cm_mra_msg *) msg->mad, cm_id_priv, ib_send_cm_mra()
2479 cm_id_priv->service_timeout = service_timeout; ib_send_cm_mra()
2480 cm_set_private_data(cm_id_priv, data, private_data_len); ib_send_cm_mra()
2481 spin_unlock_irqrestore(&cm_id_priv->lock, flags); ib_send_cm_mra()
2484 error1: spin_unlock_irqrestore(&cm_id_priv->lock, flags); ib_send_cm_mra()
2488 error2: spin_unlock_irqrestore(&cm_id_priv->lock, flags); ib_send_cm_mra()
2511 struct cm_id_private *cm_id_priv; cm_mra_handler() local
2516 cm_id_priv = cm_acquire_mraed_id(mra_msg); cm_mra_handler()
2517 if (!cm_id_priv) cm_mra_handler()
2524 cm_convert_to_ms(cm_id_priv->av.timeout); cm_mra_handler()
2526 spin_lock_irq(&cm_id_priv->lock); cm_mra_handler()
2527 switch (cm_id_priv->id.state) { cm_mra_handler()
2530 ib_modify_mad(cm_id_priv->av.port->mad_agent, cm_mra_handler()
2531 cm_id_priv->msg, timeout)) cm_mra_handler()
2533 cm_id_priv->id.state = IB_CM_MRA_REQ_RCVD; cm_mra_handler()
2537 ib_modify_mad(cm_id_priv->av.port->mad_agent, cm_mra_handler()
2538 cm_id_priv->msg, timeout)) cm_mra_handler()
2540 cm_id_priv->id.state = IB_CM_MRA_REP_RCVD; cm_mra_handler()
2544 cm_id_priv->id.lap_state != IB_CM_LAP_SENT || cm_mra_handler()
2545 ib_modify_mad(cm_id_priv->av.port->mad_agent, cm_mra_handler()
2546 cm_id_priv->msg, timeout)) { cm_mra_handler()
2547 if (cm_id_priv->id.lap_state == IB_CM_MRA_LAP_RCVD) cm_mra_handler()
2553 cm_id_priv->id.lap_state = IB_CM_MRA_LAP_RCVD; cm_mra_handler()
2564 cm_id_priv->msg->context[1] = (void *) (unsigned long) cm_mra_handler()
2565 cm_id_priv->id.state; cm_mra_handler()
2566 ret = atomic_inc_and_test(&cm_id_priv->work_count); cm_mra_handler()
2568 list_add_tail(&work->list, &cm_id_priv->work_list); cm_mra_handler()
2569 spin_unlock_irq(&cm_id_priv->lock); cm_mra_handler()
2572 cm_process_work(cm_id_priv, work); cm_mra_handler()
2574 cm_deref_id(cm_id_priv); cm_mra_handler()
2577 spin_unlock_irq(&cm_id_priv->lock); cm_mra_handler()
2578 cm_deref_id(cm_id_priv); cm_mra_handler()
2583 struct cm_id_private *cm_id_priv, cm_format_lap()
2589 cm_form_tid(cm_id_priv, CM_MSG_SEQUENCE_LAP)); cm_format_lap()
2590 lap_msg->local_comm_id = cm_id_priv->id.local_id; cm_format_lap()
2591 lap_msg->remote_comm_id = cm_id_priv->id.remote_id; cm_format_lap()
2592 cm_lap_set_remote_qpn(lap_msg, cm_id_priv->remote_qpn); cm_format_lap()
2606 cm_ack_timeout(cm_id_priv->av.port->cm_dev->ack_delay, cm_format_lap()
2618 struct cm_id_private *cm_id_priv; ib_send_cm_lap() local
2626 cm_id_priv = container_of(cm_id, struct cm_id_private, id); ib_send_cm_lap()
2627 spin_lock_irqsave(&cm_id_priv->lock, flags); ib_send_cm_lap()
2635 ret = cm_init_av_by_path(alternate_path, &cm_id_priv->alt_av); ib_send_cm_lap()
2638 cm_id_priv->alt_av.timeout = ib_send_cm_lap()
2639 cm_ack_timeout(cm_id_priv->target_ack_delay, ib_send_cm_lap()
2640 cm_id_priv->alt_av.timeout - 1); ib_send_cm_lap()
2642 ret = cm_alloc_msg(cm_id_priv, &msg); ib_send_cm_lap()
2646 cm_format_lap((struct cm_lap_msg *) msg->mad, cm_id_priv, ib_send_cm_lap()
2648 msg->timeout_ms = cm_id_priv->timeout_ms; ib_send_cm_lap()
2653 spin_unlock_irqrestore(&cm_id_priv->lock, flags); ib_send_cm_lap()
2659 cm_id_priv->msg = msg; ib_send_cm_lap()
2661 out: spin_unlock_irqrestore(&cm_id_priv->lock, flags); ib_send_cm_lap()
2666 static void cm_format_path_from_lap(struct cm_id_private *cm_id_priv, cm_format_path_from_lap() argument
2679 path->pkey = cm_id_priv->pkey; cm_format_path_from_lap()
2682 path->mtu = cm_id_priv->path_mtu; cm_format_path_from_lap()
2692 struct cm_id_private *cm_id_priv; cm_lap_handler() local
2700 cm_id_priv = cm_acquire_id(lap_msg->remote_comm_id, cm_lap_handler()
2702 if (!cm_id_priv) cm_lap_handler()
2707 cm_format_path_from_lap(cm_id_priv, param->alternate_path, lap_msg); cm_lap_handler()
2710 spin_lock_irq(&cm_id_priv->lock); cm_lap_handler()
2711 if (cm_id_priv->id.state != IB_CM_ESTABLISHED) cm_lap_handler()
2714 switch (cm_id_priv->id.lap_state) { cm_lap_handler()
2724 cm_format_mra((struct cm_mra_msg *) msg->mad, cm_id_priv, cm_lap_handler()
2726 cm_id_priv->service_timeout, cm_lap_handler()
2727 cm_id_priv->private_data, cm_lap_handler()
2728 cm_id_priv->private_data_len); cm_lap_handler()
2729 spin_unlock_irq(&cm_id_priv->lock); cm_lap_handler()
2742 cm_id_priv->id.lap_state = IB_CM_LAP_RCVD; cm_lap_handler()
2743 cm_id_priv->tid = lap_msg->hdr.tid; cm_lap_handler()
2746 &cm_id_priv->av); cm_lap_handler()
2747 cm_init_av_by_path(param->alternate_path, &cm_id_priv->alt_av); cm_lap_handler()
2748 ret = atomic_inc_and_test(&cm_id_priv->work_count); cm_lap_handler()
2750 list_add_tail(&work->list, &cm_id_priv->work_list); cm_lap_handler()
2751 spin_unlock_irq(&cm_id_priv->lock); cm_lap_handler()
2754 cm_process_work(cm_id_priv, work); cm_lap_handler()
2756 cm_deref_id(cm_id_priv); cm_lap_handler()
2759 unlock: spin_unlock_irq(&cm_id_priv->lock); cm_lap_handler()
2760 deref: cm_deref_id(cm_id_priv); cm_lap_handler()
2765 struct cm_id_private *cm_id_priv, cm_format_apr()
2772 cm_format_mad_hdr(&apr_msg->hdr, CM_APR_ATTR_ID, cm_id_priv->tid); cm_format_apr()
2773 apr_msg->local_comm_id = cm_id_priv->id.local_id; cm_format_apr()
2774 apr_msg->remote_comm_id = cm_id_priv->id.remote_id; cm_format_apr()
2793 struct cm_id_private *cm_id_priv; ib_send_cm_apr() local
2802 cm_id_priv = container_of(cm_id, struct cm_id_private, id); ib_send_cm_apr()
2803 spin_lock_irqsave(&cm_id_priv->lock, flags); ib_send_cm_apr()
2811 ret = cm_alloc_msg(cm_id_priv, &msg); ib_send_cm_apr()
2815 cm_format_apr((struct cm_apr_msg *) msg->mad, cm_id_priv, status, ib_send_cm_apr()
2819 spin_unlock_irqrestore(&cm_id_priv->lock, flags); ib_send_cm_apr()
2825 out: spin_unlock_irqrestore(&cm_id_priv->lock, flags); ib_send_cm_apr()
2832 struct cm_id_private *cm_id_priv; cm_apr_handler() local
2837 cm_id_priv = cm_acquire_id(apr_msg->remote_comm_id, cm_apr_handler()
2839 if (!cm_id_priv) cm_apr_handler()
2847 spin_lock_irq(&cm_id_priv->lock); cm_apr_handler()
2848 if (cm_id_priv->id.state != IB_CM_ESTABLISHED || cm_apr_handler()
2849 (cm_id_priv->id.lap_state != IB_CM_LAP_SENT && cm_apr_handler()
2850 cm_id_priv->id.lap_state != IB_CM_MRA_LAP_RCVD)) { cm_apr_handler()
2851 spin_unlock_irq(&cm_id_priv->lock); cm_apr_handler()
2854 cm_id_priv->id.lap_state = IB_CM_LAP_IDLE; cm_apr_handler()
2855 ib_cancel_mad(cm_id_priv->av.port->mad_agent, cm_id_priv->msg); cm_apr_handler()
2856 cm_id_priv->msg = NULL; cm_apr_handler()
2858 ret = atomic_inc_and_test(&cm_id_priv->work_count); cm_apr_handler()
2860 list_add_tail(&work->list, &cm_id_priv->work_list); cm_apr_handler()
2861 spin_unlock_irq(&cm_id_priv->lock); cm_apr_handler()
2864 cm_process_work(cm_id_priv, work); cm_apr_handler()
2866 cm_deref_id(cm_id_priv); cm_apr_handler()
2869 cm_deref_id(cm_id_priv); cm_apr_handler()
2876 struct cm_id_private *cm_id_priv; cm_timewait_handler() local
2884 cm_id_priv = cm_acquire_id(timewait_info->work.local_id, cm_timewait_handler()
2886 if (!cm_id_priv) cm_timewait_handler()
2889 spin_lock_irq(&cm_id_priv->lock); cm_timewait_handler()
2890 if (cm_id_priv->id.state != IB_CM_TIMEWAIT || cm_timewait_handler()
2891 cm_id_priv->remote_qpn != timewait_info->remote_qpn) { cm_timewait_handler()
2892 spin_unlock_irq(&cm_id_priv->lock); cm_timewait_handler()
2895 cm_id_priv->id.state = IB_CM_IDLE; cm_timewait_handler()
2896 ret = atomic_inc_and_test(&cm_id_priv->work_count); cm_timewait_handler()
2898 list_add_tail(&work->list, &cm_id_priv->work_list); cm_timewait_handler()
2899 spin_unlock_irq(&cm_id_priv->lock); cm_timewait_handler()
2902 cm_process_work(cm_id_priv, work); cm_timewait_handler()
2904 cm_deref_id(cm_id_priv); cm_timewait_handler()
2907 cm_deref_id(cm_id_priv); cm_timewait_handler()
2912 struct cm_id_private *cm_id_priv, cm_format_sidr_req()
2916 cm_form_tid(cm_id_priv, CM_MSG_SEQUENCE_SIDR)); cm_format_sidr_req()
2917 sidr_req_msg->request_id = cm_id_priv->id.local_id; cm_format_sidr_req()
2929 struct cm_id_private *cm_id_priv; ib_send_cm_sidr_req() local
2938 cm_id_priv = container_of(cm_id, struct cm_id_private, id); ib_send_cm_sidr_req()
2939 ret = cm_init_av_by_path(param->path, &cm_id_priv->av); ib_send_cm_sidr_req()
2945 cm_id_priv->timeout_ms = param->timeout_ms; ib_send_cm_sidr_req()
2946 cm_id_priv->max_cm_retries = param->max_cm_retries; ib_send_cm_sidr_req()
2947 ret = cm_alloc_msg(cm_id_priv, &msg); ib_send_cm_sidr_req()
2951 cm_format_sidr_req((struct cm_sidr_req_msg *) msg->mad, cm_id_priv, ib_send_cm_sidr_req()
2953 msg->timeout_ms = cm_id_priv->timeout_ms; ib_send_cm_sidr_req()
2956 spin_lock_irqsave(&cm_id_priv->lock, flags); ib_send_cm_sidr_req()
2963 spin_unlock_irqrestore(&cm_id_priv->lock, flags); ib_send_cm_sidr_req()
2968 cm_id_priv->msg = msg; ib_send_cm_sidr_req()
2969 spin_unlock_irqrestore(&cm_id_priv->lock, flags); ib_send_cm_sidr_req()
2993 struct cm_id_private *cm_id_priv, *cur_cm_id_priv; cm_sidr_req_handler() local
3000 cm_id_priv = container_of(cm_id, struct cm_id_private, id); cm_sidr_req_handler()
3006 cm_id_priv->av.dgid.global.subnet_prefix = cpu_to_be64(wc->slid); cm_sidr_req_handler()
3007 cm_id_priv->av.dgid.global.interface_id = 0; cm_sidr_req_handler()
3010 &cm_id_priv->av); cm_sidr_req_handler()
3011 cm_id_priv->id.remote_id = sidr_req_msg->request_id; cm_sidr_req_handler()
3012 cm_id_priv->tid = sidr_req_msg->hdr.tid; cm_sidr_req_handler()
3013 atomic_inc(&cm_id_priv->work_count); cm_sidr_req_handler()
3016 cur_cm_id_priv = cm_insert_remote_sidr(cm_id_priv); cm_sidr_req_handler()
3023 cm_id_priv->id.state = IB_CM_SIDR_REQ_RCVD; cm_sidr_req_handler()
3029 cm_reject_sidr_req(cm_id_priv, IB_SIDR_UNSUPPORTED); cm_sidr_req_handler()
3033 atomic_inc(&cm_id_priv->refcount); cm_sidr_req_handler()
3036 cm_id_priv->id.cm_handler = cur_cm_id_priv->id.cm_handler; cm_sidr_req_handler()
3037 cm_id_priv->id.context = cur_cm_id_priv->id.context; cm_sidr_req_handler()
3038 cm_id_priv->id.service_id = sidr_req_msg->service_id; cm_sidr_req_handler()
3039 cm_id_priv->id.service_mask = ~cpu_to_be64(0); cm_sidr_req_handler()
3042 cm_process_work(cm_id_priv, work); cm_sidr_req_handler()
3046 ib_destroy_cm_id(&cm_id_priv->id); cm_sidr_req_handler()
3051 struct cm_id_private *cm_id_priv, cm_format_sidr_rep()
3055 cm_id_priv->tid); cm_format_sidr_rep()
3056 sidr_rep_msg->request_id = cm_id_priv->id.remote_id; cm_format_sidr_rep()
3059 sidr_rep_msg->service_id = cm_id_priv->id.service_id; cm_format_sidr_rep()
3073 struct cm_id_private *cm_id_priv; ib_send_cm_sidr_rep() local
3083 cm_id_priv = container_of(cm_id, struct cm_id_private, id); ib_send_cm_sidr_rep()
3084 spin_lock_irqsave(&cm_id_priv->lock, flags); ib_send_cm_sidr_rep()
3090 ret = cm_alloc_msg(cm_id_priv, &msg); ib_send_cm_sidr_rep()
3094 cm_format_sidr_rep((struct cm_sidr_rep_msg *) msg->mad, cm_id_priv, ib_send_cm_sidr_rep()
3098 spin_unlock_irqrestore(&cm_id_priv->lock, flags); ib_send_cm_sidr_rep()
3103 spin_unlock_irqrestore(&cm_id_priv->lock, flags); ib_send_cm_sidr_rep()
3106 if (!RB_EMPTY_NODE(&cm_id_priv->sidr_id_node)) { ib_send_cm_sidr_rep()
3107 rb_erase(&cm_id_priv->sidr_id_node, &cm.remote_sidr_table); ib_send_cm_sidr_rep()
3108 RB_CLEAR_NODE(&cm_id_priv->sidr_id_node); ib_send_cm_sidr_rep()
3113 error: spin_unlock_irqrestore(&cm_id_priv->lock, flags); ib_send_cm_sidr_rep()
3137 struct cm_id_private *cm_id_priv; cm_sidr_rep_handler() local
3141 cm_id_priv = cm_acquire_id(sidr_rep_msg->request_id, 0); cm_sidr_rep_handler()
3142 if (!cm_id_priv) cm_sidr_rep_handler()
3145 spin_lock_irq(&cm_id_priv->lock); cm_sidr_rep_handler()
3146 if (cm_id_priv->id.state != IB_CM_SIDR_REQ_SENT) { cm_sidr_rep_handler()
3147 spin_unlock_irq(&cm_id_priv->lock); cm_sidr_rep_handler()
3150 cm_id_priv->id.state = IB_CM_IDLE; cm_sidr_rep_handler()
3151 ib_cancel_mad(cm_id_priv->av.port->mad_agent, cm_id_priv->msg); cm_sidr_rep_handler()
3152 spin_unlock_irq(&cm_id_priv->lock); cm_sidr_rep_handler()
3155 cm_process_work(cm_id_priv, work); cm_sidr_rep_handler()
3158 cm_deref_id(cm_id_priv); cm_sidr_rep_handler()
3165 struct cm_id_private *cm_id_priv; cm_process_send_error() local
3171 cm_id_priv = msg->context[0]; cm_process_send_error()
3174 spin_lock_irq(&cm_id_priv->lock); cm_process_send_error()
3176 if (msg != cm_id_priv->msg || state != cm_id_priv->id.state) cm_process_send_error()
3182 cm_reset_to_idle(cm_id_priv); cm_process_send_error()
3187 cm_reset_to_idle(cm_id_priv); cm_process_send_error()
3191 cm_enter_timewait(cm_id_priv); cm_process_send_error()
3195 cm_id_priv->id.state = IB_CM_IDLE; cm_process_send_error()
3201 spin_unlock_irq(&cm_id_priv->lock); cm_process_send_error()
3205 ret = cm_id_priv->id.cm_handler(&cm_id_priv->id, &cm_event); cm_process_send_error()
3208 ib_destroy_cm_id(&cm_id_priv->id); cm_process_send_error()
3211 spin_unlock_irq(&cm_id_priv->lock); cm_process_send_error()
3310 struct cm_id_private *cm_id_priv; cm_establish() local
3319 cm_id_priv = container_of(cm_id, struct cm_id_private, id); cm_establish()
3320 spin_lock_irqsave(&cm_id_priv->lock, flags); cm_establish()
3334 spin_unlock_irqrestore(&cm_id_priv->lock, flags); cm_establish()
3359 struct cm_id_private *cm_id_priv; cm_migrate() local
3363 cm_id_priv = container_of(cm_id, struct cm_id_private, id); cm_migrate()
3364 spin_lock_irqsave(&cm_id_priv->lock, flags); cm_migrate()
3369 cm_id_priv->av = cm_id_priv->alt_av; cm_migrate()
3372 spin_unlock_irqrestore(&cm_id_priv->lock, flags); cm_migrate()
3464 static int cm_init_qp_init_attr(struct cm_id_private *cm_id_priv, cm_init_qp_init_attr() argument
3471 spin_lock_irqsave(&cm_id_priv->lock, flags); cm_init_qp_init_attr()
3472 switch (cm_id_priv->id.state) { cm_init_qp_init_attr()
3485 if (cm_id_priv->responder_resources) cm_init_qp_init_attr()
3488 qp_attr->pkey_index = cm_id_priv->av.pkey_index; cm_init_qp_init_attr()
3489 qp_attr->port_num = cm_id_priv->av.port->port_num; cm_init_qp_init_attr()
3496 spin_unlock_irqrestore(&cm_id_priv->lock, flags); cm_init_qp_init_attr()
3500 static int cm_init_qp_rtr_attr(struct cm_id_private *cm_id_priv, cm_init_qp_rtr_attr() argument
3507 spin_lock_irqsave(&cm_id_priv->lock, flags); cm_init_qp_rtr_attr()
3508 switch (cm_id_priv->id.state) { cm_init_qp_rtr_attr()
3518 qp_attr->ah_attr = cm_id_priv->av.ah_attr; cm_init_qp_rtr_attr()
3519 if (!cm_id_priv->av.valid) { cm_init_qp_rtr_attr()
3520 spin_unlock_irqrestore(&cm_id_priv->lock, flags); cm_init_qp_rtr_attr()
3523 if (cm_id_priv->av.ah_attr.vlan_id != 0xffff) { cm_init_qp_rtr_attr()
3524 qp_attr->vlan_id = cm_id_priv->av.ah_attr.vlan_id; cm_init_qp_rtr_attr()
3527 if (!is_zero_ether_addr(cm_id_priv->av.smac)) { cm_init_qp_rtr_attr()
3528 memcpy(qp_attr->smac, cm_id_priv->av.smac, cm_init_qp_rtr_attr()
3532 if (cm_id_priv->alt_av.valid) { cm_init_qp_rtr_attr()
3533 if (cm_id_priv->alt_av.ah_attr.vlan_id != 0xffff) { cm_init_qp_rtr_attr()
3535 cm_id_priv->alt_av.ah_attr.vlan_id; cm_init_qp_rtr_attr()
3538 if (!is_zero_ether_addr(cm_id_priv->alt_av.smac)) { cm_init_qp_rtr_attr()
3540 cm_id_priv->alt_av.smac, cm_init_qp_rtr_attr()
3545 qp_attr->path_mtu = cm_id_priv->path_mtu; cm_init_qp_rtr_attr()
3546 qp_attr->dest_qp_num = be32_to_cpu(cm_id_priv->remote_qpn); cm_init_qp_rtr_attr()
3547 qp_attr->rq_psn = be32_to_cpu(cm_id_priv->rq_psn); cm_init_qp_rtr_attr()
3548 if (cm_id_priv->qp_type == IB_QPT_RC || cm_init_qp_rtr_attr()
3549 cm_id_priv->qp_type == IB_QPT_XRC_TGT) { cm_init_qp_rtr_attr()
3553 cm_id_priv->responder_resources; cm_init_qp_rtr_attr()
3556 if (cm_id_priv->alt_av.ah_attr.dlid) { cm_init_qp_rtr_attr()
3558 qp_attr->alt_port_num = cm_id_priv->alt_av.port->port_num; cm_init_qp_rtr_attr()
3559 qp_attr->alt_pkey_index = cm_id_priv->alt_av.pkey_index; cm_init_qp_rtr_attr()
3560 qp_attr->alt_timeout = cm_id_priv->alt_av.timeout; cm_init_qp_rtr_attr()
3561 qp_attr->alt_ah_attr = cm_id_priv->alt_av.ah_attr; cm_init_qp_rtr_attr()
3569 spin_unlock_irqrestore(&cm_id_priv->lock, flags); cm_init_qp_rtr_attr()
3573 static int cm_init_qp_rts_attr(struct cm_id_private *cm_id_priv, cm_init_qp_rts_attr() argument
3580 spin_lock_irqsave(&cm_id_priv->lock, flags); cm_init_qp_rts_attr()
3581 switch (cm_id_priv->id.state) { cm_init_qp_rts_attr()
3591 if (cm_id_priv->id.lap_state == IB_CM_LAP_UNINIT) { cm_init_qp_rts_attr()
3593 qp_attr->sq_psn = be32_to_cpu(cm_id_priv->sq_psn); cm_init_qp_rts_attr()
3594 switch (cm_id_priv->qp_type) { cm_init_qp_rts_attr()
3599 qp_attr->retry_cnt = cm_id_priv->retry_count; cm_init_qp_rts_attr()
3600 qp_attr->rnr_retry = cm_id_priv->rnr_retry_count; cm_init_qp_rts_attr()
3601 qp_attr->max_rd_atomic = cm_id_priv->initiator_depth; cm_init_qp_rts_attr()
3605 qp_attr->timeout = cm_id_priv->av.timeout; cm_init_qp_rts_attr()
3610 if (cm_id_priv->alt_av.ah_attr.dlid) { cm_init_qp_rts_attr()
3616 qp_attr->alt_port_num = cm_id_priv->alt_av.port->port_num; cm_init_qp_rts_attr()
3617 qp_attr->alt_pkey_index = cm_id_priv->alt_av.pkey_index; cm_init_qp_rts_attr()
3618 qp_attr->alt_timeout = cm_id_priv->alt_av.timeout; cm_init_qp_rts_attr()
3619 qp_attr->alt_ah_attr = cm_id_priv->alt_av.ah_attr; cm_init_qp_rts_attr()
3628 spin_unlock_irqrestore(&cm_id_priv->lock, flags); cm_init_qp_rts_attr()
3636 struct cm_id_private *cm_id_priv; ib_cm_init_qp_attr() local
3639 cm_id_priv = container_of(cm_id, struct cm_id_private, id); ib_cm_init_qp_attr()
3642 ret = cm_init_qp_init_attr(cm_id_priv, qp_attr, qp_attr_mask); ib_cm_init_qp_attr()
3645 ret = cm_init_qp_rtr_attr(cm_id_priv, qp_attr, qp_attr_mask); ib_cm_init_qp_attr()
3648 ret = cm_init_qp_rts_attr(cm_id_priv, qp_attr, qp_attr_mask); ib_cm_init_qp_attr()
654 cm_insert_remote_sidr(struct cm_id_private *cm_id_priv) cm_insert_remote_sidr() argument
1008 cm_format_req(struct cm_req_msg *req_msg, struct cm_id_private *cm_id_priv, struct ib_cm_req_param *param) cm_format_req() argument
1286 cm_format_req_event(struct cm_work *work, struct cm_id_private *cm_id_priv, struct ib_cm_id *listen_id) cm_format_req_event() argument
1343 cm_format_mra(struct cm_mra_msg *mra_msg, struct cm_id_private *cm_id_priv, enum cm_msg_response msg_mraed, u8 service_timeout, const void *private_data, u8 private_data_len) cm_format_mra() argument
1358 cm_format_rej(struct cm_rej_msg *rej_msg, struct cm_id_private *cm_id_priv, enum ib_cm_rej_reason reason, void *ari, u8 ari_length, const void *private_data, u8 private_data_len) cm_format_rej() argument
1399 cm_dup_req_handler(struct cm_work *work, struct cm_id_private *cm_id_priv) cm_dup_req_handler() argument
1442 cm_match_req(struct cm_work *work, struct cm_id_private *cm_id_priv) cm_match_req() argument
1615 cm_format_rep(struct cm_rep_msg *rep_msg, struct cm_id_private *cm_id_priv, struct ib_cm_rep_param *param) cm_format_rep() argument
1694 cm_format_rtu(struct cm_rtu_msg *rtu_msg, struct cm_id_private *cm_id_priv, const void *private_data, u8 private_data_len) cm_format_rtu() argument
1981 cm_format_dreq(struct cm_dreq_msg *dreq_msg, struct cm_id_private *cm_id_priv, const void *private_data, u8 private_data_len) cm_format_dreq() argument
2045 cm_format_drep(struct cm_drep_msg *drep_msg, struct cm_id_private *cm_id_priv, const void *private_data, u8 private_data_len) cm_format_drep() argument
2582 cm_format_lap(struct cm_lap_msg *lap_msg, struct cm_id_private *cm_id_priv, struct ib_sa_path_rec *alternate_path, const void *private_data, u8 private_data_len) cm_format_lap() argument
2764 cm_format_apr(struct cm_apr_msg *apr_msg, struct cm_id_private *cm_id_priv, enum ib_cm_apr_status status, void *info, u8 info_length, const void *private_data, u8 private_data_len) cm_format_apr() argument
2911 cm_format_sidr_req(struct cm_sidr_req_msg *sidr_req_msg, struct cm_id_private *cm_id_priv, struct ib_cm_sidr_req_param *param) cm_format_sidr_req() argument
3050 cm_format_sidr_rep(struct cm_sidr_rep_msg *sidr_rep_msg, struct cm_id_private *cm_id_priv, struct ib_cm_sidr_rep_param *param) cm_format_sidr_rep() argument
H A Diwcm.c107 static struct iwcm_work *get_work(struct iwcm_id_private *cm_id_priv) get_work() argument
111 if (list_empty(&cm_id_priv->work_free_list)) get_work()
113 work = list_entry(cm_id_priv->work_free_list.next, struct iwcm_work, get_work()
124 static void dealloc_work_entries(struct iwcm_id_private *cm_id_priv) dealloc_work_entries() argument
128 list_for_each_safe(e, tmp, &cm_id_priv->work_free_list) dealloc_work_entries()
132 static int alloc_work_entries(struct iwcm_id_private *cm_id_priv, int count) alloc_work_entries() argument
136 BUG_ON(!list_empty(&cm_id_priv->work_free_list)); alloc_work_entries()
140 dealloc_work_entries(cm_id_priv); alloc_work_entries()
143 work->cm_id = cm_id_priv; alloc_work_entries()
166 static void free_cm_id(struct iwcm_id_private *cm_id_priv) free_cm_id() argument
168 dealloc_work_entries(cm_id_priv); free_cm_id()
169 kfree(cm_id_priv); free_cm_id()
177 static int iwcm_deref_id(struct iwcm_id_private *cm_id_priv) iwcm_deref_id() argument
179 BUG_ON(atomic_read(&cm_id_priv->refcount)==0); iwcm_deref_id()
180 if (atomic_dec_and_test(&cm_id_priv->refcount)) { iwcm_deref_id()
181 BUG_ON(!list_empty(&cm_id_priv->work_list)); iwcm_deref_id()
182 complete(&cm_id_priv->destroy_comp); iwcm_deref_id()
191 struct iwcm_id_private *cm_id_priv; add_ref() local
192 cm_id_priv = container_of(cm_id, struct iwcm_id_private, id); add_ref()
193 atomic_inc(&cm_id_priv->refcount); add_ref()
198 struct iwcm_id_private *cm_id_priv; rem_ref() local
201 cm_id_priv = container_of(cm_id, struct iwcm_id_private, id); rem_ref()
207 cb_destroy = test_bit(IWCM_F_CALLBACK_DESTROY, &cm_id_priv->flags); rem_ref()
208 if (iwcm_deref_id(cm_id_priv) && cb_destroy) { rem_ref()
209 BUG_ON(!list_empty(&cm_id_priv->work_list)); rem_ref()
210 free_cm_id(cm_id_priv); rem_ref()
220 struct iwcm_id_private *cm_id_priv; iw_create_cm_id() local
222 cm_id_priv = kzalloc(sizeof(*cm_id_priv), GFP_KERNEL); iw_create_cm_id()
223 if (!cm_id_priv) iw_create_cm_id()
226 cm_id_priv->state = IW_CM_STATE_IDLE; iw_create_cm_id()
227 cm_id_priv->id.device = device; iw_create_cm_id()
228 cm_id_priv->id.cm_handler = cm_handler; iw_create_cm_id()
229 cm_id_priv->id.context = context; iw_create_cm_id()
230 cm_id_priv->id.event_handler = cm_event_handler; iw_create_cm_id()
231 cm_id_priv->id.add_ref = add_ref; iw_create_cm_id()
232 cm_id_priv->id.rem_ref = rem_ref; iw_create_cm_id()
233 spin_lock_init(&cm_id_priv->lock); iw_create_cm_id()
234 atomic_set(&cm_id_priv->refcount, 1); iw_create_cm_id()
235 init_waitqueue_head(&cm_id_priv->connect_wait); iw_create_cm_id()
236 init_completion(&cm_id_priv->destroy_comp); iw_create_cm_id()
237 INIT_LIST_HEAD(&cm_id_priv->work_list); iw_create_cm_id()
238 INIT_LIST_HEAD(&cm_id_priv->work_free_list); iw_create_cm_id()
240 return &cm_id_priv->id; iw_create_cm_id()
283 struct iwcm_id_private *cm_id_priv; iw_cm_disconnect() local
288 cm_id_priv = container_of(cm_id, struct iwcm_id_private, id); iw_cm_disconnect()
290 wait_event(cm_id_priv->connect_wait, iw_cm_disconnect()
291 !test_bit(IWCM_F_CONNECT_WAIT, &cm_id_priv->flags)); iw_cm_disconnect()
293 spin_lock_irqsave(&cm_id_priv->lock, flags); iw_cm_disconnect()
294 switch (cm_id_priv->state) { iw_cm_disconnect()
296 cm_id_priv->state = IW_CM_STATE_CLOSING; iw_cm_disconnect()
299 if (cm_id_priv->qp) iw_cm_disconnect()
300 qp = cm_id_priv->qp; iw_cm_disconnect()
323 spin_unlock_irqrestore(&cm_id_priv->lock, flags); iw_cm_disconnect()
350 struct iwcm_id_private *cm_id_priv; destroy_cm_id() local
353 cm_id_priv = container_of(cm_id, struct iwcm_id_private, id); destroy_cm_id()
358 wait_event(cm_id_priv->connect_wait, destroy_cm_id()
359 !test_bit(IWCM_F_CONNECT_WAIT, &cm_id_priv->flags)); destroy_cm_id()
361 spin_lock_irqsave(&cm_id_priv->lock, flags); destroy_cm_id()
362 switch (cm_id_priv->state) { destroy_cm_id()
364 cm_id_priv->state = IW_CM_STATE_DESTROYING; destroy_cm_id()
365 spin_unlock_irqrestore(&cm_id_priv->lock, flags); destroy_cm_id()
368 spin_lock_irqsave(&cm_id_priv->lock, flags); destroy_cm_id()
371 cm_id_priv->state = IW_CM_STATE_DESTROYING; destroy_cm_id()
372 spin_unlock_irqrestore(&cm_id_priv->lock, flags); destroy_cm_id()
374 (void)iwcm_modify_qp_err(cm_id_priv->qp); destroy_cm_id()
375 spin_lock_irqsave(&cm_id_priv->lock, flags); destroy_cm_id()
379 cm_id_priv->state = IW_CM_STATE_DESTROYING; destroy_cm_id()
388 cm_id_priv->state = IW_CM_STATE_DESTROYING; destroy_cm_id()
389 spin_unlock_irqrestore(&cm_id_priv->lock, flags); destroy_cm_id()
391 spin_lock_irqsave(&cm_id_priv->lock, flags); destroy_cm_id()
399 if (cm_id_priv->qp) { destroy_cm_id()
400 cm_id_priv->id.device->iwcm->rem_ref(cm_id_priv->qp); destroy_cm_id()
401 cm_id_priv->qp = NULL; destroy_cm_id()
403 spin_unlock_irqrestore(&cm_id_priv->lock, flags); destroy_cm_id()
405 (void)iwcm_deref_id(cm_id_priv); destroy_cm_id()
416 struct iwcm_id_private *cm_id_priv; iw_destroy_cm_id() local
418 cm_id_priv = container_of(cm_id, struct iwcm_id_private, id); iw_destroy_cm_id()
419 BUG_ON(test_bit(IWCM_F_CALLBACK_DESTROY, &cm_id_priv->flags)); iw_destroy_cm_id()
423 wait_for_completion(&cm_id_priv->destroy_comp); iw_destroy_cm_id()
425 free_cm_id(cm_id_priv); iw_destroy_cm_id()
437 struct iwcm_id_private *cm_id_priv; iw_cm_listen() local
441 cm_id_priv = container_of(cm_id, struct iwcm_id_private, id); iw_cm_listen()
446 ret = alloc_work_entries(cm_id_priv, backlog); iw_cm_listen()
450 spin_lock_irqsave(&cm_id_priv->lock, flags); iw_cm_listen()
451 switch (cm_id_priv->state) { iw_cm_listen()
453 cm_id_priv->state = IW_CM_STATE_LISTEN; iw_cm_listen()
454 spin_unlock_irqrestore(&cm_id_priv->lock, flags); iw_cm_listen()
457 cm_id_priv->state = IW_CM_STATE_IDLE; iw_cm_listen()
458 spin_lock_irqsave(&cm_id_priv->lock, flags); iw_cm_listen()
463 spin_unlock_irqrestore(&cm_id_priv->lock, flags); iw_cm_listen()
478 struct iwcm_id_private *cm_id_priv; iw_cm_reject() local
482 cm_id_priv = container_of(cm_id, struct iwcm_id_private, id); iw_cm_reject()
483 set_bit(IWCM_F_CONNECT_WAIT, &cm_id_priv->flags); iw_cm_reject()
485 spin_lock_irqsave(&cm_id_priv->lock, flags); iw_cm_reject()
486 if (cm_id_priv->state != IW_CM_STATE_CONN_RECV) { iw_cm_reject()
487 spin_unlock_irqrestore(&cm_id_priv->lock, flags); iw_cm_reject()
488 clear_bit(IWCM_F_CONNECT_WAIT, &cm_id_priv->flags); iw_cm_reject()
489 wake_up_all(&cm_id_priv->connect_wait); iw_cm_reject()
492 cm_id_priv->state = IW_CM_STATE_IDLE; iw_cm_reject()
493 spin_unlock_irqrestore(&cm_id_priv->lock, flags); iw_cm_reject()
498 clear_bit(IWCM_F_CONNECT_WAIT, &cm_id_priv->flags); iw_cm_reject()
499 wake_up_all(&cm_id_priv->connect_wait); iw_cm_reject()
515 struct iwcm_id_private *cm_id_priv; iw_cm_accept() local
520 cm_id_priv = container_of(cm_id, struct iwcm_id_private, id); iw_cm_accept()
521 set_bit(IWCM_F_CONNECT_WAIT, &cm_id_priv->flags); iw_cm_accept()
523 spin_lock_irqsave(&cm_id_priv->lock, flags); iw_cm_accept()
524 if (cm_id_priv->state != IW_CM_STATE_CONN_RECV) { iw_cm_accept()
525 spin_unlock_irqrestore(&cm_id_priv->lock, flags); iw_cm_accept()
526 clear_bit(IWCM_F_CONNECT_WAIT, &cm_id_priv->flags); iw_cm_accept()
527 wake_up_all(&cm_id_priv->connect_wait); iw_cm_accept()
533 spin_unlock_irqrestore(&cm_id_priv->lock, flags); iw_cm_accept()
534 clear_bit(IWCM_F_CONNECT_WAIT, &cm_id_priv->flags); iw_cm_accept()
535 wake_up_all(&cm_id_priv->connect_wait); iw_cm_accept()
539 cm_id_priv->qp = qp; iw_cm_accept()
540 spin_unlock_irqrestore(&cm_id_priv->lock, flags); iw_cm_accept()
545 BUG_ON(cm_id_priv->state != IW_CM_STATE_CONN_RECV); iw_cm_accept()
546 cm_id_priv->state = IW_CM_STATE_IDLE; iw_cm_accept()
547 spin_lock_irqsave(&cm_id_priv->lock, flags); iw_cm_accept()
548 if (cm_id_priv->qp) { iw_cm_accept()
550 cm_id_priv->qp = NULL; iw_cm_accept()
552 spin_unlock_irqrestore(&cm_id_priv->lock, flags); iw_cm_accept()
553 clear_bit(IWCM_F_CONNECT_WAIT, &cm_id_priv->flags); iw_cm_accept()
554 wake_up_all(&cm_id_priv->connect_wait); iw_cm_accept()
570 struct iwcm_id_private *cm_id_priv; iw_cm_connect() local
575 cm_id_priv = container_of(cm_id, struct iwcm_id_private, id); iw_cm_connect()
577 ret = alloc_work_entries(cm_id_priv, 4); iw_cm_connect()
581 set_bit(IWCM_F_CONNECT_WAIT, &cm_id_priv->flags); iw_cm_connect()
582 spin_lock_irqsave(&cm_id_priv->lock, flags); iw_cm_connect()
584 if (cm_id_priv->state != IW_CM_STATE_IDLE) { iw_cm_connect()
585 spin_unlock_irqrestore(&cm_id_priv->lock, flags); iw_cm_connect()
586 clear_bit(IWCM_F_CONNECT_WAIT, &cm_id_priv->flags); iw_cm_connect()
587 wake_up_all(&cm_id_priv->connect_wait); iw_cm_connect()
594 spin_unlock_irqrestore(&cm_id_priv->lock, flags); iw_cm_connect()
595 clear_bit(IWCM_F_CONNECT_WAIT, &cm_id_priv->flags); iw_cm_connect()
596 wake_up_all(&cm_id_priv->connect_wait); iw_cm_connect()
600 cm_id_priv->qp = qp; iw_cm_connect()
601 cm_id_priv->state = IW_CM_STATE_CONN_SENT; iw_cm_connect()
602 spin_unlock_irqrestore(&cm_id_priv->lock, flags); iw_cm_connect()
606 spin_lock_irqsave(&cm_id_priv->lock, flags); iw_cm_connect()
607 if (cm_id_priv->qp) { iw_cm_connect()
609 cm_id_priv->qp = NULL; iw_cm_connect()
611 spin_unlock_irqrestore(&cm_id_priv->lock, flags); iw_cm_connect()
612 BUG_ON(cm_id_priv->state != IW_CM_STATE_CONN_SENT); iw_cm_connect()
613 cm_id_priv->state = IW_CM_STATE_IDLE; iw_cm_connect()
614 clear_bit(IWCM_F_CONNECT_WAIT, &cm_id_priv->flags); iw_cm_connect()
615 wake_up_all(&cm_id_priv->connect_wait); iw_cm_connect()
642 struct iwcm_id_private *cm_id_priv; cm_conn_req_handler() local
662 cm_id_priv = container_of(cm_id, struct iwcm_id_private, id); cm_conn_req_handler()
663 cm_id_priv->state = IW_CM_STATE_CONN_RECV; cm_conn_req_handler()
678 ret = alloc_work_entries(cm_id_priv, 3); cm_conn_req_handler()
689 set_bit(IWCM_F_CALLBACK_DESTROY, &cm_id_priv->flags); cm_conn_req_handler()
691 if (atomic_read(&cm_id_priv->refcount)==0) cm_conn_req_handler()
692 free_cm_id(cm_id_priv); cm_conn_req_handler()
712 static int cm_conn_est_handler(struct iwcm_id_private *cm_id_priv, cm_conn_est_handler() argument
718 spin_lock_irqsave(&cm_id_priv->lock, flags); cm_conn_est_handler()
725 clear_bit(IWCM_F_CONNECT_WAIT, &cm_id_priv->flags); cm_conn_est_handler()
726 BUG_ON(cm_id_priv->state != IW_CM_STATE_CONN_RECV); cm_conn_est_handler()
727 cm_id_priv->state = IW_CM_STATE_ESTABLISHED; cm_conn_est_handler()
728 spin_unlock_irqrestore(&cm_id_priv->lock, flags); cm_conn_est_handler()
729 ret = cm_id_priv->id.cm_handler(&cm_id_priv->id, iw_event); cm_conn_est_handler()
730 wake_up_all(&cm_id_priv->connect_wait); cm_conn_est_handler()
742 static int cm_conn_rep_handler(struct iwcm_id_private *cm_id_priv, cm_conn_rep_handler() argument
748 spin_lock_irqsave(&cm_id_priv->lock, flags); cm_conn_rep_handler()
753 clear_bit(IWCM_F_CONNECT_WAIT, &cm_id_priv->flags); cm_conn_rep_handler()
754 BUG_ON(cm_id_priv->state != IW_CM_STATE_CONN_SENT); cm_conn_rep_handler()
756 cm_id_priv->id.local_addr = iw_event->local_addr; cm_conn_rep_handler()
757 cm_id_priv->id.remote_addr = iw_event->remote_addr; cm_conn_rep_handler()
758 cm_id_priv->state = IW_CM_STATE_ESTABLISHED; cm_conn_rep_handler()
761 cm_id_priv->id.device->iwcm->rem_ref(cm_id_priv->qp); cm_conn_rep_handler()
762 cm_id_priv->qp = NULL; cm_conn_rep_handler()
763 cm_id_priv->state = IW_CM_STATE_IDLE; cm_conn_rep_handler()
765 spin_unlock_irqrestore(&cm_id_priv->lock, flags); cm_conn_rep_handler()
766 ret = cm_id_priv->id.cm_handler(&cm_id_priv->id, iw_event); cm_conn_rep_handler()
772 wake_up_all(&cm_id_priv->connect_wait); cm_conn_rep_handler()
782 static void cm_disconnect_handler(struct iwcm_id_private *cm_id_priv, cm_disconnect_handler() argument
787 spin_lock_irqsave(&cm_id_priv->lock, flags); cm_disconnect_handler()
788 if (cm_id_priv->state == IW_CM_STATE_ESTABLISHED) cm_disconnect_handler()
789 cm_id_priv->state = IW_CM_STATE_CLOSING; cm_disconnect_handler()
790 spin_unlock_irqrestore(&cm_id_priv->lock, flags); cm_disconnect_handler()
804 static int cm_close_handler(struct iwcm_id_private *cm_id_priv, cm_close_handler() argument
809 spin_lock_irqsave(&cm_id_priv->lock, flags); cm_close_handler()
811 if (cm_id_priv->qp) { cm_close_handler()
812 cm_id_priv->id.device->iwcm->rem_ref(cm_id_priv->qp); cm_close_handler()
813 cm_id_priv->qp = NULL; cm_close_handler()
815 switch (cm_id_priv->state) { cm_close_handler()
818 cm_id_priv->state = IW_CM_STATE_IDLE; cm_close_handler()
819 spin_unlock_irqrestore(&cm_id_priv->lock, flags); cm_close_handler()
820 ret = cm_id_priv->id.cm_handler(&cm_id_priv->id, iw_event); cm_close_handler()
821 spin_lock_irqsave(&cm_id_priv->lock, flags); cm_close_handler()
828 spin_unlock_irqrestore(&cm_id_priv->lock, flags); cm_close_handler()
833 static int process_event(struct iwcm_id_private *cm_id_priv, process_event() argument
840 cm_conn_req_handler(cm_id_priv, iw_event); process_event()
843 ret = cm_conn_rep_handler(cm_id_priv, iw_event); process_event()
846 ret = cm_conn_est_handler(cm_id_priv, iw_event); process_event()
849 cm_disconnect_handler(cm_id_priv, iw_event); process_event()
852 ret = cm_close_handler(cm_id_priv, iw_event); process_event()
874 struct iwcm_id_private *cm_id_priv = work->cm_id; cm_work_handler() local
880 spin_lock_irqsave(&cm_id_priv->lock, flags); cm_work_handler()
881 empty = list_empty(&cm_id_priv->work_list); cm_work_handler()
883 work = list_entry(cm_id_priv->work_list.next, cm_work_handler()
886 empty = list_empty(&cm_id_priv->work_list); cm_work_handler()
889 spin_unlock_irqrestore(&cm_id_priv->lock, flags); cm_work_handler()
891 ret = process_event(cm_id_priv, &levent); cm_work_handler()
893 set_bit(IWCM_F_CALLBACK_DESTROY, &cm_id_priv->flags); cm_work_handler()
894 destroy_cm_id(&cm_id_priv->id); cm_work_handler()
896 BUG_ON(atomic_read(&cm_id_priv->refcount)==0); cm_work_handler()
897 destroy_id = test_bit(IWCM_F_CALLBACK_DESTROY, &cm_id_priv->flags); cm_work_handler()
898 if (iwcm_deref_id(cm_id_priv)) { cm_work_handler()
900 BUG_ON(!list_empty(&cm_id_priv->work_list)); cm_work_handler()
901 free_cm_id(cm_id_priv); cm_work_handler()
907 spin_lock_irqsave(&cm_id_priv->lock, flags); cm_work_handler()
909 spin_unlock_irqrestore(&cm_id_priv->lock, flags); cm_work_handler()
931 struct iwcm_id_private *cm_id_priv; cm_event_handler() local
935 cm_id_priv = container_of(cm_id, struct iwcm_id_private, id); cm_event_handler()
937 spin_lock_irqsave(&cm_id_priv->lock, flags); cm_event_handler()
938 work = get_work(cm_id_priv); cm_event_handler()
945 work->cm_id = cm_id_priv; cm_event_handler()
958 atomic_inc(&cm_id_priv->refcount); cm_event_handler()
959 if (list_empty(&cm_id_priv->work_list)) { cm_event_handler()
960 list_add_tail(&work->list, &cm_id_priv->work_list); cm_event_handler()
963 list_add_tail(&work->list, &cm_id_priv->work_list); cm_event_handler()
965 spin_unlock_irqrestore(&cm_id_priv->lock, flags); cm_event_handler()
969 static int iwcm_init_qp_init_attr(struct iwcm_id_private *cm_id_priv, iwcm_init_qp_init_attr() argument
976 spin_lock_irqsave(&cm_id_priv->lock, flags); iwcm_init_qp_init_attr()
977 switch (cm_id_priv->state) { iwcm_init_qp_init_attr()
991 spin_unlock_irqrestore(&cm_id_priv->lock, flags); iwcm_init_qp_init_attr()
995 static int iwcm_init_qp_rts_attr(struct iwcm_id_private *cm_id_priv, iwcm_init_qp_rts_attr() argument
1002 spin_lock_irqsave(&cm_id_priv->lock, flags); iwcm_init_qp_rts_attr()
1003 switch (cm_id_priv->state) { iwcm_init_qp_rts_attr()
1015 spin_unlock_irqrestore(&cm_id_priv->lock, flags); iwcm_init_qp_rts_attr()
1023 struct iwcm_id_private *cm_id_priv; iw_cm_init_qp_attr() local
1026 cm_id_priv = container_of(cm_id, struct iwcm_id_private, id); iw_cm_init_qp_attr()
1030 ret = iwcm_init_qp_init_attr(cm_id_priv, iw_cm_init_qp_attr()
1034 ret = iwcm_init_qp_rts_attr(cm_id_priv, iw_cm_init_qp_attr()

Completed in 137 milliseconds