diff options
Diffstat (limited to 'drivers/infiniband/core/mad.c')
| -rw-r--r-- | drivers/infiniband/core/mad.c | 47 |
1 files changed, 12 insertions, 35 deletions
diff --git a/drivers/infiniband/core/mad.c b/drivers/infiniband/core/mad.c index dc3fd1e8af0..b4d8672a3e4 100644 --- a/drivers/infiniband/core/mad.c +++ b/drivers/infiniband/core/mad.c | |||
| @@ -35,7 +35,6 @@ | |||
| 35 | */ | 35 | */ |
| 36 | #include <linux/dma-mapping.h> | 36 | #include <linux/dma-mapping.h> |
| 37 | #include <linux/slab.h> | 37 | #include <linux/slab.h> |
| 38 | #include <linux/module.h> | ||
| 39 | #include <rdma/ib_cache.h> | 38 | #include <rdma/ib_cache.h> |
| 40 | 39 | ||
| 41 | #include "mad_priv.h" | 40 | #include "mad_priv.h" |
| @@ -1597,9 +1596,6 @@ find_mad_agent(struct ib_mad_port_private *port_priv, | |||
| 1597 | mad->mad_hdr.class_version].class; | 1596 | mad->mad_hdr.class_version].class; |
| 1598 | if (!class) | 1597 | if (!class) |
| 1599 | goto out; | 1598 | goto out; |
| 1600 | if (convert_mgmt_class(mad->mad_hdr.mgmt_class) >= | ||
| 1601 | IB_MGMT_MAX_METHODS) | ||
| 1602 | goto out; | ||
| 1603 | method = class->method_table[convert_mgmt_class( | 1599 | method = class->method_table[convert_mgmt_class( |
| 1604 | mad->mad_hdr.mgmt_class)]; | 1600 | mad->mad_hdr.mgmt_class)]; |
| 1605 | if (method) | 1601 | if (method) |
| @@ -1842,26 +1838,6 @@ static void ib_mad_complete_recv(struct ib_mad_agent_private *mad_agent_priv, | |||
| 1842 | } | 1838 | } |
| 1843 | } | 1839 | } |
| 1844 | 1840 | ||
| 1845 | static bool generate_unmatched_resp(struct ib_mad_private *recv, | ||
| 1846 | struct ib_mad_private *response) | ||
| 1847 | { | ||
| 1848 | if (recv->mad.mad.mad_hdr.method == IB_MGMT_METHOD_GET || | ||
| 1849 | recv->mad.mad.mad_hdr.method == IB_MGMT_METHOD_SET) { | ||
| 1850 | memcpy(response, recv, sizeof *response); | ||
| 1851 | response->header.recv_wc.wc = &response->header.wc; | ||
| 1852 | response->header.recv_wc.recv_buf.mad = &response->mad.mad; | ||
| 1853 | response->header.recv_wc.recv_buf.grh = &response->grh; | ||
| 1854 | response->mad.mad.mad_hdr.method = IB_MGMT_METHOD_GET_RESP; | ||
| 1855 | response->mad.mad.mad_hdr.status = | ||
| 1856 | cpu_to_be16(IB_MGMT_MAD_STATUS_UNSUPPORTED_METHOD_ATTRIB); | ||
| 1857 | if (recv->mad.mad.mad_hdr.mgmt_class == IB_MGMT_CLASS_SUBN_DIRECTED_ROUTE) | ||
| 1858 | response->mad.mad.mad_hdr.status |= IB_SMP_DIRECTION; | ||
| 1859 | |||
| 1860 | return true; | ||
| 1861 | } else { | ||
| 1862 | return false; | ||
| 1863 | } | ||
| 1864 | } | ||
| 1865 | static void ib_mad_recv_done_handler(struct ib_mad_port_private *port_priv, | 1841 | static void ib_mad_recv_done_handler(struct ib_mad_port_private *port_priv, |
| 1866 | struct ib_wc *wc) | 1842 | struct ib_wc *wc) |
| 1867 | { | 1843 | { |
| @@ -1871,7 +1847,6 @@ static void ib_mad_recv_done_handler(struct ib_mad_port_private *port_priv, | |||
| 1871 | struct ib_mad_list_head *mad_list; | 1847 | struct ib_mad_list_head *mad_list; |
| 1872 | struct ib_mad_agent_private *mad_agent; | 1848 | struct ib_mad_agent_private *mad_agent; |
| 1873 | int port_num; | 1849 | int port_num; |
| 1874 | int ret = IB_MAD_RESULT_SUCCESS; | ||
| 1875 | 1850 | ||
| 1876 | mad_list = (struct ib_mad_list_head *)(unsigned long)wc->wr_id; | 1851 | mad_list = (struct ib_mad_list_head *)(unsigned long)wc->wr_id; |
| 1877 | qp_info = mad_list->mad_queue->qp_info; | 1852 | qp_info = mad_list->mad_queue->qp_info; |
| @@ -1955,6 +1930,8 @@ static void ib_mad_recv_done_handler(struct ib_mad_port_private *port_priv, | |||
| 1955 | local: | 1930 | local: |
| 1956 | /* Give driver "right of first refusal" on incoming MAD */ | 1931 | /* Give driver "right of first refusal" on incoming MAD */ |
| 1957 | if (port_priv->device->process_mad) { | 1932 | if (port_priv->device->process_mad) { |
| 1933 | int ret; | ||
| 1934 | |||
| 1958 | ret = port_priv->device->process_mad(port_priv->device, 0, | 1935 | ret = port_priv->device->process_mad(port_priv->device, 0, |
| 1959 | port_priv->port_num, | 1936 | port_priv->port_num, |
| 1960 | wc, &recv->grh, | 1937 | wc, &recv->grh, |
| @@ -1982,10 +1959,6 @@ local: | |||
| 1982 | * or via recv_handler in ib_mad_complete_recv() | 1959 | * or via recv_handler in ib_mad_complete_recv() |
| 1983 | */ | 1960 | */ |
| 1984 | recv = NULL; | 1961 | recv = NULL; |
| 1985 | } else if ((ret & IB_MAD_RESULT_SUCCESS) && | ||
| 1986 | generate_unmatched_resp(recv, response)) { | ||
| 1987 | agent_send_response(&response->mad.mad, &recv->grh, wc, | ||
| 1988 | port_priv->device, port_num, qp_info->qp->qp_num); | ||
| 1989 | } | 1962 | } |
| 1990 | 1963 | ||
| 1991 | out: | 1964 | out: |
| @@ -2004,7 +1977,7 @@ static void adjust_timeout(struct ib_mad_agent_private *mad_agent_priv) | |||
| 2004 | unsigned long delay; | 1977 | unsigned long delay; |
| 2005 | 1978 | ||
| 2006 | if (list_empty(&mad_agent_priv->wait_list)) { | 1979 | if (list_empty(&mad_agent_priv->wait_list)) { |
| 2007 | cancel_delayed_work(&mad_agent_priv->timed_work); | 1980 | __cancel_delayed_work(&mad_agent_priv->timed_work); |
| 2008 | } else { | 1981 | } else { |
| 2009 | mad_send_wr = list_entry(mad_agent_priv->wait_list.next, | 1982 | mad_send_wr = list_entry(mad_agent_priv->wait_list.next, |
| 2010 | struct ib_mad_send_wr_private, | 1983 | struct ib_mad_send_wr_private, |
| @@ -2013,11 +1986,13 @@ static void adjust_timeout(struct ib_mad_agent_private *mad_agent_priv) | |||
| 2013 | if (time_after(mad_agent_priv->timeout, | 1986 | if (time_after(mad_agent_priv->timeout, |
| 2014 | mad_send_wr->timeout)) { | 1987 | mad_send_wr->timeout)) { |
| 2015 | mad_agent_priv->timeout = mad_send_wr->timeout; | 1988 | mad_agent_priv->timeout = mad_send_wr->timeout; |
| 1989 | __cancel_delayed_work(&mad_agent_priv->timed_work); | ||
| 2016 | delay = mad_send_wr->timeout - jiffies; | 1990 | delay = mad_send_wr->timeout - jiffies; |
| 2017 | if ((long)delay <= 0) | 1991 | if ((long)delay <= 0) |
| 2018 | delay = 1; | 1992 | delay = 1; |
| 2019 | mod_delayed_work(mad_agent_priv->qp_info->port_priv->wq, | 1993 | queue_delayed_work(mad_agent_priv->qp_info-> |
| 2020 | &mad_agent_priv->timed_work, delay); | 1994 | port_priv->wq, |
| 1995 | &mad_agent_priv->timed_work, delay); | ||
| 2021 | } | 1996 | } |
| 2022 | } | 1997 | } |
| 2023 | } | 1998 | } |
| @@ -2050,9 +2025,11 @@ static void wait_for_response(struct ib_mad_send_wr_private *mad_send_wr) | |||
| 2050 | list_add(&mad_send_wr->agent_list, list_item); | 2025 | list_add(&mad_send_wr->agent_list, list_item); |
| 2051 | 2026 | ||
| 2052 | /* Reschedule a work item if we have a shorter timeout */ | 2027 | /* Reschedule a work item if we have a shorter timeout */ |
| 2053 | if (mad_agent_priv->wait_list.next == &mad_send_wr->agent_list) | 2028 | if (mad_agent_priv->wait_list.next == &mad_send_wr->agent_list) { |
| 2054 | mod_delayed_work(mad_agent_priv->qp_info->port_priv->wq, | 2029 | __cancel_delayed_work(&mad_agent_priv->timed_work); |
| 2055 | &mad_agent_priv->timed_work, delay); | 2030 | queue_delayed_work(mad_agent_priv->qp_info->port_priv->wq, |
| 2031 | &mad_agent_priv->timed_work, delay); | ||
| 2032 | } | ||
| 2056 | } | 2033 | } |
| 2057 | 2034 | ||
| 2058 | void ib_reset_mad_timeout(struct ib_mad_send_wr_private *mad_send_wr, | 2035 | void ib_reset_mad_timeout(struct ib_mad_send_wr_private *mad_send_wr, |
