win-pvdrivers
changeset 1105:ef445b2286f7
beautify
author | James Harper <james.harper@bendigoit.com.au> |
---|---|
date | Thu Sep 25 20:41:00 2014 +1000 (2014-09-25) |
parents | aa8ced6a86b0 |
children | 2d392ecdd366 |
files | xennet/xennet_rx.c |
line diff
1.1 --- a/xennet/xennet_rx.c Thu Sep 25 20:40:51 2014 +1000 1.2 +++ b/xennet/xennet_rx.c Thu Sep 25 20:41:00 2014 +1000 1.3 @@ -30,13 +30,11 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBI 1.4 #include "xennet.h" 1.5 1.6 static __inline shared_buffer_t * 1.7 -get_pb_from_freelist(struct xennet_info *xi) 1.8 -{ 1.9 +get_pb_from_freelist(struct xennet_info *xi) { 1.10 shared_buffer_t *pb; 1.11 PVOID ptr_ref; 1.12 1.13 - if (stack_pop(xi->rx_pb_stack, &ptr_ref)) 1.14 - { 1.15 + if (stack_pop(xi->rx_pb_stack, &ptr_ref)) { 1.16 pb = ptr_ref; 1.17 pb->ref_count = 1; 1.18 InterlockedDecrement(&xi->rx_pb_free); 1.19 @@ -51,22 +49,19 @@ get_pb_from_freelist(struct xennet_info 1.20 if (!pb) 1.21 return NULL; 1.22 pb->virtual = ExAllocatePoolWithTagPriority(NonPagedPool, PAGE_SIZE, XENNET_POOL_TAG, LowPoolPriority); 1.23 - if (!pb->virtual) 1.24 - { 1.25 + if (!pb->virtual) { 1.26 ExFreePoolWithTag(pb, XENNET_POOL_TAG); 1.27 return NULL; 1.28 } 1.29 pb->mdl = IoAllocateMdl(pb->virtual, PAGE_SIZE, FALSE, FALSE, NULL); 1.30 - if (!pb->mdl) 1.31 - { 1.32 + if (!pb->mdl) { 1.33 ExFreePoolWithTag(pb->virtual, XENNET_POOL_TAG); 1.34 ExFreePoolWithTag(pb, XENNET_POOL_TAG); 1.35 return NULL; 1.36 } 1.37 pb->gref = (grant_ref_t)XnGrantAccess(xi->handle, 1.38 (ULONG)(MmGetPhysicalAddress(pb->virtual).QuadPart >> PAGE_SHIFT), FALSE, INVALID_GRANT_REF, (ULONG)'XNRX'); 1.39 - if (pb->gref == INVALID_GRANT_REF) 1.40 - { 1.41 + if (pb->gref == INVALID_GRANT_REF) { 1.42 IoFreeMdl(pb->mdl); 1.43 ExFreePoolWithTag(pb->virtual, XENNET_POOL_TAG); 1.44 ExFreePoolWithTag(pb, XENNET_POOL_TAG); 1.45 @@ -78,23 +73,19 @@ get_pb_from_freelist(struct xennet_info 1.46 } 1.47 1.48 static __inline VOID 1.49 -ref_pb(struct xennet_info *xi, shared_buffer_t *pb) 1.50 -{ 1.51 +ref_pb(struct xennet_info *xi, shared_buffer_t *pb) { 1.52 UNREFERENCED_PARAMETER(xi); 1.53 InterlockedIncrement(&pb->ref_count); 1.54 } 1.55 1.56 static __inline VOID 1.57 -put_pb_on_freelist(struct xennet_info *xi, shared_buffer_t *pb) 1.58 -{ 1.59 +put_pb_on_freelist(struct xennet_info *xi, shared_buffer_t *pb) { 1.60 int ref = InterlockedDecrement(&pb->ref_count); 1.61 XN_ASSERT(ref >= 0); 1.62 - if (ref == 0) 1.63 - { 1.64 + if (ref == 0) { 1.65 //NdisAdjustBufferLength(pb->buffer, PAGE_SIZE); 1.66 //NDIS_BUFFER_LINKAGE(pb->buffer) = NULL; 1.67 - if (xi->rx_pb_free > RX_MAX_PB_FREELIST) 1.68 - { 1.69 + if (xi->rx_pb_free > RX_MAX_PB_FREELIST) { 1.70 XnEndAccess(xi->handle, pb->gref, FALSE, (ULONG)'XNRX'); 1.71 IoFreeMdl(pb->mdl); 1.72 ExFreePoolWithTag(pb->virtual, XENNET_POOL_TAG); 1.73 @@ -110,13 +101,11 @@ put_pb_on_freelist(struct xennet_info *x 1.74 } 1.75 1.76 static __inline shared_buffer_t * 1.77 -get_hb_from_freelist(struct xennet_info *xi) 1.78 -{ 1.79 +get_hb_from_freelist(struct xennet_info *xi) { 1.80 shared_buffer_t *hb; 1.81 PVOID ptr_ref; 1.82 1.83 - if (stack_pop(xi->rx_hb_stack, &ptr_ref)) 1.84 - { 1.85 + if (stack_pop(xi->rx_hb_stack, &ptr_ref)) { 1.86 hb = ptr_ref; 1.87 InterlockedDecrement(&xi->rx_hb_free); 1.88 return hb; 1.89 @@ -140,8 +129,7 @@ get_hb_from_freelist(struct xennet_info 1.90 } 1.91 1.92 static __inline VOID 1.93 -put_hb_on_freelist(struct xennet_info *xi, shared_buffer_t *hb) 1.94 -{ 1.95 +put_hb_on_freelist(struct xennet_info *xi, shared_buffer_t *hb) { 1.96 XN_ASSERT(xi); 1.97 hb->mdl->ByteCount = sizeof(shared_buffer_t) + MAX_ETH_HEADER_LENGTH + MAX_LOOKAHEAD_LENGTH; 1.98 hb->mdl->Next = NULL; 1.99 @@ -152,8 +140,7 @@ put_hb_on_freelist(struct xennet_info *x 1.100 1.101 // Called at DISPATCH_LEVEL with rx lock held 1.102 static VOID 1.103 -XenNet_FillRing(struct xennet_info *xi) 1.104 -{ 1.105 +XenNet_FillRing(struct xennet_info *xi) { 1.106 unsigned short id; 1.107 shared_buffer_t *page_buf; 1.108 ULONG i, notify; 1.109 @@ -645,8 +632,7 @@ XenNet_MakePacket(struct xennet_info *xi 1.110 } 1.111 1.112 static VOID 1.113 -XenNet_MakePackets(struct xennet_info *xi, rx_context_t *rc, packet_info_t *pi) 1.114 -{ 1.115 +XenNet_MakePackets(struct xennet_info *xi, rx_context_t *rc, packet_info_t *pi) { 1.116 UCHAR tcp_flags; 1.117 shared_buffer_t *page_buf; 1.118 1.119 @@ -772,8 +758,7 @@ XenNet_ReturnPacket(NDIS_HANDLE adapter_ 1.120 /* called at <= DISPATCH_LEVEL */ 1.121 /* it's okay for return packet to be called while resume_state != RUNNING as the packet will simply be added back to the freelist, the grants will be fixed later */ 1.122 VOID 1.123 -XenNet_ReturnNetBufferLists(NDIS_HANDLE adapter_context, PNET_BUFFER_LIST curr_nbl, ULONG return_flags) 1.124 -{ 1.125 +XenNet_ReturnNetBufferLists(NDIS_HANDLE adapter_context, PNET_BUFFER_LIST curr_nbl, ULONG return_flags) { 1.126 struct xennet_info *xi = adapter_context; 1.127 UNREFERENCED_PARAMETER(return_flags); 1.128 1.129 @@ -782,15 +767,13 @@ XenNet_ReturnNetBufferLists(NDIS_HANDLE 1.130 //KdPrint((__DRIVER_NAME " page_buf = %p\n", page_buf)); 1.131 1.132 XN_ASSERT(xi); 1.133 - while (curr_nbl) 1.134 - { 1.135 + while (curr_nbl) { 1.136 PNET_BUFFER_LIST next_nbl; 1.137 PNET_BUFFER curr_nb; 1.138 1.139 next_nbl = NET_BUFFER_LIST_NEXT_NBL(curr_nbl); 1.140 curr_nb = NET_BUFFER_LIST_FIRST_NB(curr_nbl); 1.141 - while (curr_nb) 1.142 - { 1.143 + while (curr_nb) { 1.144 PNET_BUFFER next_nb; 1.145 PMDL curr_mdl; 1.146 shared_buffer_t *page_buf; 1.147 @@ -798,24 +781,19 @@ XenNet_ReturnNetBufferLists(NDIS_HANDLE 1.148 next_nb = NET_BUFFER_NEXT_NB(curr_nb); 1.149 curr_mdl = NET_BUFFER_FIRST_MDL(curr_nb); 1.150 page_buf = NB_FIRST_PB(curr_nb); 1.151 - while (curr_mdl) 1.152 - { 1.153 + while (curr_mdl) { 1.154 shared_buffer_t *next_buf; 1.155 PMDL next_mdl; 1.156 1.157 XN_ASSERT(page_buf); /* make sure that there is a pb to match this mdl */ 1.158 next_mdl = curr_mdl->Next; 1.159 next_buf = page_buf->next; 1.160 - if (!page_buf->virtual) 1.161 - { 1.162 + if (!page_buf->virtual) { 1.163 /* this is a hb not a pb because virtual is NULL (virtual is just the memory after the hb */ 1.164 put_hb_on_freelist(xi, (shared_buffer_t *)MmGetMdlVirtualAddress(curr_mdl) - 1); 1.165 - } 1.166 - else 1.167 - { 1.168 + } else { 1.169 //KdPrint((__DRIVER_NAME " returning page_buf %p with id %d\n", page_buf, page_buf->id)); 1.170 - if (curr_mdl != page_buf->mdl) 1.171 - { 1.172 + if (curr_mdl != page_buf->mdl) { 1.173 //KdPrint((__DRIVER_NAME " curr_mdl = %p, page_buf->mdl = %p\n", curr_mdl, page_buf->mdl)); 1.174 IoFreeMdl(curr_mdl); 1.175 } 1.176 @@ -851,8 +829,7 @@ under high rx load. The DPC is immediate 1.177 1.178 // Called at DISPATCH_LEVEL 1.179 BOOLEAN 1.180 -XenNet_RxBufferCheck(struct xennet_info *xi) 1.181 -{ 1.182 +XenNet_RxBufferCheck(struct xennet_info *xi) { 1.183 RING_IDX cons, prod; 1.184 ULONG packet_count = 0; 1.185 ULONG packet_data = 0;