Page MenuHomeFreeBSD

D18952.diff
No OneTemporary

D18952.diff

Index: sys/dev/netmap/netmap_freebsd.c
===================================================================
--- sys/dev/netmap/netmap_freebsd.c
+++ sys/dev/netmap/netmap_freebsd.c
@@ -75,20 +75,20 @@
/* ======================== FREEBSD-SPECIFIC ROUTINES ================== */
+static struct mtx nm_knlist_lock;
+MTX_SYSINIT(nm_knlist_lock, &nm_knlist_lock, "knlist lock for netmap ports",
+ MTX_DEF);
+
void nm_os_selinfo_init(NM_SELINFO_T *si) {
- struct mtx *m = &si->m;
- mtx_init(m, "nm_kn_lock", NULL, MTX_DEF);
- knlist_init_mtx(&si->si.si_note, m);
+ knlist_init_mtx(&si->si_note, &nm_knlist_lock);
}
void
nm_os_selinfo_uninit(NM_SELINFO_T *si)
{
/* XXX kqueue(9) needed; these will mirror knlist_init. */
- knlist_delete(&si->si.si_note, curthread, /*islocked=*/0);
- knlist_destroy(&si->si.si_note);
- /* now we don't need the mutex anymore */
- mtx_destroy(&si->m);
+ knlist_delete(&si->si_note, curthread, /*islocked=*/0);
+ knlist_destroy(&si->si_note);
}
void *
@@ -1297,8 +1297,6 @@
* function that it is being called from 'nm_os_selwakeup'; this
* is necessary because when netmap_knrw() is called by the kevent
* subsystem (i.e. kevent_scan()) we also need to call netmap_poll().
- * The knote uses a private mutex associated to the 'si' (see struct
- * selinfo, struct nm_selinfo, and nm_os_selinfo_init).
*
* The netmap_kqfilter() function registers one or another f_event
* depending on read or write mode. A pointer to the struct
@@ -1310,29 +1308,29 @@
void
-nm_os_selwakeup(struct nm_selinfo *si)
+nm_os_selwakeup(struct selinfo *si)
{
if (netmap_verbose)
- nm_prinf("on knote %p", &si->si.si_note);
- selwakeuppri(&si->si, PI_NET);
+ nm_prinf("on knote %p", &si->si_note);
+ selwakeuppri(si, PI_NET);
/* We use a non-zero hint to distinguish this notification call
* from the call done in kqueue_scan(), which uses hint=0.
*/
- KNOTE(&si->si.si_note, /*hint=*/0x100,
- mtx_owned(&si->m) ? KNF_LISTLOCKED : 0);
+ KNOTE(&si->si_note, /*hint=*/0x100,
+ mtx_owned(&nm_knlist_lock) ? KNF_LISTLOCKED : 0);
}
void
-nm_os_selrecord(struct thread *td, struct nm_selinfo *si)
+nm_os_selrecord(struct thread *td, struct selinfo *si)
{
- selrecord(td, &si->si);
+ selrecord(td, si);
}
static void
netmap_knrdetach(struct knote *kn)
{
struct netmap_priv_d *priv = (struct netmap_priv_d *)kn->kn_hook;
- struct selinfo *si = &priv->np_si[NR_RX]->si;
+ struct selinfo *si = priv->np_si[NR_RX];
nm_prinf("remove selinfo %p", si);
knlist_remove(&si->si_note, kn, /*islocked=*/0);
@@ -1342,7 +1340,7 @@
netmap_knwdetach(struct knote *kn)
{
struct netmap_priv_d *priv = (struct netmap_priv_d *)kn->kn_hook;
- struct selinfo *si = &priv->np_si[NR_TX]->si;
+ struct selinfo *si = priv->np_si[NR_TX];
nm_prinf("remove selinfo %p", si);
knlist_remove(&si->si_note, kn, /*islocked=*/0);
@@ -1411,7 +1409,7 @@
struct netmap_priv_d *priv;
int error;
struct netmap_adapter *na;
- struct nm_selinfo *si;
+ struct selinfo *si;
int ev = kn->kn_filter;
if (ev != EVFILT_READ && ev != EVFILT_WRITE) {
@@ -1433,7 +1431,7 @@
kn->kn_fop = (ev == EVFILT_WRITE) ?
&netmap_wfiltops : &netmap_rfiltops;
kn->kn_hook = priv;
- knlist_add(&si->si.si_note, kn, /*islocked=*/0);
+ knlist_add(&si->si_note, kn, /*islocked=*/0);
return 0;
}
Index: sys/dev/netmap/netmap_kern.h
===================================================================
--- sys/dev/netmap/netmap_kern.h
+++ sys/dev/netmap/netmap_kern.h
@@ -98,7 +98,7 @@
#define NM_MTX_UNLOCK(m) sx_xunlock(&(m))
#define NM_MTX_ASSERT(m) sx_assert(&(m), SA_XLOCKED)
-#define NM_SELINFO_T struct nm_selinfo
+#define NM_SELINFO_T struct selinfo
#define NM_SELRECORD_T struct thread
#define MBUF_LEN(m) ((m)->m_pkthdr.len)
#define MBUF_TXQ(m) ((m)->m_pkthdr.flowid)
@@ -131,11 +131,6 @@
#define MBUF_QUEUED(m) 1
-struct nm_selinfo {
- struct selinfo si;
- struct mtx m;
-};
-
struct hrtimer {
/* Not used in FreeBSD. */

File Metadata

Mime Type
text/plain
Expires
Mon, Jan 27, 2:54 AM (34 m, 1 s)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
16185627
Default Alt Text
D18952.diff (3 KB)

Event Timeline