win-pvdrivers

changeset 414:7f1dd7920c57

Allow NetworkAddress registry entry to override the MAC address for NLB.
Fixed a few problems in shutdown.
Add SurpriseRemovalOkay to finally get rid of that 'Safely remove hardware' icon.
author James Harper <james.harper@bendigoit.com.au>
date Mon Aug 18 13:20:49 2008 +1000 (2008-08-18)
parents dbddf9b4c935
children 62dc0a1661e3
files xennet/xennet.c xennet/xennet.h xennet/xennet.inx xennet/xennet_common.c xennet/xennet_oid.c xennet/xennet_rx.c
line diff
     1.1 --- a/xennet/xennet.c	Tue Aug 12 22:49:49 2008 +1000
     1.2 +++ b/xennet/xennet.c	Mon Aug 18 13:20:49 2008 +1000
     1.3 @@ -207,7 +207,11 @@ XenNet_ConnectBackend(struct xennet_info
     1.4            }
     1.5            s = e + 1;
     1.6          }
     1.7 -        memcpy(xi->curr_mac_addr, xi->perm_mac_addr, ETH_ALEN);
     1.8 +        if (!(xi->curr_mac_addr[0] & 0x02))
     1.9 +        {
    1.10 +          /* only copy if curr_mac_addr is not a LUA */
    1.11 +          memcpy(xi->curr_mac_addr, xi->perm_mac_addr, ETH_ALEN);
    1.12 +        }
    1.13        }
    1.14        break;
    1.15      case XEN_INIT_TYPE_VECTORS:
    1.16 @@ -303,6 +307,8 @@ XenNet_Init(
    1.17    PCHAR setting, value;
    1.18    ULONG length;
    1.19    CHAR buf[128];
    1.20 +  PVOID network_address;
    1.21 +  UINT network_address_length;
    1.22    
    1.23    UNREFERENCED_PARAMETER(OpenErrorStatus);
    1.24  
    1.25 @@ -340,7 +346,7 @@ XenNet_Init(
    1.26    xi->rx_min_target = RX_DFL_MIN_TARGET;
    1.27    xi->rx_max_target = RX_MAX_TARGET;
    1.28    NdisMSetAttributesEx(xi->adapter_handle, (NDIS_HANDLE) xi,
    1.29 -    0, NDIS_ATTRIBUTE_DESERIALIZE, // | NDIS_ATTRIBUTE_BUS_MASTER),
    1.30 +    0, NDIS_ATTRIBUTE_DESERIALIZE|NDIS_ATTRIBUTE_SURPRISE_REMOVE_OK,
    1.31      NdisInterfaceInternal);
    1.32  
    1.33    nrl_length = 0;
    1.34 @@ -526,6 +532,20 @@ XenNet_Init(
    1.35      xi->config_mtu = config_param->ParameterData.IntegerData;
    1.36    }
    1.37  
    1.38 +  NdisReadNetworkAddress(&status, &network_address, &network_address_length, config_handle);
    1.39 +  if (!NT_SUCCESS(status) || network_address_length != ETH_ALEN || !(((PUCHAR)network_address)[0] & 0x02))
    1.40 +  {
    1.41 +    KdPrint(("Could not read NetworkAddress value (%08x)\n", status));
    1.42 +    memset(xi->curr_mac_addr, 0, ETH_ALEN);
    1.43 +  }
    1.44 +  else
    1.45 +  {
    1.46 +    memcpy(xi->curr_mac_addr, network_address, ETH_ALEN);
    1.47 +    KdPrint(("     Set MAC address from registry to %02X:%02X:%02X:%02X:%02X:%02X\n",
    1.48 +      xi->curr_mac_addr[0], xi->curr_mac_addr[1], xi->curr_mac_addr[2], 
    1.49 +      xi->curr_mac_addr[3], xi->curr_mac_addr[4], xi->curr_mac_addr[5]));
    1.50 +  }
    1.51 +
    1.52    xi->config_max_pkt_size = max(xi->config_mtu + XN_HDR_SIZE, xi->config_gso + XN_HDR_SIZE);
    1.53    
    1.54    NdisCloseConfiguration(config_handle);
    1.55 @@ -620,9 +640,7 @@ XenNet_Halt(
    1.56    )
    1.57  {
    1.58    struct xennet_info *xi = MiniportAdapterContext;
    1.59 -//  CHAR TmpPath[MAX_XENBUS_STR_LEN];
    1.60 -//  PVOID if_cxt = xi->XenInterface.InterfaceHeader.Context;
    1.61 -//  LARGE_INTEGER timeout;
    1.62 +  BOOLEAN timer_cancelled;
    1.63  
    1.64    FUNCTION_ENTER();
    1.65    KdPrint((__DRIVER_NAME "     IRQL = %d\n", KeGetCurrentIrql()));
    1.66 @@ -637,6 +655,8 @@ XenNet_Halt(
    1.67  
    1.68    // TODO: remove event channel xenbus entry (how?)
    1.69  
    1.70 +  NdisMCancelTimer(&xi->resume_timer, &timer_cancelled);
    1.71 +
    1.72    XenNet_TxShutdown(xi);
    1.73    XenNet_RxShutdown(xi);
    1.74  
     2.1 --- a/xennet/xennet.h	Tue Aug 12 22:49:49 2008 +1000
     2.2 +++ b/xennet/xennet.h	Mon Aug 18 13:20:49 2008 +1000
     2.3 @@ -69,7 +69,6 @@ Foundation, Inc., 51 Franklin Street, Fi
     2.4  
     2.5  #define ETH_ALEN 6
     2.6  
     2.7 -
     2.8  #define __NET_USHORT_BYTE_0(x) ((USHORT)(x & 0xFF))
     2.9  #define __NET_USHORT_BYTE_1(x) ((USHORT)((PUCHAR)&x)[1] & 0xFF)
    2.10  
    2.11 @@ -79,6 +78,11 @@ Foundation, Inc., 51 Franklin Street, Fi
    2.12  #define GET_NET_ULONG(x) ((GET_NET_USHORT(x) << 16) | GET_NET_USHORT(((PUCHAR)&x)[2]))
    2.13  #define SET_NET_ULONG(y, x) *((ULONG *)&(y)) = ((GET_NET_USHORT(x) << 16) | GET_NET_USHORT(((PUCHAR)&x)[2]))
    2.14  
    2.15 +#define SUPPORTED_PACKET_FILTERS (\
    2.16 +  NDIS_PACKET_TYPE_DIRECTED | \
    2.17 +  NDIS_PACKET_TYPE_MULTICAST | \
    2.18 +  NDIS_PACKET_TYPE_BROADCAST | \
    2.19 +  NDIS_PACKET_TYPE_ALL_MULTICAST)
    2.20  
    2.21  /* couldn't get regular xen ring macros to work...*/
    2.22  #define __NET_RING_SIZE(type, _sz) \
     3.1 --- a/xennet/xennet.inx	Tue Aug 12 22:49:49 2008 +1000
     3.2 +++ b/xennet/xennet.inx	Mon Aug 18 13:20:49 2008 +1000
     3.3 @@ -61,6 +61,13 @@ HKR, Ndi\Params\ScatterGather, type, , "
     3.4  HKR, Ndi\Params\ScatterGather\enum, 0, , "Disabled"
     3.5  HKR, Ndi\Params\ScatterGather\enum, 1, , "Enabled"
     3.6  
     3.7 +HKR, Ndi\Params\NetworkAddress, ParamDesc, , "Locally Administered Address"
     3.8 +HKR, Ndi\Params\NetworkAddress, Type, , "edit"
     3.9 +HKR, Ndi\Params\NetworkAddress, LimitText, , "12"
    3.10 +HKR, Ndi\Params\NetworkAddress, UpperCase, , "1"
    3.11 +HKR, Ndi\Params\NetworkAddress, Default, , ""
    3.12 +HKR, Ndi\Params\NetworkAddress, Optional, , "1"
    3.13 +
    3.14  [XenNet.CopyFiles]
    3.15  xennet.sys
    3.16  xenconfig.sys
     4.1 --- a/xennet/xennet_common.c	Tue Aug 12 22:49:49 2008 +1000
     4.2 +++ b/xennet/xennet_common.c	Mon Aug 18 13:20:49 2008 +1000
     4.3 @@ -213,7 +213,7 @@ XenFreelist_GetPage(freelist_t *fl)
     4.4      pfn = *MmGetMdlPfnArray(mdl);
     4.5      *(grant_ref_t *)(((UCHAR *)mdl) + MmSizeOfMdl(0, PAGE_SIZE)) = fl->xi->vectors.GntTbl_GrantAccess(
     4.6        fl->xi->vectors.context, 0,
     4.7 -      (uint32_t)pfn, FALSE, 0);
     4.8 +      (uint32_t)pfn, FALSE, INVALID_GRANT_REF);
     4.9      /* we really should check if our grant was successful... */
    4.10    }
    4.11    else
    4.12 @@ -259,7 +259,7 @@ XenFreelist_ReGrantMdl(freelist_t *fl, P
    4.13    pfn = *MmGetMdlPfnArray(mdl);
    4.14    *(grant_ref_t *)(((UCHAR *)mdl) + MmSizeOfMdl(0, PAGE_SIZE)) = fl->xi->vectors.GntTbl_GrantAccess(
    4.15      fl->xi->vectors.context, 0,
    4.16 -    (uint32_t)pfn, FALSE, 0);
    4.17 +    (uint32_t)pfn, FALSE, INVALID_GRANT_REF);
    4.18  }
    4.19  
    4.20  /* re-grant all the pages, as the grant table was wiped on resume */
     5.1 --- a/xennet/xennet_oid.c	Tue Aug 12 22:49:49 2008 +1000
     5.2 +++ b/xennet/xennet_oid.c	Mon Aug 18 13:20:49 2008 +1000
     5.3 @@ -60,6 +60,8 @@ NDIS_OID supported_oids[] =
     5.4    OID_TCP_TASK_OFFLOAD,
     5.5  };
     5.6  
     5.7 +
     5.8 +
     5.9  /* return 4 or 8 depending on size of buffer */
    5.10  #define HANDLE_STAT_RETURN \
    5.11    {if (InformationBufferLength == 4) { \
    5.12 @@ -458,6 +460,30 @@ XenNet_SetInformation(
    5.13        break;
    5.14      case OID_GEN_CURRENT_PACKET_FILTER:
    5.15        KdPrint(("Set OID_GEN_CURRENT_PACKET_FILTER\n"));
    5.16 +      if (*(ULONG *)data & NDIS_PACKET_TYPE_DIRECTED)
    5.17 +        KdPrint(("  NDIS_PACKET_TYPE_DIRECTED\n"));
    5.18 +      if (*(ULONG *)data & NDIS_PACKET_TYPE_MULTICAST)
    5.19 +        KdPrint(("  NDIS_PACKET_TYPE_MULTICAST\n"));
    5.20 +      if (*(ULONG *)data & NDIS_PACKET_TYPE_ALL_MULTICAST)
    5.21 +        KdPrint(("  NDIS_PACKET_TYPE_ALL_MULTICAST\n"));
    5.22 +      if (*(ULONG *)data & NDIS_PACKET_TYPE_BROADCAST)
    5.23 +        KdPrint(("  NDIS_PACKET_TYPE_BROADCAST\n"));
    5.24 +      if (*(ULONG *)data & NDIS_PACKET_TYPE_PROMISCUOUS)
    5.25 +        KdPrint(("  NDIS_PACKET_TYPE_PROMISCUOUS (not supported)\n"));
    5.26 +      if (*(ULONG *)data & NDIS_PACKET_TYPE_ALL_FUNCTIONAL)
    5.27 +        KdPrint(("  NDIS_PACKET_TYPE_ALL_FUNCTIONAL (not supported)\n"));
    5.28 +      if (*(ULONG *)data & NDIS_PACKET_TYPE_ALL_LOCAL)
    5.29 +        KdPrint(("  NDIS_PACKET_TYPE_ALL_LOCAL (not supported)\n"));
    5.30 +      if (*(ULONG *)data & NDIS_PACKET_TYPE_FUNCTIONAL)
    5.31 +        KdPrint(("  NDIS_PACKET_TYPE_FUNCTIONAL (not supported)\n"));
    5.32 +      if (*(ULONG *)data & NDIS_PACKET_TYPE_GROUP)
    5.33 +        KdPrint(("  NDIS_PACKET_TYPE_GROUP (not supported)\n"));
    5.34 +      if (*(ULONG *)data & ~SUPPORTED_PACKET_FILTERS)
    5.35 +      {
    5.36 +        status = NDIS_STATUS_NOT_SUPPORTED;
    5.37 +        KdPrint(("  returning NDIS_STATUS_NOT_SUPPORTED\n"));
    5.38 +        break;
    5.39 +      }
    5.40        xi->packet_filter = *(ULONG *)data;
    5.41        status = NDIS_STATUS_SUCCESS;
    5.42        break;
    5.43 @@ -520,8 +546,10 @@ XenNet_SetInformation(
    5.44        KdPrint(("Unsupported set OID_802_3_CURRENT_ADDRESS\n"));
    5.45        break;
    5.46      case OID_802_3_MULTICAST_LIST:
    5.47 -      status = NDIS_STATUS_NOT_SUPPORTED;
    5.48 -      KdPrint(("Unsupported set OID_802_3_MULTICAST_LIST\n"));
    5.49 +      KdPrint(("     Set OID_802_3_MULTICAST_LIST\n"));
    5.50 +      KdPrint(("       Length = %d\n", InformationBufferLength));
    5.51 +      KdPrint(("       Entries = %d\n", InformationBufferLength / 6));
    5.52 +      status = NDIS_STATUS_SUCCESS;
    5.53        break;
    5.54      case OID_802_3_MAXIMUM_LIST_SIZE:
    5.55        status = NDIS_STATUS_NOT_SUPPORTED;
     6.1 --- a/xennet/xennet_rx.c	Tue Aug 12 22:49:49 2008 +1000
     6.2 +++ b/xennet/xennet_rx.c	Mon Aug 18 13:20:49 2008 +1000
     6.3 @@ -520,13 +520,11 @@ XenNet_RxBufferFree(struct xennet_info *
     6.4  
     6.5    for (i = 0; i < NET_RX_RING_SIZE; i++)
     6.6    {
     6.7 -    KdPrint((__DRIVER_NAME "     Ring slot %d = %p\n", i, xi->rx_mdls[i]));
     6.8      if (!xi->rx_mdls[i])
     6.9        continue;
    6.10  
    6.11      mdl = xi->rx_mdls[i];
    6.12      NdisAdjustBufferLength(mdl, PAGE_SIZE);
    6.13 -    KdPrint((__DRIVER_NAME "     Calling PutPage - page_free = %d\n", xi->rx_freelist.page_free));
    6.14      XenFreelist_PutPage(&xi->rx_freelist, mdl);
    6.15    }
    6.16  }