- Removing some magic numbers

master
Asim Jamshed 2018-10-11 00:27:49 +00:00
parent 5426bfa542
commit 51fa9686be
2 changed files with 22 additions and 2 deletions

View File

@ -14,6 +14,8 @@
#include "netmap_user.h"
/* for poll */
#include <sys/poll.h>
/* for ETHER_CRC_LEN */
#include <net/ethernet.h>
/*----------------------------------------------------------------------------*/
#define MAX_PKT_BURST 64
#define ETHERNET_FRAME_SIZE 1514
@ -22,6 +24,14 @@
#define IDLE_POLL_WAIT 1 /* msecs */
#define IDLE_POLL_COUNT 10
//#define CONST_POLLING 1
/*
* Ethernet frame overhead
*/
#define ETHER_IFG 12
#define ETHER_PREAMBLE 8
#define ETHER_OVR (ETHER_CRC_LEN + ETHER_PREAMBLE + ETHER_IFG)
/*----------------------------------------------------------------------------*/
struct netmap_private_context {
@ -115,7 +125,7 @@ netmap_send_pkts(struct mtcp_thread_context *ctxt, int nif)
#ifdef NETSTAT
mtcp->nstat.tx_packets[nif]++;
mtcp->nstat.tx_bytes[nif] += pkt_size + 24;
mtcp->nstat.tx_bytes[nif] += pkt_size + ETHER_OVR;
#endif
tx_again:

View File

@ -11,9 +11,19 @@
#include "debug.h"
/* for num_devices_* */
#include "config.h"
/* for ETHER_CRC_LEN */
#include <net/ethernet.h>
/*----------------------------------------------------------------------------*/
#define PS_CHUNK_SIZE 64
#define PS_SELECT_TIMEOUT 100 /* in us */
/*
* Ethernet frame overhead
*/
#define ETHER_IFG 12
#define ETHER_PREAMBLE 8
#define ETHER_OVR (ETHER_CRC_LEN + ETHER_PREAMBLE + ETHER_IFG)
/*----------------------------------------------------------------------------*/
struct ps_device devices[MAX_DEVICES];
/*----------------------------------------------------------------------------*/
@ -159,7 +169,7 @@ psio_flush_pkts(struct mtcp_thread_context *ctx, int nif)
for (i = 0; i < send_cnt; i++) {
#ifdef NETSTAT
mtcp->nstat.tx_bytes[nif] += c_buf->info[start_idx].len + 24;
mtcp->nstat.tx_bytes[nif] += c_buf->info[start_idx].len + ETHER_OVR;
#endif
#if PKTDUMP
DumpPacket(mtcp, c_buf->buf + c_buf->info[start_idx].offset,