diff options
author | Swapna Thete <swapna.thete@qlogic.com> | 2012-02-25 20:47:32 -0500 |
---|---|---|
committer | Roland Dreier <roland@purestorage.com> | 2012-02-25 20:47:32 -0500 |
commit | 0b307043049f34211affdde46f82e7abbe8c4590 (patch) | |
tree | 49a9078b56a6d24884e6f656ec35eb29229d60a8 /drivers/infiniband | |
parent | d144b650c635b941c3d73ef995ec16984594157f (diff) |
IB/mad: Return error response for unsupported MADs
Set up a response with appropriate error status and send it for MADs
that are not supported by a specific class/version.
Reviewed-by: Hal Rosenstock <hal@mellanox.com>
Signed-off-by: Swapna Thete <swapna.thete@qlogic.com>
Signed-off-by: Roland Dreier <roland@purestorage.com>
Diffstat (limited to 'drivers/infiniband')
-rw-r--r-- | drivers/infiniband/core/mad.c | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/drivers/infiniband/core/mad.c b/drivers/infiniband/core/mad.c index 2fe428bba54c..426bb7617ec6 100644 --- a/drivers/infiniband/core/mad.c +++ b/drivers/infiniband/core/mad.c | |||
@@ -1842,6 +1842,24 @@ static void ib_mad_complete_recv(struct ib_mad_agent_private *mad_agent_priv, | |||
1842 | } | 1842 | } |
1843 | } | 1843 | } |
1844 | 1844 | ||
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 | |||
1858 | return true; | ||
1859 | } else { | ||
1860 | return false; | ||
1861 | } | ||
1862 | } | ||
1845 | static void ib_mad_recv_done_handler(struct ib_mad_port_private *port_priv, | 1863 | static void ib_mad_recv_done_handler(struct ib_mad_port_private *port_priv, |
1846 | struct ib_wc *wc) | 1864 | struct ib_wc *wc) |
1847 | { | 1865 | { |
@@ -1963,6 +1981,9 @@ local: | |||
1963 | * or via recv_handler in ib_mad_complete_recv() | 1981 | * or via recv_handler in ib_mad_complete_recv() |
1964 | */ | 1982 | */ |
1965 | recv = NULL; | 1983 | recv = NULL; |
1984 | } else if (generate_unmatched_resp(recv, response)) { | ||
1985 | agent_send_response(&response->mad.mad, &recv->grh, wc, | ||
1986 | port_priv->device, port_num, qp_info->qp->qp_num); | ||
1966 | } | 1987 | } |
1967 | 1988 | ||
1968 | out: | 1989 | out: |