~n-muench/ubuntu/precise/open-vm-tools/open-vm-tools-precise.sid-merge1

« back to all changes in this revision

Viewing changes to modules/freebsd/vmxnet/if_vxn.c

  • Committer: Bazaar Package Importer
  • Author(s): Daniel Baumann
  • Date: 2009-12-06 07:45:05 UTC
  • mfrom: (1.1.8 upstream) (2.4.10 sid)
  • Revision ID: james.westby@ubuntu.com-20091206074505-43rp7oejjgp0y2re
Tags: 2009.11.16-210370-1
* Merging upstream version 2009.11.16-210370.
* Moving vmusr plugins from open-vm-tools to open-vm-toolbox (Closes:
  #539282, #557215).
* Correcting plugin location (Closes: #545222, #549044).
* Dropping la files (Closes: #551626).
* Adding open-vm-toolbox lintian overrides.
* Removing test plugin.
* Removing unused plugin symlinks.

Show diffs side-by-side

added added

removed removed

Lines of Context:
23
23
#include <sys/malloc.h>
24
24
#include <sys/kernel.h>
25
25
#include <sys/socket.h>
 
26
#include <sys/systm.h>
26
27
 
27
28
/*
28
29
 * FreeBSD 5.3 introduced an MP-safe (multiprocessor-safe) network stack.
433
434
      VXN_IF_FREE(sc);
434
435
   }
435
436
 
 
437
   pci_disable_io(dev, SYS_RES_IOPORT);
 
438
   pci_disable_busmaster(dev);
 
439
   VXN_MTX_DESTROY(&sc->vxn_mtx);
 
440
 
436
441
  done:
437
442
 
438
443
   splx(s);
475
480
   /*
476
481
    * Cleanup - release resources and memory
477
482
    */
 
483
   VXN_IF_FREE(sc);
478
484
   contigfree(sc->vxn_dd, sc->vxn_dd->length, M_DEVBUF);
479
485
   bus_teardown_intr(dev, sc->vxn_irq, sc->vxn_intrhand);
480
486
   bus_release_resource(dev, SYS_RES_IRQ, 0, sc->vxn_irq);
481
487
   bus_release_resource(dev, SYS_RES_IOPORT, VXN_PCIR_MAPS, sc->vxn_io);
 
488
   pci_disable_io(dev, SYS_RES_IOPORT);
 
489
   pci_disable_busmaster(dev);
482
490
   VXN_MTX_DESTROY(&sc->vxn_mtx);
483
 
   VXN_IF_FREE(sc);
484
491
 
485
492
   splx(s);
486
493
   return 0;
1135
1142
               m_new = NULL;
1136
1143
            }
1137
1144
         }
1138
 
        
 
1145
 
1139
1146
         /*
1140
1147
          * replace the current mbuf in the descriptor with the new one
1141
1148
          * and pass the packet up to the kernel
1255
1262
    */
1256
1263
   for (i = 0; i < sc->vxn_num_rx_bufs; i++) {
1257
1264
      struct mbuf *m_new = NULL;
1258
 
        
 
1265
 
 
1266
      /*
 
1267
       * Allocate an mbuf and initialize it to contain a packet header and
 
1268
       * internal data.
 
1269
       */
1259
1270
      MGETHDR(m_new, M_DONTWAIT, MT_DATA);
1260
1271
      if (m_new != NULL) {
 
1272
         /* Allocate and attach an mbuf cluster to mbuf. */
1261
1273
         MCLGET(m_new, M_DONTWAIT);
1262
1274
         if (m_new->m_flags & M_EXT) {
1263
1275
            m_adj(m_new, ETHER_ALIGN);
1267
1279
            sc->vxn_rx_buffptr[i] = m_new;
1268
1280
            sc->vxn_rx_ring[i].ownership = VMXNET2_OWNERSHIP_NIC;
1269
1281
         } else {
 
1282
            /*
 
1283
             * Allocation and attachment of mbuf clusters failed.
 
1284
             */
1270
1285
            m_freem(m_new);
1271
1286
            m_new = NULL;
1272
 
            return ENOMEM;
 
1287
            goto err_release_ring;
1273
1288
         }
1274
1289
      } else {
1275
 
         return ENOMEM;
 
1290
         /* Allocation of mbuf failed. */
 
1291
         goto err_release_ring;
1276
1292
      }
1277
1293
   }
1278
1294
 
1299
1315
 
1300
1316
   sc->vxn_rings_allocated = 1;
1301
1317
   return 0;
 
1318
err_release_ring:
 
1319
   /*
 
1320
    * Clearup already allocated mbufs and attached clusters.
 
1321
    */
 
1322
  for (--i; i >= 0; i--) {
 
1323
     m_freem(sc->vxn_rx_buffptr[i]);
 
1324
     sc->vxn_rx_buffptr[i] = NULL;
 
1325
     sc->vxn_rx_ring[i].paddr = 0;
 
1326
     sc->vxn_rx_ring[i].bufferLength = 0;
 
1327
     sc->vxn_rx_ring[i].ownership = 0;
 
1328
  }
 
1329
  return ENOMEM;
 
1330
 
1302
1331
}
1303
1332
 
1304
1333
/*