~ubuntu-branches/ubuntu/precise/open-vm-tools/precise

« back to all changes in this revision

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

  • Committer: Bazaar Package Importer
  • Author(s): Serge Hallyn
  • Date: 2011-03-31 14:20:05 UTC
  • mfrom: (1.4.3 upstream)
  • Revision ID: james.westby@ubuntu.com-20110331142005-3n9red91p7ogkweo
Tags: 2011.03.28-387002-0ubuntu1
* Merge latest upstream git tag.  This has the unlocked_ioctl change
  needed to fix dkms build failures (LP: #727342)
* Changes in debian/rules:
  - work around a bug in toolbox/Makefile, where install-exec-hook is
    not happening.  This needs to get fixed the right way.
  - don't install 'vmware-user' which seems to no longer exist
  - move /etc/xdg into open-vm-toolbox (which should be done using .install)
* debian/open-vm-tools.init: add 'modprobe [-r] vmblock'. (LP: #332323)
* debian/rules and debian/open-vm-toolbox.lintian-overrides:
  - Make vmware-user-suid-wrapper suid-root (LP: #332323)

Show diffs side-by-side

added added

removed removed

Lines of Context:
104
104
   struct arpcom            arpcom;
105
105
#else
106
106
   struct ifnet            *vxn_ifp;
 
107
   struct ifmedia           media;
107
108
#endif
108
109
#ifdef VXN_MPSAFE
109
110
   struct mtx               vxn_mtx;
217
218
                           VMXNET_COMMAND_ADDR);
218
219
}
219
220
 
 
221
static int
 
222
vxn_check_link(vxn_softc_t *sc)
 
223
{
 
224
   uint32 status;
 
225
   int ok;
 
226
 
 
227
   status = bus_space_read_4(sc->vxn_iobtag, sc->vxn_iobhandle, VMXNET_STATUS_ADDR);
 
228
   ok = (status & VMXNET_STATUS_CONNECTED) != 0;
 
229
   return ok;
 
230
}
 
231
 
 
232
/*
 
233
 *-----------------------------------------------------------------------------
 
234
 *
 
235
 * vxn_media_status --
 
236
 *
 
237
 *      This routine is called when the user quries the status of interface
 
238
 *      using ifconfig. Checks link state and updates media state accorgingly.
 
239
 *
 
240
 * Results:
 
241
 *      None.
 
242
 *
 
243
 * Side effects:
 
244
 *      None.
 
245
 *
 
246
 *-----------------------------------------------------------------------------
 
247
 */
 
248
 
 
249
static void
 
250
vxn_media_status(struct ifnet * ifp, struct ifmediareq * ifmr)
 
251
{
 
252
   vxn_softc_t *sc = ifp->if_softc;
 
253
   int connected = 0;
 
254
 
 
255
   VXN_LOCK((vxn_softc_t *)ifp->if_softc);
 
256
   connected = vxn_check_link(sc);
 
257
 
 
258
   ifmr->ifm_status = IFM_AVALID;
 
259
   ifmr->ifm_active = IFM_ETHER;
 
260
 
 
261
   if (!connected) {
 
262
      ifmr->ifm_status &= ~IFM_ACTIVE;
 
263
      VXN_UNLOCK((vxn_softc_t *)ifp->if_softc);
 
264
      return;
 
265
   }
 
266
 
 
267
   ifmr->ifm_status |= IFM_ACTIVE;
 
268
 
 
269
   VXN_UNLOCK((vxn_softc_t *)ifp->if_softc);
 
270
   return;
 
271
}
 
272
 
 
273
 
 
274
/*
 
275
 *-----------------------------------------------------------------------------
 
276
 *
 
277
 * vxn_media_change --
 
278
 *
 
279
 *      This routine is called when the user changes speed/duplex using
 
280
 *      media/mediopt option with ifconfig.
 
281
 *
 
282
 * Results:
 
283
 *      Returns 0 for success, error code otherwise.
 
284
 *
 
285
 * Side effects:
 
286
 *      None.
 
287
 *
 
288
 *-----------------------------------------------------------------------------
 
289
 */
 
290
 
 
291
static int
 
292
vxn_media_change(struct ifnet * ifp)
 
293
{
 
294
   vxn_softc_t *sc = ifp->if_softc;
 
295
   struct ifmedia *ifm = &sc->media;
 
296
 
 
297
   if (IFM_TYPE(ifm->ifm_media) != IFM_ETHER)
 
298
      return (EINVAL);
 
299
 
 
300
   if (IFM_SUBTYPE(ifm->ifm_media) != IFM_AUTO)
 
301
      printf("Media subtype is not AUTO, it is : %d.\n",
 
302
             IFM_SUBTYPE(ifm->ifm_media));
 
303
 
 
304
   return (0);
 
305
}
 
306
 
 
307
 
220
308
/*
221
309
 *-----------------------------------------------------------------------------
222
310
 * vxn_attach --
393
481
    * read the MAC address from the device
394
482
    */
395
483
   for (i = 0; i < 6; i++) {
396
 
      mac[i] = bus_space_read_1(sc->vxn_iobtag, sc->vxn_iobhandle, VMXNET_MAC_ADDR + i);
 
484
      mac[i] = bus_space_read_1(sc->vxn_iobtag, sc->vxn_iobhandle, VMXNET_MAC_ADDR
 
485
                                + i);
397
486
   }
398
487
 
399
488
#ifdef VXN_NEEDARPCOM
414
503
          sc->vxn_num_tx_bufs, (int)sizeof(Vmxnet2_TxRingEntry),
415
504
          driverDataSize);
416
505
 
 
506
   /*
 
507
    * Specify the media types supported by this adapter and register
 
508
    * callbacks to update media and link information
 
509
    */
 
510
   ifmedia_init(&sc->media, IFM_IMASK, vxn_media_change,
 
511
                vxn_media_status);
 
512
   ifmedia_add(&sc->media, IFM_ETHER | IFM_FDX, 0, NULL);
 
513
   ifmedia_add(&sc->media, IFM_ETHER | IFM_1000_T | IFM_FDX, 0, NULL);
 
514
   ifmedia_add(&sc->media, IFM_ETHER | IFM_1000_T, 0, NULL);
 
515
   ifmedia_add(&sc->media, IFM_ETHER | IFM_AUTO, 0, NULL);
 
516
   ifmedia_set(&sc->media, IFM_ETHER | IFM_AUTO);
 
517
 
 
518
 
417
519
   goto done;
418
520
 
419
 
  fail:
 
521
fail:
420
522
 
421
523
   if (sc->vxn_intrhand != NULL) {
422
524
      bus_teardown_intr(dev, sc->vxn_irq, sc->vxn_intrhand);
468
570
   sc = device_get_softc(dev);
469
571
 
470
572
   ifp = VXN_SC2IFP(sc);
471
 
 
472
 
   if (device_get_state(dev) >= DS_ATTACHED) {
 
573
   if (device_is_attached(dev)) {
473
574
      vxn_stop(sc);
474
575
      /*
475
576
       * detach from stack
689
790
{
690
791
   Vmxnet2_DriverData *dd = sc->vxn_dd;
691
792
   struct ifnet *ifp = VXN_SC2IFP(sc);
692
 
   uint32 r;
 
793
   uint32 r, i;
 
794
   u_char mac_addr[6];
693
795
 
694
796
   VXN_LOCK_ASSERT(sc);
695
797
 
702
804
         return;
703
805
      }
704
806
 
 
807
      /* Get MAC address from interface and set it in hardware */
 
808
#if __FreeBSD_version >= 700000
 
809
      printf("addrlen : %d. \n", ifp->if_addrlen);
 
810
      bcopy(LLADDR((struct sockaddr_dl *)ifp->if_addr->ifa_addr), mac_addr,
 
811
            ifp->if_addrlen > 6 ? 6 : ifp->if_addrlen);
 
812
#else
 
813
      if (!ifaddr_byindex(ifp->if_index)) {
 
814
         printf("vxn:%d Invalid link address, interface index :%d.\n",
 
815
                VXN_IF_UNIT(ifp), ifp->if_index);
 
816
      } else {
 
817
         bcopy(LLADDR((struct sockaddr_dl *)ifaddr_byindex(ifp->if_index)->ifa_addr),
 
818
               mac_addr, ifp->if_addrlen);
 
819
      }
 
820
#endif
 
821
      printf("vxn%d: MAC Address : %02x:%02x:%02x:%02x:%02x:%02x \n",
 
822
             VXN_IF_UNIT(ifp), mac_addr[0], mac_addr[1], mac_addr[2],
 
823
             mac_addr[3], mac_addr[4], mac_addr[5]);
 
824
      for (i = 0; i < 6; i++) {
 
825
         bus_space_write_1(sc->vxn_iobtag, sc->vxn_iobhandle, VMXNET_MAC_ADDR +
 
826
                           i, mac_addr[i]);
 
827
      }
 
828
 
705
829
      /*
706
830
       * Start hardware
707
831
       */
1008
1132
      error = 0;
1009
1133
      break;
1010
1134
 
 
1135
   case SIOCSIFMEDIA:
 
1136
   case SIOCGIFMEDIA:
 
1137
      ifmedia_ioctl(ifp, (struct ifreq *)data, &sc->media, command);
 
1138
 
1011
1139
   default:
1012
1140
      error = EINVAL;
1013
1141
      break;