Lines Matching refs:query

489 static inline void ib_sa_disable_local_svc(struct ib_sa_query *query)
491 query->flags &= ~IB_SA_ENABLE_LOCAL_SERVICE;
511 pr_warn("Couldn't query port\n");
603 * ib_sa_cancel_query - try to cancel an SA query
604 * @id:ID of query to cancel
605 * @query:query pointer to cancel
607 * Try to cancel an SA query. If the id and query don't match up or
608 * the query has already completed, nothing is done. Otherwise the
609 * query is canceled and will complete with a status of -EINTR.
611 void ib_sa_cancel_query(int id, struct ib_sa_query *query)
618 if (idr_find(&query_idr, id) != query) {
622 agent = query->port->agent;
623 mad_buf = query->mad_buf;
746 static int alloc_mad(struct ib_sa_query *query, gfp_t gfp_mask)
750 spin_lock_irqsave(&query->port->ah_lock, flags);
751 if (!query->port->sm_ah) {
752 spin_unlock_irqrestore(&query->port->ah_lock, flags);
755 kref_get(&query->port->sm_ah->ref);
756 query->sm_ah = query->port->sm_ah;
757 spin_unlock_irqrestore(&query->port->ah_lock, flags);
759 query->mad_buf = ib_create_send_mad(query->port->agent, 1,
760 query->sm_ah->pkey_index,
764 if (IS_ERR(query->mad_buf)) {
765 kref_put(&query->sm_ah->ref, free_sm_ah);
769 query->mad_buf->ah = query->sm_ah->ah;
774 static void free_mad(struct ib_sa_query *query)
776 ib_free_send_mad(query->mad_buf);
777 kref_put(&query->sm_ah->ref, free_sm_ah);
796 static int send_mad(struct ib_sa_query *query, int timeout_ms, gfp_t gfp_mask)
806 id = idr_alloc(&query_idr, query, 0, 0, GFP_NOWAIT);
814 query->mad_buf->timeout_ms = timeout_ms;
815 query->mad_buf->context[0] = query;
816 query->id = id;
818 if (query->flags & IB_SA_ENABLE_LOCAL_SERVICE) {
819 ib_sa_disable_local_svc(query);
822 ret = ib_post_send_mad(query->mad_buf, NULL);
830 * It's not safe to dereference query any more, because the
831 * send may already have completed and freed the query in
853 struct ib_sa_path_query *query =
865 query->callback(status, &rec, query->context);
867 query->callback(status, NULL, query->context);
876 * ib_sa_path_rec_get - Start a Path get query
878 * @device:device to send query on
879 * @port_num: port number to send query on
880 * @rec:Path Record to send in query
881 * @comp_mask:component mask to send in query
884 * @callback:function called when query completes, times out or is
887 * @sa_query:query context, used to cancel query
889 * Send a Path Record Get query to the SA to look up a path. The
890 * callback function will be called when the query completes (or
891 * fails); status is 0 for a successful response, -EINTR if the query
892 * is canceled, -ETIMEDOUT is the query timed out, or -EIO if an error
893 * occurred sending the query. The resp parameter of the callback is
897 * error code. Otherwise it is a query ID that can be used to cancel
898 * the query.
911 struct ib_sa_path_query *query;
924 query = kzalloc(sizeof(*query), gfp_mask);
925 if (!query)
928 query->sa_query.port = port;
929 ret = alloc_mad(&query->sa_query, gfp_mask);
934 query->sa_query.client = client;
935 query->callback = callback;
936 query->context = context;
938 mad = query->sa_query.mad_buf->mad;
941 query->sa_query.callback = callback ? ib_sa_path_rec_callback : NULL;
942 query->sa_query.release = ib_sa_path_rec_release;
949 *sa_query = &query->sa_query;
951 query->sa_query.flags |= IB_SA_ENABLE_LOCAL_SERVICE;
952 query->sa_query.mad_buf->context[1] = rec;
954 ret = send_mad(&query->sa_query, timeout_ms, gfp_mask);
962 ib_sa_client_put(query->sa_query.client);
963 free_mad(&query->sa_query);
966 kfree(query);
975 struct ib_sa_service_query *query =
983 query->callback(status, &rec, query->context);
985 query->callback(status, NULL, query->context);
1009 * unregister or query a service record.
1011 * fails); status is 0 for a successful response, -EINTR if the query
1012 * is canceled, -ETIMEDOUT is the query timed out, or -EIO if an error
1013 * occurred sending the query. The resp parameter of the callback is
1018 * the query.
1031 struct ib_sa_service_query *query;
1049 query = kzalloc(sizeof(*query), gfp_mask);
1050 if (!query)
1053 query->sa_query.port = port;
1054 ret = alloc_mad(&query->sa_query, gfp_mask);
1059 query->sa_query.client = client;
1060 query->callback = callback;
1061 query->context = context;
1063 mad = query->sa_query.mad_buf->mad;
1066 query->sa_query.callback = callback ? ib_sa_service_rec_callback : NULL;
1067 query->sa_query.release = ib_sa_service_rec_release;
1075 *sa_query = &query->sa_query;
1077 ret = send_mad(&query->sa_query, timeout_ms, gfp_mask);
1085 ib_sa_client_put(query->sa_query.client);
1086 free_mad(&query->sa_query);
1089 kfree(query);
1098 struct ib_sa_mcmember_query *query =
1106 query->callback(status, &rec, query->context);
1108 query->callback(status, NULL, query->context);
1128 struct ib_sa_mcmember_query *query;
1141 query = kzalloc(sizeof(*query), gfp_mask);
1142 if (!query)
1145 query->sa_query.port = port;
1146 ret = alloc_mad(&query->sa_query, gfp_mask);
1151 query->sa_query.client = client;
1152 query->callback = callback;
1153 query->context = context;
1155 mad = query->sa_query.mad_buf->mad;
1158 query->sa_query.callback = callback ? ib_sa_mcmember_rec_callback : NULL;
1159 query->sa_query.release = ib_sa_mcmember_rec_release;
1167 *sa_query = &query->sa_query;
1169 ret = send_mad(&query->sa_query, timeout_ms, gfp_mask);
1177 ib_sa_client_put(query->sa_query.client);
1178 free_mad(&query->sa_query);
1181 kfree(query);
1190 struct ib_sa_guidinfo_query *query =
1198 query->callback(status, &rec, query->context);
1200 query->callback(status, NULL, query->context);
1219 struct ib_sa_guidinfo_query *query;
1238 query = kzalloc(sizeof(*query), gfp_mask);
1239 if (!query)
1242 query->sa_query.port = port;
1243 ret = alloc_mad(&query->sa_query, gfp_mask);
1248 query->sa_query.client = client;
1249 query->callback = callback;
1250 query->context = context;
1252 mad = query->sa_query.mad_buf->mad;
1255 query->sa_query.callback = callback ? ib_sa_guidinfo_rec_callback : NULL;
1256 query->sa_query.release = ib_sa_guidinfo_rec_release;
1265 *sa_query = &query->sa_query;
1267 ret = send_mad(&query->sa_query, timeout_ms, gfp_mask);
1275 ib_sa_client_put(query->sa_query.client);
1276 free_mad(&query->sa_query);
1279 kfree(query);
1290 struct ib_sa_classport_info_query *query =
1309 query->callback(status, &rec, query->context);
1311 query->callback(status, NULL, query->context);
1330 struct ib_sa_classport_info_query *query;
1356 query = kzalloc(sizeof(*query), gfp_mask);
1357 if (!query)
1360 query->sa_query.port = port;
1361 ret = alloc_mad(&query->sa_query, gfp_mask);
1366 query->sa_query.client = client;
1367 query->callback = callback;
1368 query->context = context;
1370 mad = query->sa_query.mad_buf->mad;
1373 query->sa_query.callback = callback ? ib_sa_classport_info_rec_callback : NULL;
1375 query->sa_query.release = ib_sa_portclass_info_rec_release;
1380 *sa_query = &query->sa_query;
1382 ret = send_mad(&query->sa_query, timeout_ms, gfp_mask);
1390 ib_sa_client_put(query->sa_query.client);
1391 free_mad(&query->sa_query);
1394 kfree(query);
1402 struct ib_sa_query *query = mad_send_wc->send_buf->context[0];
1405 if (query->callback)
1411 query->callback(query, -ETIMEDOUT, NULL);
1414 query->callback(query, -EINTR, NULL);
1417 query->callback(query, -EIO, NULL);
1422 idr_remove(&query_idr, query->id);
1425 free_mad(query);
1426 ib_sa_client_put(query->client);
1427 query->release(query);
1434 struct ib_sa_query *query;
1439 query = send_buf->context[0];
1440 if (query->callback) {
1442 query->callback(query,
1447 query->callback(query, -EIO, NULL);