1
/*********************************************************
2
* Copyright (C) 1998 VMware, Inc. All rights reserved.
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.
9
* You can obtain a copy of the License at
10
* http://www.opensource.org/licenses/cddl1.php
12
* See the License for the specific language governing permissions
13
* and limitations under the License.
15
*********************************************************/
17
/************************************************************
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.
26
************************************************************/
28
#ifndef VMWARE_DEVICES_NET_H
29
#define VMWARE_DEVICES_NET_H
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"
37
#define ETHERNET_MTU 1518
38
#define ETH_MIN_FRAME_LEN 60
40
#ifndef ETHER_ADDR_LEN
41
#define ETHER_ADDR_LEN 6 /* length of MAC address */
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 */
47
#define ETHER_MAX_QUEUED_PACKET 1600
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.
57
#define LANCE_CHIP 0x2934
58
#define VMXNET_CHIP 0x4392
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.
67
#define LANCE_CHIP_IO_RESV_SIZE 0x20
68
#define VMXNET_CHIP_IO_RESV_SIZE 0x40
70
#define MORPH_PORT_SIZE 4
76
*----------------------------------------------------------------------------
78
* Net_AddAddrToLADRF --
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.
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.
97
*----------------------------------------------------------------------------
101
Net_AddAddrToLadrf(const uint8 *addr, // IN: pointer to MAC address
102
uint8 *ladrf) // IN/OUT: pointer to ladrf
104
#define CRC_POLYNOMIAL_BE 0x04c11db7UL /* Ethernet CRC, big endian */
107
int32 crc = 0xffffffff; /* init CRC for each address */
115
for (byte = 0; byte < ETHER_ADDR_LEN; byte++) { /* for each address byte */
116
/* process each address bit */
117
for (bit = *addr++, j = 0;
120
crc = (crc << 1) ^ ((((crc < 0 ? 1 : 0) ^ bit) & 0x01) ?
121
CRC_POLYNOMIAL_BE : 0);
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);
129
ladrf[hashcode >> 3] |= 1 << (hashcode & 0x07);
134
#endif // VMWARE_DEVICES_NET_H