Lines Matching defs:query

689 static inline void ib_sa_disable_local_svc(struct ib_sa_query *query)
691 query->flags &= ~IB_SA_ENABLE_LOCAL_SERVICE;
694 static inline int ib_sa_query_cancelled(struct ib_sa_query *query)
696 return (query->flags & IB_SA_CANCEL);
700 struct ib_sa_query *query)
702 struct sa_path_rec *sa_rec = query->mad_buf->context[1];
703 struct ib_sa_mad *mad = query->mad_buf->mad;
709 query->mad_buf->context[1] = NULL;
714 dev_name(&query->port->agent->device->dev),
716 header->port_num = query->port->port_num;
720 query->path_use = LS_RESOLVE_PATH_USE_ALL;
722 query->path_use = LS_RESOLVE_PATH_USE_UNIDIRECTIONAL;
723 header->path_use = query->path_use;
783 static int ib_nl_make_request(struct ib_sa_query *query, gfp_t gfp_mask)
795 INIT_LIST_HEAD(&query->list);
796 query->seq = (u32)atomic_inc_return(&ib_nl_sa_request_seq);
798 mad = query->mad_buf->mad;
808 data = ibnl_put_msg(skb, &nlh, query->seq, 0, RDMA_NL_LS,
816 ib_nl_set_path_rec_attrs(skb, query);
832 query->timeout = delay + jiffies;
833 list_add_tail(&query->list, &ib_nl_request_list);
835 if (ib_nl_request_list.next == &query->list)
844 static int ib_nl_cancel_request(struct ib_sa_query *query)
853 if (query == wait_query) {
854 query->flags |= IB_SA_CANCEL;
855 query->timeout = jiffies;
856 list_move(&query->list, &ib_nl_request_list);
870 static void ib_nl_process_good_resolve_rsp(struct ib_sa_query *query,
883 if (!query->callback)
886 path_query = container_of(query, struct ib_sa_path_query, sa_query);
887 mad = query->mad_buf->mad;
891 switch (query->path_use) {
915 if ((query->flags & IB_SA_QUERY_OPA) ||
920 query->callback(query, 0, mad);
941 query->callback(query, status, mad);
944 mad_send_wc.send_buf = query->mad_buf;
946 send_handler(query->mad_buf->mad_agent, &mad_send_wc);
952 struct ib_sa_query *query;
959 query = list_entry(ib_nl_request_list.next,
962 if (time_after(query->timeout, jiffies)) {
963 delay = query->timeout - jiffies;
970 list_del(&query->list);
971 ib_sa_disable_local_svc(query);
972 /* Hold the lock to protect against query cancellation */
973 if (ib_sa_query_cancelled(query))
976 ret = ib_post_send_mad(query->mad_buf, NULL);
978 mad_send_wc.send_buf = query->mad_buf;
981 send_handler(query->port->agent, &mad_send_wc);
995 struct ib_sa_query *query;
1025 list_for_each_entry(query, &ib_nl_request_list, list) {
1026 if (delta < 0 && abs_delta > query->timeout)
1027 query->timeout = 0;
1029 query->timeout += delta;
1033 delay = query->timeout - jiffies;
1069 struct ib_sa_query *query = NULL, *iter;
1081 * If the query is cancelled, let the timeout routine
1087 query = iter;
1093 if (!query) {
1098 send_buf = query->mad_buf;
1102 ib_sa_disable_local_svc(query);
1103 ret = ib_post_send_mad(query->mad_buf, NULL);
1108 send_handler(query->port->agent, &mad_send_wc);
1112 ib_nl_process_good_resolve_rsp(query, nlh);
1142 * ib_sa_cancel_query - try to cancel an SA query
1143 * @id:ID of query to cancel
1144 * @query:query pointer to cancel
1146 * Try to cancel an SA query. If the id and query don't match up or
1147 * the query has already completed, nothing is done. Otherwise the
1148 * query is canceled and will complete with a status of -EINTR.
1150 void ib_sa_cancel_query(int id, struct ib_sa_query *query)
1156 if (xa_load(&queries, id) != query) {
1160 mad_buf = query->mad_buf;
1164 * If the query is still on the netlink request list, schedule
1168 if (!ib_nl_cancel_request(query))
1267 static int alloc_mad(struct ib_sa_query *query, gfp_t gfp_mask)
1272 spin_lock_irqsave(&query->port->ah_lock, flags);
1273 if (!query->port->sm_ah) {
1274 spin_unlock_irqrestore(&query->port->ah_lock, flags);
1277 kref_get(&query->port->sm_ah->ref);
1278 query->sm_ah = query->port->sm_ah;
1279 spin_unlock_irqrestore(&query->port->ah_lock, flags);
1285 if ((rdma_query_ah(query->sm_ah->ah, &ah_attr) < 0) ||
1287 kref_put(&query->sm_ah->ref, free_sm_ah);
1290 query->mad_buf = ib_create_send_mad(query->port->agent, 1,
1291 query->sm_ah->pkey_index,
1294 ((query->flags & IB_SA_QUERY_OPA) ?
1297 if (IS_ERR(query->mad_buf)) {
1298 kref_put(&query->sm_ah->ref, free_sm_ah);
1302 query->mad_buf->ah = query->sm_ah->ah;
1307 static void free_mad(struct ib_sa_query *query)
1309 ib_free_send_mad(query->mad_buf);
1310 kref_put(&query->sm_ah->ref, free_sm_ah);
1313 static void init_mad(struct ib_sa_query *query, struct ib_mad_agent *agent)
1315 struct ib_sa_mad *mad = query->mad_buf->mad;
1320 if (query->flags & IB_SA_QUERY_OPA) {
1334 static int send_mad(struct ib_sa_query *query, unsigned long timeout_ms,
1342 ret = __xa_alloc(&queries, &id, query, xa_limit_32b, gfp_mask);
1347 query->mad_buf->timeout_ms = timeout_ms / nmbr_sa_query_retries;
1348 query->mad_buf->retries = nmbr_sa_query_retries;
1349 if (!query->mad_buf->timeout_ms) {
1351 query->mad_buf->timeout_ms = 1;
1352 query->mad_buf->retries = timeout_ms;
1354 query->mad_buf->context[0] = query;
1355 query->id = id;
1357 if ((query->flags & IB_SA_ENABLE_LOCAL_SERVICE) &&
1358 (!(query->flags & IB_SA_QUERY_OPA))) {
1360 if (!ib_nl_make_request(query, gfp_mask))
1363 ib_sa_disable_local_svc(query);
1366 ret = ib_post_send_mad(query->mad_buf, NULL);
1374 * It's not safe to dereference query any more, because the
1375 * send may already have completed and freed the query in
1421 * opa_pr_query_possible - Check if current PR query can be an OPA query.
1423 * Retuns PR_NOT_SUPPORTED if a path record query is not
1424 * possible, PR_OPA_SUPPORTED if an OPA path record query
1426 * query is possible.
1449 struct ib_sa_path_query *query =
1454 query->callback(status, NULL, 0, query->context);
1462 query->callback(status, &rec, 1, query->context);
1471 if (query->conv_pr) {
1476 query->callback(status, &opa, 1, query->context);
1478 query->callback(status, &rec, 1, query->context);
1484 struct ib_sa_path_query *query =
1487 kfree(query->conv_pr);
1488 kfree(query);
1492 * ib_sa_path_rec_get - Start a Path get query
1494 * @device:device to send query on
1495 * @port_num: port number to send query on
1496 * @rec:Path Record to send in query
1497 * @comp_mask:component mask to send in query
1500 * @callback:function called when query completes, times out or is
1503 * @sa_query:query context, used to cancel query
1505 * Send a Path Record Get query to the SA to look up a path. The
1506 * callback function will be called when the query completes (or
1507 * fails); status is 0 for a successful response, -EINTR if the query
1508 * is canceled, -ETIMEDOUT is the query timed out, or -EIO if an error
1509 * occurred sending the query. The resp parameter of the callback is
1513 * error code. Otherwise it is a query ID that can be used to cancel
1514 * the query.
1527 struct ib_sa_path_query *query;
1545 query = kzalloc(sizeof(*query), gfp_mask);
1546 if (!query)
1549 query->sa_query.port = port;
1556 query->sa_query.flags |= IB_SA_QUERY_OPA;
1558 query->conv_pr =
1559 kmalloc(sizeof(*query->conv_pr), gfp_mask);
1560 if (!query->conv_pr) {
1567 ret = alloc_mad(&query->sa_query, gfp_mask);
1572 query->sa_query.client = client;
1573 query->callback = callback;
1574 query->context = context;
1576 mad = query->sa_query.mad_buf->mad;
1577 init_mad(&query->sa_query, agent);
1579 query->sa_query.callback = callback ? ib_sa_path_rec_callback : NULL;
1580 query->sa_query.release = ib_sa_path_rec_release;
1585 if (query->sa_query.flags & IB_SA_QUERY_OPA) {
1588 } else if (query->conv_pr) {
1589 sa_convert_path_opa_to_ib(query->conv_pr, rec);
1591 query->conv_pr, mad->data);
1597 *sa_query = &query->sa_query;
1599 query->sa_query.flags |= IB_SA_ENABLE_LOCAL_SERVICE;
1600 query->sa_query.mad_buf->context[1] = (query->conv_pr) ?
1601 query->conv_pr : rec;
1603 ret = send_mad(&query->sa_query, timeout_ms, gfp_mask);
1611 ib_sa_client_put(query->sa_query.client);
1612 free_mad(&query->sa_query);
1614 kfree(query->conv_pr);
1616 kfree(query);
1624 struct ib_sa_mcmember_query *query =
1632 query->callback(status, &rec, query->context);
1634 query->callback(status, NULL, query->context);
1654 struct ib_sa_mcmember_query *query;
1667 query = kzalloc(sizeof(*query), gfp_mask);
1668 if (!query)
1671 query->sa_query.port = port;
1672 ret = alloc_mad(&query->sa_query, gfp_mask);
1677 query->sa_query.client = client;
1678 query->callback = callback;
1679 query->context = context;
1681 mad = query->sa_query.mad_buf->mad;
1682 init_mad(&query->sa_query, agent);
1684 query->sa_query.callback = callback ? ib_sa_mcmember_rec_callback : NULL;
1685 query->sa_query.release = ib_sa_mcmember_rec_release;
1693 *sa_query = &query->sa_query;
1695 ret = send_mad(&query->sa_query, timeout_ms, gfp_mask);
1703 ib_sa_client_put(query->sa_query.client);
1704 free_mad(&query->sa_query);
1707 kfree(query);
1715 struct ib_sa_guidinfo_query *query =
1723 query->callback(status, &rec, query->context);
1725 query->callback(status, NULL, query->context);
1744 struct ib_sa_guidinfo_query *query;
1763 query = kzalloc(sizeof(*query), gfp_mask);
1764 if (!query)
1767 query->sa_query.port = port;
1768 ret = alloc_mad(&query->sa_query, gfp_mask);
1773 query->sa_query.client = client;
1774 query->callback = callback;
1775 query->context = context;
1777 mad = query->sa_query.mad_buf->mad;
1778 init_mad(&query->sa_query, agent);
1780 query->sa_query.callback = callback ? ib_sa_guidinfo_rec_callback : NULL;
1781 query->sa_query.release = ib_sa_guidinfo_rec_release;
1790 *sa_query = &query->sa_query;
1792 ret = send_mad(&query->sa_query, timeout_ms, gfp_mask);
1800 ib_sa_client_put(query->sa_query.client);
1801 free_mad(&query->sa_query);
1804 kfree(query);
1825 struct ib_sa_classport_info_query *query =
1869 query->callback(query->context);
1885 struct ib_sa_classport_info_query *query;
1892 query = kzalloc(sizeof(*query), gfp_mask);
1893 if (!query)
1896 query->sa_query.port = port;
1897 query->sa_query.flags |= rdma_cap_opa_ah(port->agent->device,
1900 ret = alloc_mad(&query->sa_query, gfp_mask);
1904 query->callback = callback;
1905 query->context = context;
1907 mad = query->sa_query.mad_buf->mad;
1908 init_mad(&query->sa_query, agent);
1910 query->sa_query.callback = ib_sa_classport_info_rec_callback;
1911 query->sa_query.release = ib_sa_classport_info_rec_release;
1915 *sa_query = &query->sa_query;
1917 ret = send_mad(&query->sa_query, timeout_ms, gfp_mask);
1925 free_mad(&query->sa_query);
1928 kfree(query);
1966 /* If the classport info is still not valid, the query should have
1967 * failed for some reason. Retry issuing the query
1988 struct ib_sa_query *query = mad_send_wc->send_buf->context[0];
1991 if (query->callback)
1997 query->callback(query, -ETIMEDOUT, NULL);
2000 query->callback(query, -EINTR, NULL);
2003 query->callback(query, -EIO, NULL);
2008 __xa_erase(&queries, query->id);
2011 free_mad(query);
2012 if (query->client)
2013 ib_sa_client_put(query->client);
2014 query->release(query);
2021 struct ib_sa_query *query;
2026 query = send_buf->context[0];
2027 if (query->callback) {
2029 query->callback(query,
2034 query->callback(query, -EIO, NULL);
2050 pr_warn("Couldn't query port\n");