[openib-general] [PATCH] ib_mad: Fix send only registrations
Hal Rosenstock
Thu Oct 14 10:33:08 PDT 2004
ib_mad: Fix send only registrations
Index: ib_mad.c
===================================================================
--- ib_mad.c (revision 990)
+++ ib_mad.c (working copy)
@@ -116,11 +116,6 @@
goto error1;
}
- if (!send_handler) {
- ret = ERR_PTR(-EINVAL);
- goto error1;
- }
-
if (rmpp_version) {
ret = ERR_PTR(-EINVAL); /* until RMPP implemented!!! */
goto error1;
@@ -128,11 +123,22 @@
/* Validate MAD registration request if supplied */
if (mad_reg_req) {
- if (!recv_handler ||
- mad_reg_req->mgmt_class_version >= MAX_MGMT_VERSION) {
+ if (mad_reg_req->mgmt_class_version >= MAX_MGMT_VERSION) {
ret = ERR_PTR(-EINVAL);
goto error1;
}
+ if (!bitmap_empty(mad_reg_req->method_mask,
+ IB_MGMT_MAX_METHODS)) {
+ if (!recv_handler) {
+ ret = ERR_PTR(-EINVAL);
+ goto error1;
+ }
+ } else {
+ if (!send_handler) {
+ ret = ERR_PTR(-EINVAL);
+ goto error1;
+ }
+ }
if (mad_reg_req->mgmt_class >= MAX_MGMT_CLASS) {
/*
* IB_MGMT_CLASS_SUBN_DIRECTED_ROUTE is the only
@@ -151,6 +157,12 @@
ret = ERR_PTR(-EINVAL);
goto error1;
}
+ } else {
+ /* No registration request supplied */
+ if (!send_handler) {
+ ret = ERR_PTR(-EINVAL);
+ goto error1;
+ }
}
/* Validate device and port */
@@ -842,7 +854,9 @@
spin_unlock_irqrestore(&mad_agent_priv->lock, flags);
/* Defined behavior is to complete response before request */
- mad_agent_priv->agent.recv_handler(&mad_agent_priv->agent,
+ if (mad_agent_priv->agent.recv_handler)
+ mad_agent_priv->agent.recv_handler(
+ &mad_agent_priv->agent,
&recv->header.recv_wc);
atomic_dec(&mad_agent_priv->refcount);
@@ -851,7 +865,9 @@
mad_send_wc.wr_id = mad_send_wr->wr_id;
ib_mad_complete_send_wr(mad_send_wr, &mad_send_wc);
} else {
- mad_agent_priv->agent.recv_handler(&mad_agent_priv->agent,
+ if (mad_agent_priv->agent.recv_handler)
+ mad_agent_priv->agent.recv_handler(
+ &mad_agent_priv->agent,
&recv->header.recv_wc);
if (atomic_dec_and_test(&mad_agent_priv->refcount))
wake_up(&mad_agent_priv->wait);
@@ -929,7 +945,7 @@
/* Snoop MAD ? */
if (port_priv->device->snoop_mad) {
if (port_priv->device->snoop_mad(port_priv->device,
- port_priv->port_num,
+ (u8)port_priv->port_num,
wc->slid,
recv->header.recv_buf.mad)) {
goto ret;
@@ -952,7 +968,7 @@
}
ret:
- if (!mad_agent) {
+ if (!mad_agent || !mad_agent->agent.recv_handler) {
/* Should this case be optimized ? */
kmem_cache_free(ib_mad_cache, recv);
}
@@ -1018,7 +1034,9 @@
if (mad_send_wr->status != IB_WC_SUCCESS )
mad_send_wc->status = mad_send_wr->status;
- mad_agent_priv->agent.send_handler(&mad_agent_priv->agent,
mad_send_wc);
+ if (mad_agent_priv->agent.send_handler)
+ mad_agent_priv->agent.send_handler(&mad_agent_priv->agent,
+ mad_send_wc);
/* Release reference on agent taken when sending */
if (atomic_dec_and_test(&mad_agent_priv->refcount))
@@ -1135,7 +1153,9 @@
list_for_each_entry_safe(mad_send_wr, temp_mad_send_wr,
&cancel_list, agent_list) {
mad_send_wc.wr_id = mad_send_wr->wr_id;
- mad_agent_priv->agent.send_handler(&mad_agent_priv->agent,
+ if (mad_agent_priv->agent.send_handler)
+ mad_agent_priv->agent.send_handler(
+ &mad_agent_priv->agent,
&mad_send_wc);
list_del(&mad_send_wr->agent_list);
@@ -1196,8 +1216,9 @@
mad_send_wc.status = IB_WC_WR_FLUSH_ERR;
mad_send_wc.vendor_err = 0;
mad_send_wc.wr_id = mad_send_wr->wr_id;
- mad_agent_priv->agent.send_handler(&mad_agent_priv->agent,
- &mad_send_wc);
+ if (mad_agent_priv->agent.send_handler)
+ mad_agent_priv->agent.send_handler(&mad_agent_priv->agent,
+ &mad_send_wc);
kfree(mad_send_wr);
if (atomic_dec_and_test(&mad_agent_priv->refcount))
More information about the openib-general mailing list