~ubuntu-branches/ubuntu/quantal/open-vm-tools/quantal-201207201942

« back to all changes in this revision

Viewing changes to modules/solaris/vmxnet3/net.h

  • Committer: Bazaar Package Importer
  • Author(s): Daniel Baumann
  • Date: 2009-03-20 10:19:00 UTC
  • mfrom: (1.1.4 upstream) (2.4.3 squeeze)
  • Revision ID: james.westby@ubuntu.com-20090320101900-1o604camiubq2de8
Tags: 2009.03.18-154848-2
Correcting patch system depends (Closes: #520493).

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*********************************************************
 
2
 * Copyright (C) 1998 VMware, Inc. All rights reserved.
 
3
 *
 
4
 * The contents of this file are subject to the terms of the Common
 
5
 * Development and Distribution License (the "License") version 1.0
 
6
 * and no later version.  You may not use this file except in
 
7
 * compliance with the License.
 
8
 *
 
9
 * You can obtain a copy of the License at
 
10
 *         http://www.opensource.org/licenses/cddl1.php
 
11
 *
 
12
 * See the License for the specific language governing permissions
 
13
 * and limitations under the License.
 
14
 *
 
15
 *********************************************************/
 
16
 
 
17
/************************************************************
 
18
 *
 
19
 *   net.h
 
20
 *
 
21
 *   This file should contain all network global defines.
 
22
 *   No vlance/vmxnet/vnet/vmknet specific stuff should be
 
23
 *   put here only defines used/usable by all network code.
 
24
 *   --gustav
 
25
 *
 
26
 ************************************************************/
 
27
 
 
28
#ifndef VMWARE_DEVICES_NET_H
 
29
#define VMWARE_DEVICES_NET_H
 
30
 
 
31
#define INCLUDE_ALLOW_USERLEVEL
 
32
#define INCLUDE_ALLOW_MODULE
 
33
#define INCLUDE_ALLOW_VMMEXT
 
34
#include "includeCheck.h"
 
35
#include "vm_device_version.h"
 
36
 
 
37
#define ETHERNET_MTU         1518
 
38
#define ETH_MIN_FRAME_LEN      60
 
39
 
 
40
#ifndef ETHER_ADDR_LEN
 
41
#define ETHER_ADDR_LEN          6  /* length of MAC address */
 
42
#endif
 
43
#define ETH_HEADER_LEN         14  /* length of Ethernet header */
 
44
#define IP_ADDR_LEN             4  /* length of IPv4 address */
 
45
#define IP_HEADER_LEN          20  /* minimum length of IPv4 header */
 
46
 
 
47
#define ETHER_MAX_QUEUED_PACKET 1600
 
48
 
 
49
 
 
50
/*
 
51
 * State's that a NIC can be in currently we only use this
 
52
 * in VLance but if we implement/emulate new adapters that
 
53
 * we also want to be able to morph a new corresponding
 
54
 * state should be added.
 
55
 */
 
56
 
 
57
#define LANCE_CHIP  0x2934
 
58
#define VMXNET_CHIP 0x4392
 
59
 
 
60
/*
 
61
 * Size of reserved IO space needed by the LANCE adapter and
 
62
 * the VMXNET adapter. If you add more ports to Vmxnet than
 
63
 * there is reserved space you must bump VMXNET_CHIP_IO_RESV_SIZE.
 
64
 * The sizes must be powers of 2.
 
65
 */
 
66
 
 
67
#define LANCE_CHIP_IO_RESV_SIZE  0x20
 
68
#define VMXNET_CHIP_IO_RESV_SIZE 0x40
 
69
 
 
70
#define MORPH_PORT_SIZE 4
 
71
 
 
72
 
 
73
#ifdef USERLEVEL
 
74
 
 
75
/*
 
76
 *----------------------------------------------------------------------------
 
77
 *
 
78
 * Net_AddAddrToLADRF --
 
79
 *
 
80
 *      Given a MAC address, sets the corresponding bit in the LANCE style
 
81
 *      Logical Address Filter 'ladrf'.
 
82
 *      The caller should have initialized the ladrf to all 0's, as this
 
83
 *      function only ORs on a bit in the array.
 
84
 *      'addr' is presumed to be ETHER_ADDR_LEN in size;
 
85
 *      'ladrf' is presumed to point to a 64-bit vector.
 
86
 *
 
87
 *      Derived from a long history of derivations, originally inspired by
 
88
 *      sample code from the AMD "Network Products: Ethernet Controllers 1998
 
89
 *      Data Book, Book 2", pages 1-53..1-55.
 
90
 *
 
91
 * Returns:
 
92
 *      None.
 
93
 *
 
94
 * Side effects:
 
95
 *      Updates 'ladrf'.
 
96
 *
 
97
 *----------------------------------------------------------------------------
 
98
 */
 
99
 
 
100
static INLINE void
 
101
Net_AddAddrToLadrf(const uint8 *addr,  // IN: pointer to MAC address
 
102
                   uint8 *ladrf)       // IN/OUT: pointer to ladrf
 
103
{
 
104
#define CRC_POLYNOMIAL_BE 0x04c11db7UL  /* Ethernet CRC, big endian */
 
105
 
 
106
   uint16 hashcode;
 
107
   int32 crc = 0xffffffff;              /* init CRC for each address */
 
108
   int32 j;
 
109
   int32 bit;
 
110
   int32 byte;
 
111
 
 
112
   ASSERT(addr);
 
113
   ASSERT(ladrf);
 
114
 
 
115
   for (byte = 0; byte < ETHER_ADDR_LEN; byte++) {  /* for each address byte */
 
116
      /* process each address bit */
 
117
      for (bit = *addr++, j = 0;
 
118
           j < 8;
 
119
           j++, bit >>= 1) {
 
120
         crc = (crc << 1) ^ ((((crc < 0 ? 1 : 0) ^ bit) & 0x01) ?
 
121
               CRC_POLYNOMIAL_BE : 0);
 
122
      }
 
123
   }
 
124
   hashcode = (crc & 1);               /* hashcode is 6 LSb of CRC ... */
 
125
   for (j = 0; j < 5; j++) {           /* ... in reverse order. */
 
126
      hashcode = (hashcode << 1) | ((crc>>=1) & 1);
 
127
   }
 
128
 
 
129
   ladrf[hashcode >> 3] |= 1 << (hashcode & 0x07);
 
130
}
 
131
 
 
132
#endif // USERLEVEL
 
133
 
 
134
#endif // VMWARE_DEVICES_NET_H