Skip to content

Commit 6c5f7f6

Browse files
Merge remote-tracking branch 'gitlab/master'
2 parents 676ac34 + 1bff216 commit 6c5f7f6

4 files changed

Lines changed: 52 additions & 81 deletions

File tree

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ LINUX/netmap-tmp.c
3535
LINUX/i40e
3636
LINUX/failed-patches
3737
examples/bridge
38+
examples/bridge-b
3839
examples/pkt-gen
3940
examples/pkt-gen-b
4041
examples/test_select

LINUX/i40e_netmap_linux.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ extern int ix_rx_miss, ix_rx_miss_bufs, ix_crcstrip;
7171
SYSCTL_DECL(_dev_netmap);
7272
int ix_rx_miss, ix_rx_miss_bufs, ix_crcstrip;
7373
SYSCTL_INT(_dev_netmap, OID_AUTO, ix_crcstrip,
74-
CTLFLAG_RW, &ix_crcstrip, 0, "strip CRC on rx frames");
74+
CTLFLAG_RW, &ix_crcstrip, 1, "strip CRC on rx frames");
7575
SYSCTL_INT(_dev_netmap, OID_AUTO, ix_rx_miss,
7676
CTLFLAG_RW, &ix_rx_miss, 0, "potentially missed rx intr");
7777
SYSCTL_INT(_dev_netmap, OID_AUTO, ix_rx_miss_bufs,

sys/dev/netmap/netmap.c

Lines changed: 46 additions & 76 deletions
Original file line numberDiff line numberDiff line change
@@ -1491,6 +1491,20 @@ netmap_unget_na(struct netmap_adapter *na, struct ifnet *ifp)
14911491
}
14921492

14931493

1494+
#define NM_FAIL_ON(t) do { \
1495+
if (unlikely(t)) { \
1496+
RD(5, "%s: fail '" #t "' " \
1497+
"h %d c %d t %d " \
1498+
"rh %d rc %d rt %d " \
1499+
"hc %d ht %d", \
1500+
kring->name, \
1501+
head, cur, ring->tail, \
1502+
kring->rhead, kring->rcur, kring->rtail, \
1503+
kring->nr_hwcur, kring->nr_hwtail); \
1504+
return kring->nkr_num_slots; \
1505+
} \
1506+
} while (0)
1507+
14941508
/*
14951509
* validate parameters on entry for *_txsync()
14961510
* Returns ring->cur if ok, or something >= kring->nkr_num_slots
@@ -1507,7 +1521,6 @@ netmap_unget_na(struct netmap_adapter *na, struct ifnet *ifp)
15071521
u_int
15081522
nm_txsync_prologue(struct netmap_kring *kring, struct netmap_ring *ring)
15091523
{
1510-
#define NM_ASSERT(t) if (t) { D("fail " #t); goto error; }
15111524
u_int head = ring->head; /* read only once */
15121525
u_int cur = ring->cur; /* read only once */
15131526
u_int n = kring->nkr_num_slots;
@@ -1517,35 +1530,34 @@ nm_txsync_prologue(struct netmap_kring *kring, struct netmap_ring *ring)
15171530
kring->nr_hwcur, kring->nr_hwtail,
15181531
ring->head, ring->cur, ring->tail);
15191532
#if 1 /* kernel sanity checks; but we can trust the kring. */
1520-
if (kring->nr_hwcur >= n || kring->rhead >= n ||
1521-
kring->rtail >= n || kring->nr_hwtail >= n)
1522-
goto error;
1533+
NM_FAIL_ON(kring->nr_hwcur >= n || kring->rhead >= n ||
1534+
kring->rtail >= n || kring->nr_hwtail >= n);
15231535
#endif /* kernel sanity checks */
15241536
/*
1525-
* user sanity checks. We only use 'cur',
1526-
* A, B, ... are possible positions for cur:
1537+
* user sanity checks. We only use head,
1538+
* A, B, ... are possible positions for head:
15271539
*
1528-
* 0 A cur B tail C n-1
1529-
* 0 D tail E cur F n-1
1540+
* 0 A rhead B rtail C n-1
1541+
* 0 D rtail E rhead F n-1
15301542
*
15311543
* B, F, D are valid. A, C, E are wrong
15321544
*/
15331545
if (kring->rtail >= kring->rhead) {
15341546
/* want rhead <= head <= rtail */
1535-
NM_ASSERT(head < kring->rhead || head > kring->rtail);
1547+
NM_FAIL_ON(head < kring->rhead || head > kring->rtail);
15361548
/* and also head <= cur <= rtail */
1537-
NM_ASSERT(cur < head || cur > kring->rtail);
1549+
NM_FAIL_ON(cur < head || cur > kring->rtail);
15381550
} else { /* here rtail < rhead */
15391551
/* we need head outside rtail .. rhead */
1540-
NM_ASSERT(head > kring->rtail && head < kring->rhead);
1552+
NM_FAIL_ON(head > kring->rtail && head < kring->rhead);
15411553

15421554
/* two cases now: head <= rtail or head >= rhead */
15431555
if (head <= kring->rtail) {
15441556
/* want head <= cur <= rtail */
1545-
NM_ASSERT(cur < head || cur > kring->rtail);
1557+
NM_FAIL_ON(cur < head || cur > kring->rtail);
15461558
} else { /* head >= rhead */
15471559
/* cur must be outside rtail..head */
1548-
NM_ASSERT(cur > kring->rtail && cur < head);
1560+
NM_FAIL_ON(cur > kring->rtail && cur < head);
15491561
}
15501562
}
15511563
if (ring->tail != kring->rtail) {
@@ -1556,15 +1568,6 @@ nm_txsync_prologue(struct netmap_kring *kring, struct netmap_ring *ring)
15561568
kring->rhead = head;
15571569
kring->rcur = cur;
15581570
return head;
1559-
1560-
error:
1561-
RD(5, "%s kring error: head %d cur %d tail %d rhead %d rcur %d rtail %d hwcur %d hwtail %d",
1562-
kring->name,
1563-
head, cur, ring->tail,
1564-
kring->rhead, kring->rcur, kring->rtail,
1565-
kring->nr_hwcur, kring->nr_hwtail);
1566-
return n;
1567-
#undef NM_ASSERT
15681571
}
15691572

15701573

@@ -1599,30 +1602,24 @@ nm_rxsync_prologue(struct netmap_kring *kring, struct netmap_ring *ring)
15991602
cur = kring->rcur = ring->cur; /* read only once */
16001603
head = kring->rhead = ring->head; /* read only once */
16011604
#if 1 /* kernel sanity checks */
1602-
if (kring->nr_hwcur >= n || kring->nr_hwtail >= n)
1603-
goto error;
1605+
NM_FAIL_ON(kring->nr_hwcur >= n || kring->nr_hwtail >= n);
16041606
#endif /* kernel sanity checks */
16051607
/* user sanity checks */
16061608
if (kring->nr_hwtail >= kring->nr_hwcur) {
16071609
/* want hwcur <= rhead <= hwtail */
1608-
if (head < kring->nr_hwcur || head > kring->nr_hwtail)
1609-
goto error;
1610+
NM_FAIL_ON(head < kring->nr_hwcur || head > kring->nr_hwtail);
16101611
/* and also rhead <= rcur <= hwtail */
1611-
if (cur < head || cur > kring->nr_hwtail)
1612-
goto error;
1612+
NM_FAIL_ON(cur < head || cur > kring->nr_hwtail);
16131613
} else {
16141614
/* we need rhead outside hwtail..hwcur */
1615-
if (head < kring->nr_hwcur && head > kring->nr_hwtail)
1616-
goto error;
1615+
NM_FAIL_ON(head < kring->nr_hwcur && head > kring->nr_hwtail);
16171616
/* two cases now: head <= hwtail or head >= hwcur */
16181617
if (head <= kring->nr_hwtail) {
16191618
/* want head <= cur <= hwtail */
1620-
if (cur < head || cur > kring->nr_hwtail)
1621-
goto error;
1619+
NM_FAIL_ON(cur < head || cur > kring->nr_hwtail);
16221620
} else {
16231621
/* cur must be outside hwtail..head */
1624-
if (cur < head && cur > kring->nr_hwtail)
1625-
goto error;
1622+
NM_FAIL_ON(cur < head && cur > kring->nr_hwtail);
16261623
}
16271624
}
16281625
if (ring->tail != kring->rtail) {
@@ -1632,16 +1629,8 @@ nm_rxsync_prologue(struct netmap_kring *kring, struct netmap_ring *ring)
16321629
ring->tail = kring->rtail;
16331630
}
16341631
return head;
1635-
1636-
error:
1637-
RD(5, "kring error: hwcur %d rcur %d hwtail %d head %d cur %d tail %d",
1638-
kring->nr_hwcur,
1639-
kring->rcur, kring->nr_hwtail,
1640-
kring->rhead, kring->rcur, ring->tail);
1641-
return n;
16421632
}
16431633

1644-
16451634
/*
16461635
* Error routine called when txsync/rxsync detects an error.
16471636
* Can't do much more than resetting head =cur = hwcur, tail = hwtail
@@ -1976,9 +1965,8 @@ netmap_rel_exclusive(struct netmap_priv_d *priv)
19761965
* (put the adapter in netmap mode)
19771966
*
19781967
* This may be one of the following:
1979-
* (XXX these should be either all *_register or all *_reg 2014-03-15)
19801968
*
1981-
* * netmap_hw_register (hw ports)
1969+
* * netmap_hw_reg (hw ports)
19821970
* checks that the ifp is still there, then calls
19831971
* the hardware specific callback;
19841972
*
@@ -1996,7 +1984,7 @@ netmap_rel_exclusive(struct netmap_priv_d *priv)
19961984
* intercept the sync callbacks of the monitored
19971985
* rings
19981986
*
1999-
* * netmap_bwrap_register (bwraps)
1987+
* * netmap_bwrap_reg (bwraps)
20001988
* cross-link the bwrap and hwna rings,
20011989
* forward the request to the hwna, override
20021990
* the hwna notify callback (to get the frames
@@ -2120,42 +2108,24 @@ netmap_do_regif(struct netmap_priv_d *priv, struct netmap_adapter *na,
21202108
return error;
21212109
}
21222110

2123-
21242111
/*
2125-
* update kring and ring at the end of txsync.
2112+
* update kring and ring at the end of rxsync/txsync.
21262113
*/
21272114
static inline void
2128-
nm_txsync_finalize(struct netmap_kring *kring)
2115+
nm_sync_finalize(struct netmap_kring *kring)
21292116
{
2130-
/* update ring tail to what the kernel knows */
2117+
/*
2118+
* Update ring tail to what the kernel knows
2119+
* After txsync: head/rhead/hwcur might be behind cur/rcur
2120+
* if no carrier.
2121+
*/
21312122
kring->ring->tail = kring->rtail = kring->nr_hwtail;
21322123

2133-
/* note, head/rhead/hwcur might be behind cur/rcur
2134-
* if no carrier
2135-
*/
21362124
ND(5, "%s now hwcur %d hwtail %d head %d cur %d tail %d",
21372125
kring->name, kring->nr_hwcur, kring->nr_hwtail,
21382126
kring->rhead, kring->rcur, kring->rtail);
21392127
}
21402128

2141-
2142-
/*
2143-
* update kring and ring at the end of rxsync
2144-
*/
2145-
static inline void
2146-
nm_rxsync_finalize(struct netmap_kring *kring)
2147-
{
2148-
/* tell userspace that there might be new packets */
2149-
//struct netmap_ring *ring = kring->ring;
2150-
ND("head %d cur %d tail %d -> %d", ring->head, ring->cur, ring->tail,
2151-
kring->nr_hwtail);
2152-
kring->ring->tail = kring->rtail = kring->nr_hwtail;
2153-
/* make a copy of the state for next round */
2154-
kring->rhead = kring->ring->head;
2155-
kring->rcur = kring->ring->cur;
2156-
}
2157-
2158-
21592129
/*
21602130
* ioctl(2) support for the "netmap" device.
21612131
*
@@ -2360,7 +2330,7 @@ netmap_ioctl(struct netmap_priv_d *priv, u_long cmd, caddr_t data, struct thread
23602330
if (nm_txsync_prologue(kring, ring) >= kring->nkr_num_slots) {
23612331
netmap_ring_reinit(kring);
23622332
} else if (kring->nm_sync(kring, NAF_FORCE_RECLAIM) == 0) {
2363-
nm_txsync_finalize(kring);
2333+
nm_sync_finalize(kring);
23642334
}
23652335
if (netmap_verbose & NM_VERB_TXSYNC)
23662336
D("post txsync ring %d cur %d hwcur %d",
@@ -2370,7 +2340,7 @@ netmap_ioctl(struct netmap_priv_d *priv, u_long cmd, caddr_t data, struct thread
23702340
if (nm_rxsync_prologue(kring, ring) >= kring->nkr_num_slots) {
23712341
netmap_ring_reinit(kring);
23722342
} else if (kring->nm_sync(kring, NAF_FORCE_READ) == 0) {
2373-
nm_rxsync_finalize(kring);
2343+
nm_sync_finalize(kring);
23742344
}
23752345
microtime(&ring->ts);
23762346
}
@@ -2546,7 +2516,7 @@ netmap_poll(struct netmap_priv_d *priv, int events, NM_SELRECORD_T *sr)
25462516
if (kring->nm_sync(kring, 0))
25472517
revents |= POLLERR;
25482518
else
2549-
nm_txsync_finalize(kring);
2519+
nm_sync_finalize(kring);
25502520
}
25512521

25522522
/*
@@ -2609,7 +2579,7 @@ netmap_poll(struct netmap_priv_d *priv, int events, NM_SELRECORD_T *sr)
26092579
if (kring->nm_sync(kring, 0))
26102580
revents |= POLLERR;
26112581
else
2612-
nm_rxsync_finalize(kring);
2582+
nm_sync_finalize(kring);
26132583
send_down |= (kring->nr_kflags & NR_FORWARD); /* host ring only */
26142584
if (netmap_no_timestamp == 0 ||
26152585
ring->flags & NR_TIMESTAMP) {
@@ -2763,7 +2733,7 @@ netmap_detach_common(struct netmap_adapter *na)
27632733
* module unloading.
27642734
*/
27652735
static int
2766-
netmap_hw_register(struct netmap_adapter *na, int onoff)
2736+
netmap_hw_reg(struct netmap_adapter *na, int onoff)
27672737
{
27682738
struct netmap_hw_adapter *hwna =
27692739
(struct netmap_hw_adapter*)na;
@@ -2824,7 +2794,7 @@ _netmap_attach(struct netmap_adapter *arg, size_t size)
28242794
hwna->up.na_flags |= NAF_HOST_RINGS | NAF_NATIVE;
28252795
strncpy(hwna->up.name, ifp->if_xname, sizeof(hwna->up.name));
28262796
hwna->nm_hw_register = hwna->up.nm_register;
2827-
hwna->up.nm_register = netmap_hw_register;
2797+
hwna->up.nm_register = netmap_hw_reg;
28282798
if (netmap_attach_common(&hwna->up)) {
28292799
free(hwna, M_DEVBUF);
28302800
goto fail;

sys/dev/netmap/netmap_vale.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ SYSEND;
163163

164164
static int netmap_vp_create(struct nmreq *, struct ifnet *, struct netmap_vp_adapter **);
165165
static int netmap_vp_reg(struct netmap_adapter *na, int onoff);
166-
static int netmap_bwrap_register(struct netmap_adapter *, int onoff);
166+
static int netmap_bwrap_reg(struct netmap_adapter *, int onoff);
167167

168168
/*
169169
* For each output interface, nm_bdg_q is used to construct a list.
@@ -776,7 +776,7 @@ nm_bdg_ctl_attach(struct nmreq *nmr)
776776
static inline int
777777
nm_is_bwrap(struct netmap_adapter *na)
778778
{
779-
return na->nm_register == netmap_bwrap_register;
779+
return na->nm_register == netmap_bwrap_reg;
780780
}
781781

782782
/* process NETMAP_BDG_DETACH */
@@ -2271,7 +2271,7 @@ netmap_bwrap_intr_notify(struct netmap_kring *kring, int flags)
22712271

22722272
/* nm_register callback for bwrap */
22732273
static int
2274-
netmap_bwrap_register(struct netmap_adapter *na, int onoff)
2274+
netmap_bwrap_reg(struct netmap_adapter *na, int onoff)
22752275
{
22762276
struct netmap_bwrap_adapter *bna =
22772277
(struct netmap_bwrap_adapter *)na;
@@ -2570,7 +2570,7 @@ netmap_bwrap_attach(const char *nr_name, struct netmap_adapter *hwna)
25702570
nma_set_ndesc(na, t, nma_get_ndesc(hwna, r));
25712571
}
25722572
na->nm_dtor = netmap_bwrap_dtor;
2573-
na->nm_register = netmap_bwrap_register;
2573+
na->nm_register = netmap_bwrap_reg;
25742574
// na->nm_txsync = netmap_bwrap_txsync;
25752575
// na->nm_rxsync = netmap_bwrap_rxsync;
25762576
na->nm_config = netmap_bwrap_config;

0 commit comments

Comments
 (0)