X-Git-Url: http://v3vee.org/palacios/gitweb/gitweb.cgi?a=blobdiff_plain;f=palacios%2Finclude%2Fpalacios%2Fvmm_ethernet.h;h=f43ba43653a386388f3faf5cbd2edb5533ba61fd;hb=60ad6a41c6d0ee08ed689e8505eb0c3df0c2a289;hp=ca3034bc0b21966312481211b1d2e068d40b0048;hpb=6ed3385440a7d82f4529bb9433d1a5489351c378;p=palacios.git diff --git a/palacios/include/palacios/vmm_ethernet.h b/palacios/include/palacios/vmm_ethernet.h index ca3034b..f43ba43 100644 --- a/palacios/include/palacios/vmm_ethernet.h +++ b/palacios/include/palacios/vmm_ethernet.h @@ -20,39 +20,27 @@ #ifndef __ETHERNET_H__ #define __ETHERNET_H__ +#include + #define ETHERNET_HEADER_LEN 14 #define ETHERNET_MTU 1500 #define ETHERNET_PACKET_LEN (ETHERNET_HEADER_LEN + ETHERNET_MTU) #define ETH_ALEN 6 #define MIN_MTU 68 -//#define MAX_MTU 65535 -#define MAX_MTU 9000 - -#define MAX_PACKET_LEN (ETHERNET_HEADER_LEN + MAX_MTU) - - -extern int vnet_debug; - -#ifdef __V3VEE__ +#define MAX_MTU 65536 -#include +#define MAX_PACKET_LEN (MAX_MTU + ETHERNET_HEADER_LEN) -#define V3_Net_Print(level, fmt, args...) \ - do { \ - if(level <= vnet_debug) { \ - extern struct v3_os_hooks * os_hooks; \ - if ((os_hooks) && (os_hooks)->print) { \ - (os_hooks)->print((fmt), ##args); \ - } \ - } \ - } while (0) +#ifdef V3_CONFIG_VNET +extern int net_debug; +#endif struct nic_statistics { uint64_t tx_pkts; uint64_t tx_bytes; uint64_t tx_dropped; - + uint64_t rx_pkts; uint64_t rx_bytes; uint64_t rx_dropped; @@ -60,17 +48,29 @@ struct nic_statistics { uint32_t tx_interrupts; uint32_t rx_interrupts; }; - + +#ifdef __V3VEE__ + +#include + +#define V3_Net_Print(level, fmt, args...) \ + do { \ + if(level <= net_debug) { \ + V3_Print(VM_NONE, VCORE_NONE, fmt, ##args); \ + } \ + } while (0) + + static inline int is_multicast_ethaddr(const uint8_t * addr) { - V3_ASSERT(ETH_ALEN == 6); + V3_ASSERT(VM_NONE, VCORE_NONE, ETH_ALEN == 6); return (0x01 & addr[0]); } static inline int is_broadcast_ethaddr(const uint8_t * addr) { - V3_ASSERT(ETH_ALEN == 6); + V3_ASSERT(VM_NONE, VCORE_NONE, ETH_ALEN == 6); return (addr[0] & addr[1] & addr[2] & addr[3] & addr[4] & addr[5]) == 0xff; } @@ -81,7 +81,7 @@ static inline int compare_ethaddr(const uint8_t * addr1, const uint8_t * addr2) const uint16_t *a = (const uint16_t *) addr1; const uint16_t *b = (const uint16_t *) addr2; - V3_ASSERT(ETH_ALEN == 6); + V3_ASSERT(VM_NONE, VCORE_NONE, ETH_ALEN == 6); return ((a[0] ^ b[0]) | (a[1] ^ b[1]) | (a[2] ^ b[2])) != 0; } @@ -91,7 +91,7 @@ static inline int compare_ether_hdr(const uint8_t * hdr1, const uint8_t * hdr2) uint32_t *a32 = (uint32_t *)(hdr1 + 2); uint32_t *b32 = (uint32_t *)(hdr2 + 2); - V3_ASSERT(ETHERNET_HEADER_LEN == 14); + V3_ASSERT(VM_NONE, VCORE_NONE, ETHERNET_HEADER_LEN == 14); return (*(uint16_t *)hdr1 ^ *(uint16_t *)hdr2) | (a32[0] ^ b32[0]) | (a32[1] ^ b32[1]) | (a32[2] ^ b32[2]); @@ -99,9 +99,10 @@ static inline int compare_ether_hdr(const uint8_t * hdr1, const uint8_t * hdr2) /* AA:BB:CC:DD:EE:FF */ static inline int str2mac(char * macstr, uint8_t * mac){ - char hex[2], *s = macstr; + char hex[3], *s = macstr; int i = 0; + hex[2] = 0; while(s){ memcpy(hex, s, 2); mac[i++] = (char)atox(hex);