summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJustus Winter <4winter@informatik.uni-hamburg.de>2015-07-25 01:55:22 +0200
committerJustus Winter <4winter@informatik.uni-hamburg.de>2015-08-15 12:43:26 +0200
commita532bf98740841143d881898c0047b1065d9e11c (patch)
tree9e3a69b78ce11f1a4895f9808c60e0ac846e5ecd
parentebe071dae0cc99dc73f8ff61950f786f4f51bdbe (diff)
device: use general lock for port lists
* device/if_hdr.h (struct ifnet): Turn the port list locks into general locks. (port_list_{lock_init,lock,unlock): New macros. * device/net_io.c (net_filter, net_set_filter): Use new macros. * device/subrs.c (if_init_queues): Likewise.
-rw-r--r--device/if_hdr.h12
-rw-r--r--device/net_io.c20
-rw-r--r--device/subrs.c4
3 files changed, 19 insertions, 17 deletions
diff --git a/device/if_hdr.h b/device/if_hdr.h
index e53983b..58a670c 100644
--- a/device/if_hdr.h
+++ b/device/if_hdr.h
@@ -92,11 +92,13 @@ struct ifnet {
struct ifqueue if_snd; /* output queue */
queue_head_t if_rcv_port_list; /* input filter list */
queue_head_t if_snd_port_list; /* output filter list */
- decl_simple_lock_data(,
- if_rcv_port_list_lock) /* lock for input filter list */
- decl_simple_lock_data(,
- if_snd_port_list_lock) /* lock for output filter list */
-/* statistics */
+ struct lock if_rcv_port_list_lock; /* lock for input filter list */
+ struct lock if_snd_port_list_lock; /* lock for output filter list */
+#define port_list_lock_init(l) lock_init(l, FALSE)
+#define port_list_lock(l) lock_write(l)
+#define port_list_unlock(l) lock_write_done(l)
+
+ /* statistics */
int if_ipackets; /* packets received */
int if_ierrors; /* input errors */
int if_opackets; /* packets sent */
diff --git a/device/net_io.c b/device/net_io.c
index 47ef2ea..12a1e9c 100644
--- a/device/net_io.c
+++ b/device/net_io.c
@@ -722,8 +722,8 @@ net_filter(kmsg, send_list)
* Both locks are hold in case a filter is removed from both
* queues.
*/
- simple_lock(&ifp->if_rcv_port_list_lock);
- simple_lock(&ifp->if_snd_port_list_lock);
+ port_list_lock(&ifp->if_rcv_port_list_lock);
+ port_list_lock(&ifp->if_snd_port_list_lock);
FILTER_ITERATE(if_port_list, infp, nextfp,
net_kmsg(kmsg)->sent ? &infp->output : &infp->input)
{
@@ -853,8 +853,8 @@ net_filter(kmsg, send_list)
}
}
FILTER_ITERATE_END
- simple_unlock(&ifp->if_snd_port_list_lock);
- simple_unlock(&ifp->if_rcv_port_list_lock);
+ port_list_unlock(&ifp->if_snd_port_list_lock);
+ port_list_unlock(&ifp->if_rcv_port_list_lock);
/*
* Deallocate dead filters.
@@ -1255,8 +1255,8 @@ net_set_filter(
in = (filter[0] & NETF_IN) != 0;
out = (filter[0] & NETF_OUT) != 0;
- simple_lock(&ifp->if_rcv_port_list_lock);
- simple_lock(&ifp->if_snd_port_list_lock);
+ port_list_lock(&ifp->if_rcv_port_list_lock);
+ port_list_lock(&ifp->if_snd_port_list_lock);
if (in)
check_filter_list(&ifp->if_rcv_port_list);
@@ -1272,8 +1272,8 @@ net_set_filter(
}
if (i == N_NET_HASH) {
simple_unlock(&net_hash_header_lock);
- simple_unlock(&ifp->if_snd_port_list_lock);
- simple_unlock(&ifp->if_rcv_port_list_lock);
+ port_list_unlock(&ifp->if_snd_port_list_lock);
+ port_list_unlock(&ifp->if_rcv_port_list_lock);
ipc_port_release_send(rcv_port);
if (match != 0)
@@ -1352,8 +1352,8 @@ net_set_filter(
hash_entp->rcv_qlimit = net_add_q_info(rcv_port);
}
- simple_unlock(&ifp->if_snd_port_list_lock);
- simple_unlock(&ifp->if_rcv_port_list_lock);
+ port_list_unlock(&ifp->if_snd_port_list_lock);
+ port_list_unlock(&ifp->if_rcv_port_list_lock);
clean_and_return:
/* No locks are held at this point. */
diff --git a/device/subrs.c b/device/subrs.c
index a10b72d..cfaaecd 100644
--- a/device/subrs.c
+++ b/device/subrs.c
@@ -80,8 +80,8 @@ void if_init_queues(struct ifnet *ifp)
IFQ_INIT(&ifp->if_snd);
queue_init(&ifp->if_rcv_port_list);
queue_init(&ifp->if_snd_port_list);
- simple_lock_init(&ifp->if_rcv_port_list_lock);
- simple_lock_init(&ifp->if_snd_port_list_lock);
+ port_list_lock_init(&ifp->if_rcv_port_list_lock);
+ port_list_lock_init(&ifp->if_snd_port_list_lock);
}