MFC r353775
netmap: minor misc improvements - use ring->head rather than ring->cur in lb(8) - use strlcat() rather than strncat() - fix bandwidth computation in pkt-gen(8)
This commit is contained in:
parent
f34000fd4a
commit
131bbfc23d
|
@ -3316,7 +3316,8 @@ nmreq_getoption(struct nmreq_header *hdr, uint16_t reqtype)
|
||||||
if (!hdr->nr_options)
|
if (!hdr->nr_options)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
opt_tab = (struct nmreq_option **)(hdr->nr_options) - (NETMAP_REQ_OPT_MAX + 1);
|
opt_tab = (struct nmreq_option **)((uintptr_t)hdr->nr_options) -
|
||||||
|
(NETMAP_REQ_OPT_MAX + 1);
|
||||||
return opt_tab[reqtype];
|
return opt_tab[reqtype];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -100,7 +100,7 @@ nmreq_register_from_legacy(struct nmreq *nmr, struct nmreq_header *hdr,
|
||||||
/* No space for the pipe suffix. */
|
/* No space for the pipe suffix. */
|
||||||
return ENOBUFS;
|
return ENOBUFS;
|
||||||
}
|
}
|
||||||
strncat(hdr->nr_name, suffix, strlen(suffix));
|
strlcat(hdr->nr_name, suffix, sizeof(hdr->nr_name));
|
||||||
req->nr_mode = NR_REG_ALL_NIC;
|
req->nr_mode = NR_REG_ALL_NIC;
|
||||||
req->nr_ringid = 0;
|
req->nr_ringid = 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -2447,8 +2447,8 @@ netmap_mem_pt_guest_ifp_del(struct netmap_mem_d *nmd, struct ifnet *ifp)
|
||||||
} else {
|
} else {
|
||||||
ptnmd->pt_ifs = curr->next;
|
ptnmd->pt_ifs = curr->next;
|
||||||
}
|
}
|
||||||
nm_prinf("removed (ifp=%p,nifp_offset=%u)",
|
nm_prinf("removed (ifp=%s,nifp_offset=%u)",
|
||||||
curr->ifp, curr->nifp_offset);
|
curr->ifp->if_xname, curr->nifp_offset);
|
||||||
nm_os_free(curr);
|
nm_os_free(curr);
|
||||||
ret = 0;
|
ret = 0;
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -652,7 +652,7 @@ int main(int argc, char **argv)
|
||||||
/* extract the base name */
|
/* extract the base name */
|
||||||
char *nscan = strncmp(glob_arg.ifname, "netmap:", 7) ?
|
char *nscan = strncmp(glob_arg.ifname, "netmap:", 7) ?
|
||||||
glob_arg.ifname : glob_arg.ifname + 7;
|
glob_arg.ifname : glob_arg.ifname + 7;
|
||||||
strncpy(glob_arg.base_name, nscan, MAX_IFNAMELEN-1);
|
strncpy(glob_arg.base_name, nscan, MAX_IFNAMELEN - 1);
|
||||||
for (nscan = glob_arg.base_name; *nscan && !index("-*^{}/@", *nscan); nscan++)
|
for (nscan = glob_arg.base_name; *nscan && !index("-*^{}/@", *nscan); nscan++)
|
||||||
;
|
;
|
||||||
*nscan = '\0';
|
*nscan = '\0';
|
||||||
|
@ -948,8 +948,8 @@ run:
|
||||||
struct netmap_ring *rxring = NETMAP_RXRING(rxport->nmd->nifp, i);
|
struct netmap_ring *rxring = NETMAP_RXRING(rxport->nmd->nifp, i);
|
||||||
|
|
||||||
//D("prepare to scan rings");
|
//D("prepare to scan rings");
|
||||||
int next_cur = rxring->cur;
|
int next_head = rxring->head;
|
||||||
struct netmap_slot *next_slot = &rxring->slot[next_cur];
|
struct netmap_slot *next_slot = &rxring->slot[next_head];
|
||||||
const char *next_buf = NETMAP_BUF(rxring, next_slot->buf_idx);
|
const char *next_buf = NETMAP_BUF(rxring, next_slot->buf_idx);
|
||||||
while (!nm_ring_empty(rxring)) {
|
while (!nm_ring_empty(rxring)) {
|
||||||
struct netmap_slot *rs = next_slot;
|
struct netmap_slot *rs = next_slot;
|
||||||
|
@ -963,14 +963,14 @@ run:
|
||||||
non_ip++; // XXX ??
|
non_ip++; // XXX ??
|
||||||
}
|
}
|
||||||
// prefetch the buffer for the next round
|
// prefetch the buffer for the next round
|
||||||
next_cur = nm_ring_next(rxring, next_cur);
|
next_head = nm_ring_next(rxring, next_head);
|
||||||
next_slot = &rxring->slot[next_cur];
|
next_slot = &rxring->slot[next_head];
|
||||||
next_buf = NETMAP_BUF(rxring, next_slot->buf_idx);
|
next_buf = NETMAP_BUF(rxring, next_slot->buf_idx);
|
||||||
__builtin_prefetch(next_buf);
|
__builtin_prefetch(next_buf);
|
||||||
// 'B' is just a hashing seed
|
// 'B' is just a hashing seed
|
||||||
rs->buf_idx = forward_packet(g, rs);
|
rs->buf_idx = forward_packet(g, rs);
|
||||||
rs->flags |= NS_BUF_CHANGED;
|
rs->flags |= NS_BUF_CHANGED;
|
||||||
rxring->head = rxring->cur = next_cur;
|
rxring->head = rxring->cur = next_head;
|
||||||
|
|
||||||
batch++;
|
batch++;
|
||||||
if (unlikely(batch >= glob_arg.batch)) {
|
if (unlikely(batch >= glob_arg.batch)) {
|
||||||
|
|
|
@ -2634,7 +2634,7 @@ main_thread(struct glob_arg *g)
|
||||||
D("%spps %s(%spkts %sbps in %llu usec) %.2f avg_batch %d min_space",
|
D("%spps %s(%spkts %sbps in %llu usec) %.2f avg_batch %d min_space",
|
||||||
norm(b1, pps, normalize), b4,
|
norm(b1, pps, normalize), b4,
|
||||||
norm(b2, (double)x.pkts, normalize),
|
norm(b2, (double)x.pkts, normalize),
|
||||||
norm(b3, (double)x.bytes*8+(double)x.pkts*g->framing, normalize),
|
norm(b3, 1000000*((double)x.bytes*8+(double)x.pkts*g->framing)/usec, normalize),
|
||||||
(unsigned long long)usec,
|
(unsigned long long)usec,
|
||||||
abs, (int)cur.min_space);
|
abs, (int)cur.min_space);
|
||||||
prev = cur;
|
prev = cur;
|
||||||
|
@ -2973,6 +2973,7 @@ main(int arc, char **argv)
|
||||||
g.options |= OPT_DUMP;
|
g.options |= OPT_DUMP;
|
||||||
break;
|
break;
|
||||||
case 'C':
|
case 'C':
|
||||||
|
D("WARNING: the 'C' option is deprecated, use the '+conf:' libnetmap option instead");
|
||||||
g.nmr_config = strdup(optarg);
|
g.nmr_config = strdup(optarg);
|
||||||
break;
|
break;
|
||||||
case 'H':
|
case 'H':
|
||||||
|
|
Loading…
Reference in New Issue