[Openib-windows] RE: Anything new about the IPOIB arp check-in?
Tzachi Dar
tzachid at mellanox.co.il
Tue Nov 8 08:51:38 PST 2005
Hi Fab,
As the pressure is down again, I'm sending you the revisad patch again.
Thanks
Tzachi
Index: ip_packet.h
===================================================================
--- ip_packet.h (revision 148)
+++ ip_packet.h (working copy)
@@ -37,12 +37,6 @@
#include <complib/cl_types.h>
#include <complib/cl_byteswap.h>
-
-#ifndef HW_ADDR_LEN
-#define HW_ADDR_LEN 6
-#endif /* HW_ADDR_LEN */
-
-
#define ETH_PROT_TYPE_IP CL_HTON16(0x800)
#define ETH_PROT_TYPE_ARP CL_HTON16(0x806)
Index: kernel/ip_Addresses.c
===================================================================
--- kernel/ip_Addresses.c (revision 0)
+++ kernel/ip_Addresses.c (revision 0)
@@ -0,0 +1,600 @@
+/*
+ * Copyright (c) 2005 Mellanox Technologies. All rights reserved.
+ *
+ * This software is available to you under the OpenIB.org BSD license
+ * below:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ * $Id: ip_packet.h 47 2005-05-30 18:00:40Z sleybo $
+ */
+#include <iba/ib_types.h>
+#include "ip_addresses_shared.h"
+#include "ipoib_adapter.h"
+#include "ipoib_port.h"
+#include "ipoib_debug.h"
+#include "ip_addresses.h"
+#include "ipoib_endpoint.h"
+
+
+NTSTATUS
+__ipoib_dispatch(
+ IN PDEVICE_OBJECT device_object,
+ IN PIRP Irp
+ );
+
+
+struct ipoib_addresses_config {
+
+ PDEVICE_OBJECT device_object;
+ NDIS_HANDLE ndis_device_handle;
+ cl_list_t ports_list;
+ cl_spinlock_t spin_lock; // To protect the list
+ NDIS_HANDLE g_ndis_wrapper_handle;
+
+};
+
+
+
+struct ipoib_addresses_config g_ipoib_addresses_config;
+
+void __ipoib_lock_list()
+{
+ cl_spinlock_acquire(&g_ipoib_addresses_config.spin_lock);
+}
+
+void __ipoib_unlock_list()
+{
+ cl_spinlock_release(&g_ipoib_addresses_config.spin_lock);
+}
+
+
+NDIS_STATUS __ipoib_ip_create_device(
+ NDIS_HANDLE ndis_wrapper_handle
+ );
+
+VOID __ipoib_dregister_device();
+
+NDIS_STATUS ipoib_get_ipoib_ports(
+ struct IOCTL_IPOIB_PORTS_IN ports_in,
+ struct IOCTL_IPOIB_PORTS_OUT *ports_out,
+ IN ULONG OutputBufferLength,
+ OUT ULONG *pOutputDataSize
+ )
+{
+ NDIS_STATUS status = NDIS_STATUS_SUCCESS;
+ ULONG num_ports, i = 0;
+ ULONG needed_size_bytes;
+ cl_list_iterator_t it;
+ ipoib_adapter_t *p_adapter;
+ struct IPOIB_AT_PORT_RECORD *ports_records;
+
+ IPOIB_ENTER(IPOIB_DBG_IOCTL);
+ ports_out->Version = IPOIB_IOCTL_VERSION;
+ ports_out->Size = 0;
+ if (ports_in.Version != IPOIB_IOCTL_VERSION) {
+ IPOIB_TRACE( IPOIB_DBG_ERROR, ("unsupported version = 0x%x\n",
ports_in.Version ));
+ return STATUS_INVALID_PARAMETER;
+ }
+ num_ports =
(ULONG)cl_list_count(&g_ipoib_addresses_config.ports_list);
+ if (num_ports == 0) {
+ needed_size_bytes = sizeof (struct IOCTL_IPOIB_PORTS_OUT);
+ } else {
+ needed_size_bytes = sizeof (struct IOCTL_IPOIB_PORTS_OUT) +
+ (num_ports - 1) * sizeof (struct IPOIB_AT_PORT_RECORD);
+ }
+ if (needed_size_bytes > OutputBufferLength) {
+ // Not enough data for us to use, we should return only the
+ // size
+ ports_out->NumPorts = num_ports;
+ ports_out->Size = needed_size_bytes;
+ return NDIS_STATUS_SUCCESS;
+ }
+ *pOutputDataSize = needed_size_bytes;
+ ports_out->NumPorts = num_ports;
+ ports_records = ports_out->Ports;
+
+ __ipoib_lock_list();
+
+ for (it = cl_list_head(&g_ipoib_addresses_config.ports_list);
+ it != cl_list_end(&g_ipoib_addresses_config.ports_list);
+ it = cl_list_next(it), i++) {
+ p_adapter = cl_list_obj(it);
+
+ cl_obj_lock( &p_adapter->obj );
+ ports_records[i].CaGuid = p_adapter->guids.ca_guid;
+ ports_records[i].PortGuid = p_adapter->guids.port_guid;
+ cl_obj_unlock( &p_adapter->obj );
+
+ }
+ __ipoib_unlock_list();
+ CL_ASSERT(i == num_ports);
+ IPOIB_EXIT(IPOIB_DBG_IOCTL);
+ return status;
+
+}
+
+
+NDIS_STATUS __ipoib_get_port_ips(
+ struct IOCTL_IPOIB_IP_ADDRESSES_IN addresses_in,
+ struct IOCTL_IPOIB_IP_ADDRESSES_OUT *addresses_out,
+ IN ULONG OutputBufferLength,
+ OUT ULONG *pOutputDataSize
+ )
+{
+ ULONG num_ips, i = 0;
+ ULONG needed_size_bytes;
+ cl_list_iterator_t it;
+ ipoib_adapter_t *p_adapter;
+ struct IP_ADDRESS *ip_records;
+ net_address_item_t *p_addr_item;
+
+ IPOIB_ENTER(IPOIB_DBG_IOCTL);
+
+ addresses_out->Version = IPOIB_IOCTL_VERSION;
+ addresses_out->Size = 0;
+ if (addresses_in.Version != IPOIB_IOCTL_VERSION) {
+ IPOIB_TRACE( IPOIB_DBG_ERROR, ("unsupported version = 0x%x\n",
addresses_in.Version ));
+ return STATUS_INVALID_PARAMETER;
+ }
+ __ipoib_lock_list();
+
+ for (it = cl_list_head(&g_ipoib_addresses_config.ports_list);
+ it != cl_list_end(&g_ipoib_addresses_config.ports_list);
+ it = cl_list_next(it)) {
+ p_adapter = cl_list_obj(it);
+
+ cl_obj_lock( &p_adapter->obj );
+ if (p_adapter->guids.port_guid == addresses_in.PortGuid) {
+ // We should return our answer based on our answer
+ num_ips = (ULONG)
cl_vector_get_size(&p_adapter->ip_vector);
+ if (num_ips == 0) {
+ needed_size_bytes = sizeof (struct
IOCTL_IPOIB_IP_ADDRESSES_OUT);
+ } else {
+ needed_size_bytes = sizeof (struct
IOCTL_IPOIB_IP_ADDRESSES_OUT) +
+ (num_ips - 1) * sizeof (struct IP_ADDRESS);
+ }
+ if (needed_size_bytes > OutputBufferLength) {
+ // Not enough data for us to use, we should return only
the
+ // size
+ addresses_out->NumIps = num_ips;
+ addresses_out->Size = needed_size_bytes;
+ cl_obj_unlock( &p_adapter->obj );
+ __ipoib_unlock_list();
+ return NDIS_STATUS_SUCCESS;
+ }
+ *pOutputDataSize = needed_size_bytes;
+
+ addresses_out->NumIps = num_ips;
+ ip_records = addresses_out->Addreses;
+
+ // Copy all the IP's into the vector
+ for (i = 0 ; i < num_ips; i++) {
+
+ ip_records[i].IpVersion = 4;
+ p_addr_item = (net_address_item_t*)
+ cl_vector_get_ptr(
&p_adapter->ip_vector, i );
+ ip_records[i].Data[12] =
p_addr_item->address.as_bytes[0];
+ ip_records[i].Data[13] =
p_addr_item->address.as_bytes[1];
+ ip_records[i].Data[14] =
p_addr_item->address.as_bytes[2];
+ ip_records[i].Data[15] =
p_addr_item->address.as_bytes[3];
+ }
+
+ cl_obj_unlock( &p_adapter->obj );
+
+ __ipoib_unlock_list();
+ return NDIS_STATUS_SUCCESS;
+
+ }
+ cl_obj_unlock( &p_adapter->obj );
+
+
+ }
+ // If we have reached here, this means that the port was not found
+ __ipoib_unlock_list();
+ IPOIB_EXIT(IPOIB_DBG_IOCTL);
+ return STATUS_INVALID_PORT_HANDLE;
+
+}
+
+
+NDIS_STATUS __ipoib_get_gid(
+ struct IOCTL_IPOIB_MAC_2_GID_IN mac_in,
+ struct IOCTL_IPOIB_MAC_2_GID_OUT *gid_out,
+ OUT ULONG *pOutputDataSize
+ )
+{
+ cl_list_iterator_t it;
+ ipoib_adapter_t *p_adapter;
+ NDIS_STATUS status;
+ mac_addr_t mac;
+
+ IPOIB_ENTER(IPOIB_DBG_IOCTL);
+
+ *pOutputDataSize = sizeof (gid_out->DestGid);
+
+ // Go over all addapters and try to find the correct endpoint
+
+ memcpy(mac.addr, mac_in.DestMac, HW_ADDR_LEN);
+
+ __ipoib_lock_list();
+
+ for (it = cl_list_head(&g_ipoib_addresses_config.ports_list);
+ it != cl_list_end(&g_ipoib_addresses_config.ports_list);
+ it = cl_list_next(it)) {
+ p_adapter = cl_list_obj(it);
+
+ cl_obj_lock( &p_adapter->obj );
+
+ status = gid_from_mac( p_adapter->p_port, mac,
&gid_out->DestGid );
+
+ if (status == NDIS_STATUS_SUCCESS) {
+ cl_obj_unlock( &p_adapter->obj );
+ __ipoib_unlock_list();
+ IPOIB_EXIT(IPOIB_DBG_IOCTL);
+ return status;
+ }
+
+ cl_obj_unlock( &p_adapter->obj );
+
+
+ }
+ __ipoib_unlock_list();
+ IPOIB_EXIT(IPOIB_DBG_IOCTL);
+ return NDIS_STATUS_NO_ROUTE_TO_DESTINATION;
+
+}
+
+#define VERIFY_BUFFERS(InputBufferLength, OutputBufferLength,
InStructSize, OutStructZize) \
+if ((InputBufferLength < InStructSize) ||
\
+ (OutputBufferLength < OutStructZize)) {
\
+ IPOIB_TRACE( IPOIB_DBG_ERROR,
\
+ ("ipoib_dispatch_device_io_control bad buffer sizes\n" ));
\
+ CL_ASSERT(FALSE);
\
+ status = STATUS_ACCESS_VIOLATION;
\
+ goto Cleanup;
\
+}
+
+NDIS_STATUS __ipoib_dispatch_device_io_control(
+ IN PVOID pInputBuffer,
+ IN ULONG InputBufferLength ,
+ IN PVOID pOutputBuffer,
+ IN ULONG OutputBufferLength,
+ IN ULONG IoControlCode,
+ OUT ULONG *pOutputDataSize
+ )
+{
+ NDIS_STATUS status = NDIS_STATUS_SUCCESS;
+ struct IOCTL_IPOIB_PORTS_IN ports_in;
+ struct IOCTL_IPOIB_PORTS_OUT *ports_out;
+ struct IOCTL_IPOIB_IP_ADDRESSES_IN addreses_in;
+ struct IOCTL_IPOIB_IP_ADDRESSES_OUT *addreses_out;
+ struct IOCTL_IPOIB_MAC_2_GID_IN ip_in;
+ struct IOCTL_IPOIB_MAC_2_GID_OUT *ip_out;
+
+ IPOIB_ENTER(IPOIB_DBG_IOCTL);
+
+ switch (IoControlCode) {
+ case IOCTL_IPOIB_PORTS :
+ {
+ IPOIB_TRACE( IPOIB_DBG_IOCTL, ("IOCTL_IPOIB_PORTS
recieved\n" ));
+ VERIFY_BUFFERS(InputBufferLength, OutputBufferLength,
sizeof (struct IOCTL_IPOIB_PORTS_IN), sizeof (struct
IOCTL_IPOIB_PORTS_OUT));
+
+
+ ports_in = *(struct IOCTL_IPOIB_PORTS_IN *) pInputBuffer;
+ ports_out = (struct IOCTL_IPOIB_PORTS_OUT *) pOutputBuffer;
+
+ status = ipoib_get_ipoib_ports(
+ ports_in,
+ ports_out,
+ OutputBufferLength,
+ pOutputDataSize
+ );
+ }
+ break;
+ case IOCTL_IPOIB_IP_ADDRESSES :
+ {
+ IPOIB_TRACE( IPOIB_DBG_IOCTL, ("IOCTL_IPOIB_IP_ADDRESSES
recieved\n" ));
+ VERIFY_BUFFERS(InputBufferLength, OutputBufferLength,
sizeof (struct IOCTL_IPOIB_IP_ADDRESSES_IN), sizeof (struct
IOCTL_IPOIB_IP_ADDRESSES_OUT));
+
+ addreses_in = *(struct IOCTL_IPOIB_IP_ADDRESSES_IN *)
pInputBuffer;
+ addreses_out = (struct IOCTL_IPOIB_IP_ADDRESSES_OUT *)
pOutputBuffer;
+
+ status = __ipoib_get_port_ips(
+ addreses_in,
+ addreses_out,
+ OutputBufferLength,
+ pOutputDataSize
+ );
+ }
+ break;
+
+ case IOCTL_IPOIB_MAC_2_GID :
+ {
+ IPOIB_TRACE( IPOIB_DBG_IOCTL, ("IOCTL_IPOIB_MAC_2_GID
recieved\n" ));
+ VERIFY_BUFFERS(InputBufferLength, OutputBufferLength,
sizeof (struct IOCTL_IPOIB_MAC_2_GID_IN), sizeof (struct
IOCTL_IPOIB_MAC_2_GID_OUT));
+
+ ip_in = *(struct IOCTL_IPOIB_MAC_2_GID_IN *) pInputBuffer;
+ ip_out = (struct IOCTL_IPOIB_MAC_2_GID_OUT *)
pOutputBuffer;
+
+ status = __ipoib_get_gid(
+ ip_in,
+ ip_out,
+ pOutputDataSize
+ );
+ }
+ break;
+
+
+
+
+ default:
+ // This is an unrecgnized IOCTL
+ CL_ASSERT(FALSE);
+ IPOIB_TRACE( IPOIB_DBG_ERROR, ("unknow IOCTL code =
0x%x\n", IoControlCode ));
+ status = STATUS_INVALID_PARAMETER;
+ }
+Cleanup:
+ IPOIB_EXIT(IPOIB_DBG_IOCTL);
+ return status;
+
+}
+
+NDIS_STATUS ipoib_driver_up(NDIS_HANDLE ndis_wrapper_handle)
+{
+ NDIS_STATUS status;
+ IPOIB_ENTER(IPOIB_DBG_IOCTL);
+ status = cl_list_init(&g_ipoib_addresses_config.ports_list, 8);
+ if( status != CL_SUCCESS )
+ {
+ IPOIB_TRACE( IPOIB_DBG_ERROR,
+ ("cl_list_init failed with status of %d\n",
status) );
+ return status;
+ }
+
+ status = cl_spinlock_init(&g_ipoib_addresses_config.spin_lock);
+ IPOIB_EXIT(IPOIB_DBG_IOCTL);
+ g_ipoib_addresses_config.g_ndis_wrapper_handle =
ndis_wrapper_handle;
+ return status;
+
+
+}
+
+void ipoib_driver_unload()
+{
+ IPOIB_ENTER(IPOIB_DBG_IOCTL);
+ cl_list_destroy(&g_ipoib_addresses_config.ports_list);
+ cl_spinlock_destroy(&g_ipoib_addresses_config.spin_lock);
+ IPOIB_EXIT(IPOIB_DBG_IOCTL);
+
+}
+
+NDIS_STATUS __ipoib_ip_create_device(
+ NDIS_HANDLE ndis_wrapper_handle
+ )
+{
+ NDIS_STATUS status;
+ NDIS_STRING DeviceName;
+ NDIS_STRING DeviceLinkUnicodeString;
+ PDRIVER_DISPATCH DispatchTable[IRP_MJ_MAXIMUM_FUNCTION+1];
+
+ IPOIB_ENTER(IPOIB_DBG_IOCTL);
+
+ NdisInitUnicodeString(&DeviceName, IPOIB_DEV_NAME);
+ NdisInitUnicodeString(&DeviceLinkUnicodeString,
IPOIB_DOS_DEV_NAME);
+
+ NdisZeroMemory(DispatchTable, (IRP_MJ_MAXIMUM_FUNCTION+1) *
sizeof(PDRIVER_DISPATCH));
+
+ DispatchTable[IRP_MJ_CREATE] = __ipoib_dispatch;
+ DispatchTable[IRP_MJ_CLEANUP] = __ipoib_dispatch;
+ DispatchTable[IRP_MJ_CLOSE] = __ipoib_dispatch;
+ DispatchTable[IRP_MJ_DEVICE_CONTROL] = __ipoib_dispatch;
+ DispatchTable[IRP_MJ_INTERNAL_DEVICE_CONTROL] = __ipoib_dispatch;
+
+ status = NdisMRegisterDevice(
+ ndis_wrapper_handle,
+ &DeviceName,
+ &DeviceLinkUnicodeString,
+ &DispatchTable[0],
+ &g_ipoib_addresses_config.device_object,
+ &g_ipoib_addresses_config.ndis_device_handle
+ );
+ if( status != NDIS_STATUS_SUCCESS )
+ {
+ IPOIB_TRACE( IPOIB_DBG_ERROR,
+ ("NdisMRegisterDevice failed with status of
%d\n", status) );
+ } else {
+ IPOIB_TRACE( IPOIB_DBG_IOCTL,
+ ("NdisMRegisterDevice succeeded\n") );
+ }
+ IPOIB_EXIT(IPOIB_DBG_IOCTL);
+ return status;
+
+
+}
+
+NDIS_STATUS ipoib_add_adapter(ipoib_adapter_t *p_adapter)
+{
+ NDIS_STATUS status;
+ ULONG count;
+
+ IPOIB_ENTER(IPOIB_DBG_IOCTL);
+
+
+ __ipoib_lock_list();
+ count = (ULONG)
cl_list_count(&g_ipoib_addresses_config.ports_list);
+ status = cl_list_insert_head(&g_ipoib_addresses_config.ports_list,
p_adapter);
+ __ipoib_unlock_list();
+ if( status != NDIS_STATUS_SUCCESS )
+ {
+ IPOIB_TRACE( IPOIB_DBG_ERROR,
+ ("cl_list_insert_head failed with status of
%d\n", status) );
+ return status;
+ }
+
+
+ if (count == 0) {
+ status =
__ipoib_ip_create_device(g_ipoib_addresses_config.g_ndis_wrapper_handle)
;
+ if( status != NDIS_STATUS_SUCCESS )
+ {
+ IPOIB_TRACE( IPOIB_DBG_ERROR,
+ ("NdisMRegisterDevice failed with status of
%d\n", status) );
+ return status;
+ }
+
+ }
+ IPOIB_EXIT(IPOIB_DBG_IOCTL);
+ return status;
+}
+
+
+VOID ipoib_remove_adapter(ipoib_adapter_t *p_adapter)
+{
+ cl_status_t status;
+ ULONG count;
+
+ IPOIB_ENTER(IPOIB_DBG_IOCTL);
+
+ __ipoib_lock_list();
+ status =
cl_list_remove_object(&g_ipoib_addresses_config.ports_list, p_adapter);
+ CL_ASSERT(status == CL_SUCCESS);
+
+ count = (ULONG)cl_list_count(&g_ipoib_addresses_config.ports_list);
+ __ipoib_unlock_list();
+
+ if (count == 0 ) {
+ __ipoib_dregister_device();
+ }
+
+
+ IPOIB_EXIT(IPOIB_DBG_IOCTL);
+
+}
+
+VOID __ipoib_dregister_device()
+{
+ NDIS_STATUS status;
+ IPOIB_ENTER(IPOIB_DBG_IOCTL);
+
+ if (g_ipoib_addresses_config.ndis_device_handle != NULL) {
+ status =
NdisMDeregisterDevice(g_ipoib_addresses_config.ndis_device_handle);
+ if( status != NDIS_STATUS_SUCCESS )
+ {
+ IPOIB_TRACE( IPOIB_DBG_ERROR,
+ ("NdisMDeregisterDevice failed with status of
%d", status) );
+ } else {
+ IPOIB_TRACE( IPOIB_DBG_IOCTL,
+ ("NdisMDeregisterDevice succeeded\n") );
+ }
+
+ g_ipoib_addresses_config.ndis_device_handle = NULL;
+ }
+ IPOIB_EXIT(IPOIB_DBG_IOCTL);
+}
+
+
+NTSTATUS
+__ipoib_dispatch(
+ IN PDEVICE_OBJECT device_object,
+ IN PIRP pIrp
+ )
+/*++
+Routine Description:
+
+ Process IRPs sent to this device.
+
+Arguments:
+
+ device_object - pointer to a device object
+ Irp - pointer to an I/O Request Packet
+
+Return Value:
+
+ NTSTATUS - STATUS_SUCCESS always - change this when adding
+ real code to handle ioctls.
+
+--*/
+{
+ PIO_STACK_LOCATION pIrpSp;
+ NTSTATUS status = STATUS_SUCCESS;
+ int Method;
+ ULONG OutputDataSize = 0;
+
+ UNREFERENCED_PARAMETER(device_object);
+
+ IPOIB_ENTER(IPOIB_DBG_IOCTL);
+
+ pIrpSp = IoGetCurrentIrpStackLocation(pIrp);
+
+
+ switch (pIrpSp->MajorFunction)
+ {
+ case IRP_MJ_CREATE:
+ IPOIB_TRACE( IPOIB_DBG_IOCTL, ("IRP_MJ_CREATE recieved\n")
);
+ break;
+
+ case IRP_MJ_CLEANUP:
+ IPOIB_TRACE( IPOIB_DBG_IOCTL, ("IRP_MJ_CLEANUP recieved\n")
);
+ break;
+
+ case IRP_MJ_CLOSE:
+ IPOIB_TRACE( IPOIB_DBG_IOCTL, ("IRP_MJ_CLOSE recieved\n")
);
+ break;
+
+ case IRP_MJ_INTERNAL_DEVICE_CONTROL:
+ IPOIB_TRACE( IPOIB_DBG_IOCTL,
("IRP_MJ_INTERNAL_DEVICE_CONTROL recieved\n") );
+ // Intentionly fail down
+ case IRP_MJ_DEVICE_CONTROL:
+ IPOIB_TRACE( IPOIB_DBG_IOCTL, ("IRP_MJ_DEVICE_CONTROL
recieved\n") );
+ Method = pIrpSp->Parameters.DeviceIoControl.IoControlCode &
0x3;
+ if (Method != METHOD_BUFFERED) {
+ // We only support method buffered (very small
requests)
+ status = STATUS_INVALID_PARAMETER;
+ IPOIB_TRACE( IPOIB_DBG_ERROR,
+ ("Unsupporteed ioctl Method %d\n",
Method) );
+ } else {
+ status = __ipoib_dispatch_device_io_control(
+ pIrp->AssociatedIrp.SystemBuffer,
+
pIrpSp->Parameters.DeviceIoControl.InputBufferLength,
+ pIrp->AssociatedIrp.SystemBuffer,
+
pIrpSp->Parameters.DeviceIoControl.OutputBufferLength,
+ pIrpSp->Parameters.DeviceIoControl.IoControlCode,
+ &OutputDataSize
+ );
+ }
+ break;
+ default:
+ break;
+ }
+ CL_ASSERT(status != STATUS_PENDING);
+
+ pIrp->IoStatus.Status = status;
+ pIrp->IoStatus.Information = OutputDataSize;
+ IoCompleteRequest(pIrp, IO_NO_INCREMENT);
+
+ IPOIB_EXIT(IPOIB_DBG_IOCTL);
+
+ return status;
+
+}
+
Index: kernel/ip_Addresses.h
===================================================================
--- kernel/ip_Addresses.h (revision 0)
+++ kernel/ip_Addresses.h (revision 0)
@@ -0,0 +1,50 @@
+/*
+ * Copyright (c) 2005 Mellanox Technologies. All rights reserved.
+ *
+ * This software is available to you under the OpenIB.org BSD license
+ * below:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ * $Id: ip_packet.h 47 2005-05-30 18:00:40Z sleybo $
+ */
+
+#ifndef _IP_ADDRESSES_H_
+#define _IP_ADDRESSES_H_
+
+#include <ip_addresses_shared.h>
+
+NDIS_STATUS ipoib_driver_up(
+ NDIS_HANDLE ndis_wrapper_handle
+ );
+
+void ipoib_driver_unload();
+
+//VOID dregister_device();
+
+NDIS_STATUS ipoib_add_adapter(ipoib_adapter_t *p_adapter);
+
+VOID ipoib_remove_adapter(ipoib_adapter_t *p_adapter);
+
+
+#endif /* _IP_ADDRESSES_H_ */
Index: kernel/ipoib_adapter.c
===================================================================
--- kernel/ipoib_adapter.c (revision 148)
+++ kernel/ipoib_adapter.c (working copy)
@@ -30,13 +30,14 @@
*/
-
+#include <iba/ib_types.h>
+#include "ip_addresses_shared.h"
#include "ipoib_adapter.h"
#include "ipoib_port.h"
#include "ipoib_driver.h"
#include "ipoib_debug.h"
+#include <ip_addresses.h>
-
#define ITEM_POOL_START 16
#define ITEM_POOL_GROW 16
@@ -203,6 +204,16 @@
return status;
}
+ status = ipoib_add_adapter(p_adapter);
+ if( status != IB_SUCCESS )
+ {
+ cl_obj_destroy( &p_adapter->obj ); // ??? is this the
correct way to stop
+ IPOIB_TRACE_EXIT( IPOIB_DBG_ERROR,
+ ("adapter_init returned %s.\n",
+ p_adapter->p_ifc->get_err_str( status )) );
+ return status;
+ }
+
*pp_adapter = p_adapter;
IPOIB_EXIT( IPOIB_DBG_INIT );
@@ -231,6 +242,8 @@
{
IPOIB_ENTER( IPOIB_DBG_INIT );
+ ipoib_remove_adapter(p_adapter);
+
CL_ASSERT( p_adapter );
/*
Index: kernel/ipoib_debug.h
===================================================================
--- kernel/ipoib_debug.h (revision 148)
+++ kernel/ipoib_debug.h (working copy)
@@ -59,7 +59,9 @@
#define IPOIB_DBG_MCAST (1 << 7)
#define IPOIB_DBG_ALLOC (1 << 8)
#define IPOIB_DBG_OID (1 << 9)
+#define IPOIB_DBG_IOCTL (1 << 10)
+
#define IPOIB_DBG_FUNC (1 << 28) /* For function entry/exit */
#define IPOIB_DBG_INFO (1 << 29) /* For verbose information */
#define IPOIB_DBG_WARN (1 << 30) /* For warnings. */
Index: kernel/ipoib_driver.c
===================================================================
--- kernel/ipoib_driver.c (revision 148)
+++ kernel/ipoib_driver.c (working copy)
@@ -29,7 +29,8 @@
* $Id$
*/
-
+#include <iba/ib_types.h>
+#include "ip_addresses_shared.h"
#include "ipoib_driver.h"
#include "ipoib_debug.h"
#include "ipoib_port.h"
@@ -37,6 +38,7 @@
#include <complib/cl_init.h>
#include <initguid.h>
#include <iba/ipoib_ifc.h>
+#include <ip_addresses.h>
/* Default parameters values for optional parameters */
@@ -221,6 +223,15 @@
IN ipoib_adapter_t* const
p_adapter );
+
+VOID DriverUnload (
+ IN PDRIVER_OBJECT pDriverObject
+ )
+{
+ IPOIB_ENTER( IPOIB_DBG_INIT );
+ pDriverObject = NULL;
+ ipoib_driver_unload();
+}
//! Standard Windows Device Driver Entry Point
/*! DriverEntry is the first routine called after a driver is loaded,
and
is responsible for initializing the driver. On W2k this occurs when
the PnP
@@ -244,6 +255,8 @@
IPOIB_ENTER( IPOIB_DBG_INIT );
+ p_drv_obj->DriverUnload = DriverUnload;
+
#ifdef _DEBUG_
PAGED_CODE();
#endif
@@ -263,7 +276,6 @@
InitializeListHead( &g_ipoib.adapter_list );
NdisMInitializeWrapper( &ndis_handle, p_drv_obj,
p_registry_path, NULL );
-
memset(&characteristics, 0, sizeof(characteristics));
characteristics.MajorNdisVersion =
MAJOR_NDIS_VERSION;
characteristics.MinorNdisVersion =
MINOR_NDIS_VERSION;
@@ -286,16 +298,30 @@
ndis_handle, &characteristics, sizeof(characteristics)
);
if( status != NDIS_STATUS_SUCCESS )
{
+
IPOIB_TRACE( IPOIB_DBG_ERROR,
("NdisMRegisterMiniport failed with status of
%d\n", status) );
NdisTerminateWrapper( ndis_handle, NULL );
- CL_DEINIT;
+ return status;
+ }
+
+
+ status = ipoib_driver_up(ndis_handle);
+ if( status != NDIS_STATUS_SUCCESS )
+ {
+ IPOIB_TRACE( IPOIB_DBG_ERROR,
+ ("ipoib_driver_up failed with status of %d\n",
status) );
+ //??? should we "undo the" NdisMRegisterMiniport ?
+ NdisTerminateWrapper( ndis_handle, NULL );
+ return status;
}
else
{
NdisMRegisterUnloadHandler( ndis_handle, ipoib_unload );
}
+ NdisMRegisterUnloadHandler(ndis_handle, DriverUnload);
+
IPOIB_EXIT( IPOIB_DBG_INIT );
return status;
}
Index: kernel/ipoib_endpoint.c
===================================================================
--- kernel/ipoib_endpoint.c (revision 148)
+++ kernel/ipoib_endpoint.c (working copy)
@@ -30,7 +30,8 @@
*/
-
+#include <iba/ib_types.h>
+#include "ip_addresses_shared.h"
#include "ipoib_endpoint.h"
#include "ipoib_port.h"
#include "ipoib_debug.h"
Index: kernel/ipoib_port.c
===================================================================
--- kernel/ipoib_port.c (revision 148)
+++ kernel/ipoib_port.c (working copy)
@@ -30,7 +30,8 @@
*/
-
+#include <iba/ib_types.h>
+#include "ip_addresses_shared.h"
#include "ipoib_port.h"
#include "ipoib_adapter.h"
#include "ipoib_debug.h"
@@ -3856,8 +3857,39 @@
IPOIB_EXIT( IPOIB_DBG_ENDPT );
}
+NDIS_STATUS
+gid_from_mac(
+ IN ipoib_port_t* const
p_port,
+ IN const mac_addr_t
mac,
+ OUT ib_gid_t*
p_dest_gid )
+{
+ ipoib_endpt_t* p_endpt;
+ cl_map_item_t *p_item;
+ uint64_t key = 0;
+ cl_memcpy( &key, &mac, sizeof(mac_addr_t) );
-static inline NDIS_STATUS
+ IPOIB_ENTER( IPOIB_DBG_ENDPT );
+
+ cl_obj_lock( &p_port->obj );
+
+ p_item = cl_qmap_get( &p_port->endpt_mgr.mac_endpts, key );
+ if( p_item == cl_qmap_end( &p_port->endpt_mgr.mac_endpts ) )
+ {
+ cl_obj_unlock( &p_port->obj );
+ IPOIB_TRACE_EXIT( IPOIB_DBG_ENDPT, ("Failed endpoint
lookup.\n") );
+ return NDIS_STATUS_NO_ROUTE_TO_DESTINATION;
+ }
+
+ p_endpt = PARENT_STRUCT( p_item, ipoib_endpt_t, mac_item );
+ *p_dest_gid = p_endpt->dgid;
+
+ cl_obj_unlock( &p_port->obj );
+
+ IPOIB_EXIT( IPOIB_DBG_ENDPT );
+ return NDIS_STATUS_SUCCESS;
+}
+
+NDIS_STATUS
__endpt_mgr_ref(
IN ipoib_port_t* const
p_port,
IN const mac_addr_t
mac,
@@ -3872,6 +3904,7 @@
IPOIB_ENTER( IPOIB_DBG_ENDPT );
key = 0;
+ *pp_endpt = NULL;
cl_memcpy( &key, &mac, sizeof(mac_addr_t) );
cl_obj_lock( &p_port->obj );
Index: kernel/ipoib_port.h
===================================================================
--- kernel/ipoib_port.h (revision 148)
+++ kernel/ipoib_port.h (working copy)
@@ -584,5 +584,10 @@
ipoib_port_resume(
IN ipoib_port_t* const
p_port );
+NDIS_STATUS
+gid_from_mac(
+ IN ipoib_port_t* const
p_port,
+ IN const mac_addr_t
mac,
+ OUT ib_gid_t*
p_dest_gid );
#endif /* _IPOIB_PORT_H_ */
Index: kernel/SOURCES
===================================================================
--- kernel/SOURCES (revision 148)
+++ kernel/SOURCES (working copy)
@@ -6,7 +6,8 @@
ipoib_driver.c \
ipoib_adapter.c \
ipoib_endpoint.c \
- ipoib_port.c
+ ipoib_port.c \
+ ip_Addresses.c
INCLUDES=..;..\..\..\inc;..\..\..\inc\kernel;
>-----Original Message-----
>From: Fab Tillier [mailto:ftillier at silverstorm.com]
>Sent: Friday, October 21, 2005 9:33 PM
>To: 'Tzachi Dar'; openib-windows at openib.org
>Cc: Yossi Leybovich; Gilad Shainer
>Subject: RE: Anything new about the IPOIB arp check-in?
>
>> From: Tzachi Dar [mailto:tzachid at mellanox.co.il]
>> Sent: Friday, October 21, 2005 4:50 AM
>>
>> Hi Fab,
>>
>> This check in will help the SDP in the first place, but later Winsock
>direct
>> and UDAPL can also enjoy it. This will improve the time needed for
>Winsock
>> direct clients to create connections (for example).
>
>Right, I agree that it's a useful feature. It's just that I'm swamped
with
>other work and as such it isn't immediately applicable to OpenIB.
>
>> Please note that we have been using this code for a long time and it
is
>quite
>> stable, so you can use the patch that I have sent you or I can make a
new
>one
>> and send you.
>
>Would you mind sending me a patch against the latest code? If I give
you
>feedback, would you be able to incorporate that feedback and resend an
>updated
>patch?
>
>> You will have the freedom to apply your changes when ever you
>> have the free time for that.
>
>I'd like to get this in sooner rather than later, it's just a matter of
>scheduling it.
>
>Thanks,
>
>- Fab
-------------- next part --------------
A non-text attachment was scrubbed...
Name: ipoib.diff
Type: application/octet-stream
Size: 29141 bytes
Desc: ipoib.diff
URL: <http://lists.openfabrics.org/pipermail/ofw/attachments/20051108/d82e1eed/attachment.obj>
More information about the ofw
mailing list