win-pvdrivers

diff xennet/xennet_rx.c @ 1023:1ce315b193d1

Change all NT_ASSERT to XN_ASSERT
author James Harper <james.harper@bendigoit.com.au>
date Tue Feb 19 15:12:35 2013 +1100 (2013-02-19)
parents 9b6213b6be25
children cb767700f91c
line diff
     1.1 --- a/xennet/xennet_rx.c	Tue Feb 19 15:11:49 2013 +1100
     1.2 +++ b/xennet/xennet_rx.c	Tue Feb 19 15:12:35 2013 +1100
     1.3 @@ -131,7 +131,7 @@ get_hb_from_freelist(struct xennet_info 
     1.4  static __inline VOID
     1.5  put_hb_on_freelist(struct xennet_info *xi, shared_buffer_t *hb)
     1.6  {
     1.7 -  NT_ASSERT(xi);
     1.8 +  XN_ASSERT(xi);
     1.9    hb->mdl->ByteCount = sizeof(shared_buffer_t) + MAX_ETH_HEADER_LENGTH + MAX_LOOKAHEAD_LENGTH;
    1.10    hb->mdl->Next = NULL;
    1.11    hb->next = NULL;
    1.12 @@ -172,12 +172,12 @@ XenNet_FillRing(struct xennet_info *xi)
    1.13  
    1.14      /* Give to netback */
    1.15      id = (USHORT)((req_prod + i) & (NET_RX_RING_SIZE - 1));
    1.16 -    NT_ASSERT(xi->rx_ring_pbs[id] == NULL);
    1.17 +    XN_ASSERT(xi->rx_ring_pbs[id] == NULL);
    1.18      xi->rx_ring_pbs[id] = page_buf;
    1.19      req = RING_GET_REQUEST(&xi->rx_ring, req_prod + i);
    1.20      req->id = id;
    1.21      req->gref = page_buf->gref;
    1.22 -    NT_ASSERT(req->gref != INVALID_GRANT_REF);
    1.23 +    XN_ASSERT(req->gref != INVALID_GRANT_REF);
    1.24    }
    1.25    KeMemoryBarrier();
    1.26    xi->rx_ring.req_prod_pvt = req_prod + i;
    1.27 @@ -239,7 +239,7 @@ XenNet_SumPacketData(
    1.28      FUNCTION_MSG("NdisGetFirstBufferFromPacketSafe failed, buffer == NULL\n");
    1.29      return FALSE;
    1.30    }
    1.31 -  ASSERT(mdl);
    1.32 +  XN_ASSERT(mdl);
    1.33  
    1.34    ip4_length = GET_NET_PUSHORT(&buffer[XN_HDR_SIZE + 2]);
    1.35    data_length = ip4_length + XN_HDR_SIZE;
    1.36 @@ -251,11 +251,11 @@ XenNet_SumPacketData(
    1.37  
    1.38    switch (pi->ip_proto) {
    1.39    case 6:
    1.40 -    ASSERT(buffer_length >= (USHORT)(XN_HDR_SIZE + pi->ip4_header_length + 17));
    1.41 +    XN_ASSERT(buffer_length >= (USHORT)(XN_HDR_SIZE + pi->ip4_header_length + 17));
    1.42      csum_ptr = (USHORT *)&buffer[XN_HDR_SIZE + pi->ip4_header_length + 16];
    1.43      break;
    1.44    case 17:
    1.45 -    ASSERT(buffer_length >= (USHORT)(XN_HDR_SIZE + pi->ip4_header_length + 7));
    1.46 +    XN_ASSERT(buffer_length >= (USHORT)(XN_HDR_SIZE + pi->ip4_header_length + 7));
    1.47      csum_ptr = (USHORT *)&buffer[XN_HDR_SIZE + pi->ip4_header_length + 6];
    1.48      break;
    1.49    default:
    1.50 @@ -288,7 +288,7 @@ XenNet_SumPacketData(
    1.51      }
    1.52      if (csum_span) {
    1.53        /* the other half of the next bit */
    1.54 -      ASSERT(buffer_offset == 0);
    1.55 +      XN_ASSERT(buffer_offset == 0);
    1.56        csum += (USHORT)buffer[buffer_offset];
    1.57        csum_span = FALSE;
    1.58        i += 1;
    1.59 @@ -311,7 +311,7 @@ XenNet_SumPacketData(
    1.60          return FALSE; // should never happen
    1.61        }
    1.62        NdisQueryBufferSafe(mdl, &buffer, &buffer_length, NormalPagePriority);
    1.63 -      ASSERT(buffer_length);
    1.64 +      XN_ASSERT(buffer_length);
    1.65        buffer_offset = 0;
    1.66      }
    1.67    }
    1.68 @@ -393,7 +393,7 @@ XenNet_MakePacket(struct xennet_info *xi
    1.69      #endif
    1.70      ref_pb(xi, pi->first_pb);
    1.71    } else {
    1.72 -    NT_ASSERT(ndis_os_minor_version >= 1);
    1.73 +    XN_ASSERT(ndis_os_minor_version >= 1);
    1.74      header_buf = get_hb_from_freelist(xi);
    1.75      if (!header_buf) {
    1.76        FUNCTION_MSG("No free header buffers\n");
    1.77 @@ -414,7 +414,7 @@ XenNet_MakePacket(struct xennet_info *xi
    1.78      /* make sure only the header is in the first buffer (or the entire packet, but that is done in the above case) */
    1.79      XenNet_BuildHeader(pi, header_va, MAX_ETH_HEADER_LENGTH + pi->ip4_header_length + pi->tcp_header_length);
    1.80      header_extra = pi->header_length - (MAX_ETH_HEADER_LENGTH + pi->ip4_header_length + pi->tcp_header_length);
    1.81 -    NT_ASSERT(pi->header_length <= MAX_ETH_HEADER_LENGTH + MAX_LOOKAHEAD_LENGTH);
    1.82 +    XN_ASSERT(pi->header_length <= MAX_ETH_HEADER_LENGTH + MAX_LOOKAHEAD_LENGTH);
    1.83      header_buf->mdl->ByteCount = pi->header_length;
    1.84      mdl_head = mdl_tail = curr_mdl = header_buf->mdl;
    1.85      #if NTDDI_VERSION < NTDDI_VISTA
    1.86 @@ -442,10 +442,10 @@ XenNet_MakePacket(struct xennet_info *xi
    1.87        pi->tcp_remaining = (USHORT)(pi->tcp_remaining - tcp_length);
    1.88        /* part of the packet is already present in the header buffer for lookahead */
    1.89        out_remaining = tcp_length - header_extra;
    1.90 -      NT_ASSERT((LONG)out_remaining >= 0);
    1.91 +      XN_ASSERT((LONG)out_remaining >= 0);
    1.92      } else {
    1.93        out_remaining = pi->total_length - pi->header_length;
    1.94 -      NT_ASSERT((LONG)out_remaining >= 0);
    1.95 +      XN_ASSERT((LONG)out_remaining >= 0);
    1.96      }
    1.97  
    1.98      while (out_remaining != 0) {
    1.99 @@ -466,7 +466,7 @@ XenNet_MakePacket(struct xennet_info *xi
   1.100        in_buffer_length = MmGetMdlByteCount(pi->curr_mdl);
   1.101        out_length = min(out_remaining, in_buffer_length - pi->curr_mdl_offset);
   1.102        curr_mdl = IoAllocateMdl((PUCHAR)MmGetMdlVirtualAddress(pi->curr_mdl) + pi->curr_mdl_offset, out_length, FALSE, FALSE, NULL);
   1.103 -      NT_ASSERT(curr_mdl);
   1.104 +      XN_ASSERT(curr_mdl);
   1.105        IoBuildPartialMdl(pi->curr_mdl, curr_mdl, (PUCHAR)MmGetMdlVirtualAddress(pi->curr_mdl) + pi->curr_mdl_offset, out_length);
   1.106        mdl_tail->Next = curr_mdl;
   1.107        mdl_tail = curr_mdl;
   1.108 @@ -502,7 +502,7 @@ XenNet_MakePacket(struct xennet_info *xi
   1.109      #if NTDDI_VERSION < NTDDI_VISTA
   1.110      csum_info = (PNDIS_TCP_IP_CHECKSUM_PACKET_INFO)&NDIS_PER_PACKET_INFO_FROM_PACKET(
   1.111        packet, TcpIpChecksumPacketInfo);
   1.112 -    ASSERT(csum_info->Value == 0);
   1.113 +    XN_ASSERT(csum_info->Value == 0);
   1.114      if (pi->csum_blank || pi->data_validated) {
   1.115        BOOLEAN checksum_offload = FALSE;
   1.116        /* we know this is IPv4, and we know Linux always validates the IPv4 checksum for us */
   1.117 @@ -724,7 +724,7 @@ XenNet_ReturnPacket(NDIS_HANDLE adapter_
   1.118    
   1.119    while (buffer) {
   1.120      shared_buffer_t *next_buf;
   1.121 -    ASSERT(page_buf);
   1.122 +    XN_ASSERT(page_buf);
   1.123      next_buf = page_buf->next;
   1.124      if (!page_buf->virtual) {
   1.125        /* this is a hb not a pb because virtual is NULL (virtual is just the memory after the hb */
   1.126 @@ -757,7 +757,7 @@ XenNet_ReturnNetBufferLists(NDIS_HANDLE 
   1.127  
   1.128    //KdPrint((__DRIVER_NAME "     page_buf = %p\n", page_buf));
   1.129  
   1.130 -  NT_ASSERT(xi);
   1.131 +  XN_ASSERT(xi);
   1.132    while (curr_nbl)
   1.133    {
   1.134      PNET_BUFFER_LIST next_nbl;
   1.135 @@ -779,7 +779,7 @@ XenNet_ReturnNetBufferLists(NDIS_HANDLE 
   1.136          shared_buffer_t *next_buf;
   1.137          PMDL next_mdl;
   1.138          
   1.139 -        NT_ASSERT(page_buf); /* make sure that there is a pb to match this mdl */
   1.140 +        XN_ASSERT(page_buf); /* make sure that there is a pb to match this mdl */
   1.141          next_mdl = curr_mdl->Next;
   1.142          next_buf = page_buf->next;
   1.143          if (!page_buf->virtual)
   1.144 @@ -892,7 +892,7 @@ XenNet_RxBufferCheck(struct xennet_info 
   1.145      for (cons = xi->rx_ring.rsp_cons; cons != prod && packet_count < MAXIMUM_PACKETS_PER_INTERRUPT && packet_data < MAXIMUM_DATA_PER_INTERRUPT; cons++) {
   1.146        id = (USHORT)(cons & (NET_RX_RING_SIZE - 1));
   1.147        page_buf = xi->rx_ring_pbs[id];
   1.148 -      NT_ASSERT(page_buf);
   1.149 +      XN_ASSERT(page_buf);
   1.150        xi->rx_ring_pbs[id] = NULL;
   1.151        xi->rx_id_free++;
   1.152        memcpy(&page_buf->rsp, RING_GET_RESPONSE(&xi->rx_ring, cons), max(sizeof(struct netif_rx_response), sizeof(struct netif_extra_info)));
   1.153 @@ -900,7 +900,7 @@ XenNet_RxBufferCheck(struct xennet_info 
   1.154          if (page_buf->rsp.status <= 0 || page_buf->rsp.offset + page_buf->rsp.status > PAGE_SIZE) {
   1.155            KdPrint((__DRIVER_NAME "     Error: rsp offset %d, size %d\n",
   1.156              page_buf->rsp.offset, page_buf->rsp.status));
   1.157 -          NT_ASSERT(!extra_info_flag);
   1.158 +          XN_ASSERT(!extra_info_flag);
   1.159            put_pb_on_freelist(xi, page_buf);
   1.160            continue;
   1.161          }
   1.162 @@ -998,7 +998,7 @@ XenNet_RxBufferCheck(struct xennet_info 
   1.163          switch (ei->u.gso.type) {
   1.164          case XEN_NETIF_GSO_TYPE_TCPV4:
   1.165            pi->mss = ei->u.gso.size;
   1.166 -          // TODO - put this assertion somewhere NT_ASSERT(header_len + pi->mss <= PAGE_SIZE); // this limits MTU to PAGE_SIZE - XN_HEADER_LEN
   1.167 +          // TODO - put this assertion somewhere XN_ASSERT(header_len + pi->mss <= PAGE_SIZE); // this limits MTU to PAGE_SIZE - XN_HEADER_LEN
   1.168            break;
   1.169          default:
   1.170            KdPrint((__DRIVER_NAME "     Unknown GSO type (%d) detected\n", ei->u.gso.type));
   1.171 @@ -1011,7 +1011,7 @@ XenNet_RxBufferCheck(struct xennet_info 
   1.172        }
   1.173        put_pb_on_freelist(xi, page_buf);
   1.174      } else {
   1.175 -      NT_ASSERT(!page_buf->rsp.offset);
   1.176 +      XN_ASSERT(!page_buf->rsp.offset);
   1.177        if (!more_data_flag) { // handling the packet's 1st buffer
   1.178          if (page_buf->rsp.flags & NETRXF_csum_blank)
   1.179            pi->csum_blank = TRUE;
   1.180 @@ -1022,11 +1022,11 @@ XenNet_RxBufferCheck(struct xennet_info 
   1.181        mdl->ByteCount = page_buf->rsp.status; //NdisAdjustBufferLength(mdl, page_buf->rsp.status);
   1.182        //KdPrint((__DRIVER_NAME "     buffer = %p, pb = %p\n", buffer, page_buf));
   1.183        if (pi->first_pb) {
   1.184 -        NT_ASSERT(pi->curr_pb);
   1.185 +        XN_ASSERT(pi->curr_pb);
   1.186          //KdPrint((__DRIVER_NAME "     additional buffer\n"));
   1.187          pi->curr_pb->next = page_buf;
   1.188          pi->curr_pb = page_buf;
   1.189 -        NT_ASSERT(pi->curr_mdl);
   1.190 +        XN_ASSERT(pi->curr_mdl);
   1.191          pi->curr_mdl->Next = mdl;
   1.192          pi->curr_mdl = mdl;
   1.193        } else {
   1.194 @@ -1050,7 +1050,7 @@ XenNet_RxBufferCheck(struct xennet_info 
   1.195  
   1.196      page_buf = next_buf;
   1.197    }
   1.198 -  NT_ASSERT(!more_data_flag && !extra_info_flag);
   1.199 +  XN_ASSERT(!more_data_flag && !extra_info_flag);
   1.200  
   1.201    #if NTDDI_VERSION < NTDDI_VISTA
   1.202    packet_count = 0;
   1.203 @@ -1062,7 +1062,7 @@ XenNet_RxBufferCheck(struct xennet_info 
   1.204      NDIS_STATUS status;
   1.205  
   1.206      packet = rc.first_packet;
   1.207 -    ASSERT(PACKET_FIRST_PB(packet));
   1.208 +    XN_ASSERT(PACKET_FIRST_PB(packet));
   1.209      rc.first_packet = PACKET_NEXT_PACKET(packet);
   1.210      status = NDIS_GET_PACKET_STATUS(packet);
   1.211      if (status == NDIS_STATUS_RESOURCES) {