} __attribute__((packed));
} __attribute__((packed));
+
+struct vnet_stat{
+ uint64_t tx_bytes;
+ uint32_t tx_pkts;
+ uint64_t rx_bytes;
+ uint32_t rx_pkts;
+};
+
+
struct v3_vnet_bridge_ops {
int (*input)(struct v3_vm_info * vm,
struct v3_vnet_pkt * pkt,
int v3_vnet_add_route(struct v3_vnet_route route);
int v3_vnet_send_pkt(struct v3_vnet_pkt * pkt, void * private_data);
int v3_vnet_find_dev(uint8_t * mac);
+int v3_vnet_stat(struct vnet_stat * stats);
#ifdef __V3VEE__
-#define VMM_DRIVERN 1
-#define GUEST_DRIVERN 0
+typedef enum {VMM_DRIVERN = 1, GUEST_DRIVERN} vnet_poll_type_t;
struct v3_vnet_dev_ops {
int (*input)(struct v3_vm_info * vm,
void * private_data;
int active;
- uint8_t mode; //vmm_drivern or guest_drivern
+ vnet_poll_type_t mode; //vmm_drivern or guest_drivern
struct list_head node;
} __attribute__((packed));
struct v3_vnet_bridge_ops brg_ops;
uint8_t type;
- uint8_t mode;
+ vnet_poll_type_t mode;
int active;
void * private_data;
} __attribute__((packed));
struct vnet_brg_dev *bridge;
v3_lock_t lock;
+ struct vnet_stat stats;
struct hashtable * route_cache;
} vnet_state;
flags = v3_lock_irqsave(vnet_state.lock);
+ vnet_state.stats.rx_bytes += pkt->size;
+ vnet_state.stats.rx_pkts++;
+
look_into_cache(pkt, &matched_routes);
if (matched_routes == NULL) {
PrintDebug("VNET/P Core: send pkt Looking into routing table\n");
PrintDebug("VNET/P Core: Packet not sent properly to bridge\n");
continue;
}
+ vnet_state.stats.tx_bytes += pkt->size;
+ vnet_state.stats.tx_pkts ++;
} else if (route->route_def.dst_type == LINK_INTERFACE) {
if (route->dst_dev == NULL || route->dst_dev->active == 0){
PrintDebug("VNET/P Core: No active device to sent data to\n");
PrintDebug("VNET/P Core: Packet not sent properly\n");
continue;
}
+ vnet_state.stats.tx_bytes += pkt->size;
+ vnet_state.stats.tx_pkts ++;
} else {
PrintError("VNET/P Core: Wrong dst type\n");
}
return 0;
}
+int v3_vnet_stat(struct vnet_stat * stats){
+
+ stats->rx_bytes = vnet_state.stats.rx_bytes;
+ stats->rx_pkts = vnet_state.stats.rx_pkts;
+ stats->tx_bytes = vnet_state.stats.tx_bytes;
+ stats->tx_pkts = vnet_state.stats.tx_pkts;
+
+ return 0;
+}
static void free_devices(){
struct vnet_dev * dev = NULL;