[ofw] [PATCH] Make al_cep_get_pdata return NTSTATUS
Fab Tillier
ftillier at windows.microsoft.com
Tue Jul 1 12:22:00 PDT 2008
There are a bunch of places where ib_api_status_t is converted to either cl_status_t or NTSTATUS. Thankfully cl_status_t and NTSTATUS are the same now.
There's no reason not to make al_cep_get_pdata return NTSTATUS. It makes the IRP handling a lot simpler.
This patch does this.
Signed-off-by: Fab Tillier <ftillier at microsoft.com>
diff -up -r -X trunk\docs\dontdiff.txt -I \$Id: old\core\al\al_cm_cep.h trunk\core\al\al_cm_cep.h
--- old\core\al\al_cm_cep.h Tue Jul 01 12:06:18 2008
+++ trunk\core\al\al_cm_cep.h Tue Jul 01 12:06:46 2008
@@ -280,7 +280,7 @@ al_cep_get_cid(
IN PIRP h_ioctl
);
-ib_api_status_t
+NTSTATUS
al_cep_get_pdata(
IN ib_al_handle_t h_al,
IN net32_t cid,
diff -up -r -X trunk\docs\dontdiff.txt -I \$Id: old\core\al\kernel\al_cm_cep.c trunk\core\al\kernel\al_cm_cep.c
--- old\core\al\kernel\al_cm_cep.c Tue Jul 01 12:06:18 2008
+++ trunk\core\al\kernel\al_cm_cep.c Tue Jul 01 12:06:46 2008
@@ -6379,7 +6379,7 @@ exit:
}
-ib_api_status_t
+NTSTATUS
al_cep_get_pdata(
IN ib_al_handle_t h_al,
IN net32_t cid,
@@ -6388,7 +6388,7 @@ al_cep_get_pdata(
{
kcep_t *p_cep;
KLOCK_QUEUE_HANDLE hdl;
- uint8_t remainder;
+ uint8_t copy_len;
AL_ENTER( AL_DBG_CM );
@@ -6401,34 +6401,22 @@ al_cep_get_pdata(
KeReleaseInStackQueuedSpinLock( &hdl );
AL_PRINT_EXIT( TRACE_LEVEL_ERROR, AL_DBG_ERROR,
("CEP not found for cid %d, h_al %p\n", cid, h_al ));
- return IB_INVALID_HANDLE;
+ return STATUS_CONNECTION_INVALID;
}
- if ( *p_psize < p_cep->psize )
- {
- KeReleaseInStackQueuedSpinLock( &hdl );
- AL_PRINT_EXIT( TRACE_LEVEL_ERROR, AL_DBG_ERROR,
- ("Insufficient size: *p_psize %d, max %d, cid %d, h_al %p\n",
- *p_psize, p_cep->psize, cid, h_al ));
- return IB_INVALID_PARAMETER;
- }
-
- memcpy( pdata, p_cep->pdata, p_cep->psize );
- remainder = *p_psize - p_cep->psize;
- if (remainder)
- cl_memclr( &pdata[p_cep->psize], remainder );
- *p_psize = p_cep->psize;
- if ( !*p_psize )
- {
- AL_PRINT_EXIT( TRACE_LEVEL_ERROR, AL_DBG_ERROR,
- ("p_cep->psize is zero for cid %d, h_al %p\n", cid, h_al ));
- }
+ copy_len = min( *p_psize, p_cep->psize );
+
+ if( copy_len )
+ RtlCopyMemory( pdata, p_cep->pdata, copy_len );
+
+ // Always report the maximum available user private data.
+ *p_psize = p_cep->psize;
AL_PRINT(TRACE_LEVEL_INFORMATION ,AL_DBG_CM ,
("al_cep_get_pdata: get %d of pdata from CEP with cid %d, h_al %p, context %p \n",
- p_cep->psize, cid, h_al, p_cep->context ));
+ copy_len, cid, h_al, p_cep->context ));
KeReleaseInStackQueuedSpinLock( &hdl );
AL_EXIT( AL_DBG_CM );
- return IB_SUCCESS;
+ return STATUS_SUCCESS;
}
diff -up -r -X trunk\docs\dontdiff.txt -I \$Id: old\core\al\kernel\al_proxy_cep.c trunk\core\al\kernel\al_proxy_cep.c
--- old\core\al\kernel\al_proxy_cep.c Tue Jul 01 10:36:03 2008
+++ trunk\core\al\kernel\al_proxy_cep.c Tue Jul 01 12:06:46 2008
@@ -899,10 +899,8 @@ proxy_cep_get_pdata(
{
al_dev_open_context_t *p_context;
ual_cep_get_pdata_ioctl_t *p_ioctl;
- ib_qp_handle_t VOID_PTR64 h_qp = NULL;
- net32_t cid;
- ib_api_status_t status;
- cl_status_t cl_status;
+ al_conn_qp_t *p_qp;
+ NTSTATUS status;
AL_ENTER( AL_DBG_CM );
@@ -921,47 +919,34 @@ proxy_cep_get_pdata(
return CL_INVALID_PARAMETER;
}
- *p_ret_bytes = sizeof(struct _ual_cep_get_pdata_ioctl_out);
-
if ( p_ioctl->in.h_qp )
{
/* Get the kernel QP handle. */
- h_qp = (ib_qp_handle_t VOID_PTR64)al_hdl_ref(
+ p_qp = (al_conn_qp_t*)al_hdl_ref(
p_context->h_al, p_ioctl->in.h_qp, AL_OBJ_TYPE_H_QP );
- if( !h_qp )
+ if( !p_qp )
{
AL_PRINT_EXIT( TRACE_LEVEL_ERROR, AL_DBG_ERROR,
("Invalid QP handle\n"));
return CL_CONNECTION_INVALID;
}
- cid = ((al_conn_qp_t*)h_qp)->cid;
- }
- else
- {
- cid = p_ioctl->in.cid;
+ p_ioctl->in.cid = p_qp->cid;
+ deref_al_obj( &p_qp->qp.obj );
}
p_ioctl->out.pdata_len = sizeof(p_ioctl->out.pdata);
- status = al_cep_get_pdata( p_context->h_al, cid,
+ status = al_cep_get_pdata( p_context->h_al, p_ioctl->in.cid,
(uint8_t*)&p_ioctl->out.pdata_len, p_ioctl->out.pdata );
- if ( status == IB_SUCCESS )
+ if( NT_SUCCESS( status ) )
{
- cl_status = CL_SUCCESS;
- *p_ret_bytes = p_ioctl->out.pdata_len;
+ *p_ret_bytes = sizeof(struct _ual_cep_get_pdata_ioctl_out);
AL_PRINT(TRACE_LEVEL_INFORMATION ,AL_DBG_CM ,
("proxy_cep_get_pdata: get %d of pdata \n", (int)*p_ret_bytes ));
}
- else
- {
- cl_status = CL_CONNECTION_INVALID;
- }
-
- if ( h_qp )
- deref_al_obj( &h_qp->obj );
AL_EXIT( AL_DBG_CM );
- return cl_status;
+ return status;
}
cl_status_t cep_ioctl(
-------------- next part --------------
A non-text attachment was scrubbed...
Name: cep_get_pdata_native.patch
Type: application/octet-stream
Size: 4494 bytes
Desc: cep_get_pdata_native.patch
URL: <http://lists.openfabrics.org/pipermail/ofw/attachments/20080701/8c217751/attachment.obj>
More information about the ofw
mailing list