Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 19 Oct 2015 11:57:34 +0000 (UTC)
From:      Hans Petter Selasky <hselasky@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r289574 - in head/sys/ofed: drivers/infiniband/core drivers/net/mlx4 include/linux
Message-ID:  <201510191157.t9JBvYc5070159@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: hselasky
Date: Mon Oct 19 11:57:33 2015
New Revision: 289574
URL: https://svnweb.freebsd.org/changeset/base/289574

Log:
  Merge LinuxKPI changes from DragonflyBSD:
  - Add more list related functions and macros.
  - Update the hlist_for_each_entry() macro to take one less argument.
  
  Sponsored by:	Mellanox Technologies

Modified:
  head/sys/ofed/drivers/infiniband/core/cma.c
  head/sys/ofed/drivers/infiniband/core/fmr_pool.c
  head/sys/ofed/drivers/net/mlx4/en_netdev.c
  head/sys/ofed/include/linux/list.h

Modified: head/sys/ofed/drivers/infiniband/core/cma.c
==============================================================================
--- head/sys/ofed/drivers/infiniband/core/cma.c	Mon Oct 19 11:51:10 2015	(r289573)
+++ head/sys/ofed/drivers/infiniband/core/cma.c	Mon Oct 19 11:57:33 2015	(r289574)
@@ -2400,10 +2400,9 @@ static int cma_check_port(struct rdma_bi
 {
 	struct rdma_id_private *cur_id;
 	struct sockaddr *addr, *cur_addr;
-	struct hlist_node *node;
 
 	addr = (struct sockaddr *) &id_priv->id.route.addr.src_addr;
-	hlist_for_each_entry(cur_id, node, &bind_list->owners, node) {
+	hlist_for_each_entry(cur_id, &bind_list->owners, node) {
 		if (id_priv == cur_id)
 			continue;
 

Modified: head/sys/ofed/drivers/infiniband/core/fmr_pool.c
==============================================================================
--- head/sys/ofed/drivers/infiniband/core/fmr_pool.c	Mon Oct 19 11:51:10 2015	(r289573)
+++ head/sys/ofed/drivers/infiniband/core/fmr_pool.c	Mon Oct 19 11:57:33 2015	(r289574)
@@ -118,14 +118,13 @@ static inline struct ib_pool_fmr *ib_fmr
 {
 	struct hlist_head *bucket;
 	struct ib_pool_fmr *fmr;
-	struct hlist_node *pos;
 
 	if (!pool->cache_bucket)
 		return NULL;
 
 	bucket = pool->cache_bucket + ib_fmr_hash(*page_list);
 
-	hlist_for_each_entry(fmr, pos, bucket, cache_node)
+	hlist_for_each_entry(fmr, bucket, cache_node)
 		if (io_virtual_address == fmr->io_virtual_address &&
 		    page_list_len      == fmr->page_list_len      &&
 		    !memcmp(page_list, fmr->page_list,

Modified: head/sys/ofed/drivers/net/mlx4/en_netdev.c
==============================================================================
--- head/sys/ofed/drivers/net/mlx4/en_netdev.c	Mon Oct 19 11:51:10 2015	(r289573)
+++ head/sys/ofed/drivers/net/mlx4/en_netdev.c	Mon Oct 19 11:57:33 2015	(r289574)
@@ -264,11 +264,10 @@ static inline struct mlx4_en_filter *
 mlx4_en_filter_find(struct mlx4_en_priv *priv, __be32 src_ip, __be32 dst_ip,
 		    u8 ip_proto, __be16 src_port, __be16 dst_port)
 {
-	struct hlist_node *elem;
 	struct mlx4_en_filter *filter;
 	struct mlx4_en_filter *ret = NULL;
 
-	hlist_for_each_entry(filter, elem,
+	hlist_for_each_entry(filter,
 			     filter_hash_bucket(priv, src_ip, dst_ip,
 						src_port, dst_port),
 			     filter_chain) {

Modified: head/sys/ofed/include/linux/list.h
==============================================================================
--- head/sys/ofed/include/linux/list.h	Mon Oct 19 11:51:10 2015	(r289573)
+++ head/sys/ofed/include/linux/list.h	Mon Oct 19 11:57:33 2015	(r289574)
@@ -96,6 +96,15 @@ list_del(struct list_head *entry)
 }
 
 static inline void
+list_replace(struct list_head *old, struct list_head *new)
+{
+	new->next = old->next;
+	new->next->prev = new;
+	new->prev = old->prev;
+	new->prev->next = new;
+}
+
+static inline void
 _list_add(struct list_head *new, struct list_head *prev,
     struct list_head *next)
 {
@@ -119,6 +128,9 @@ list_del_init(struct list_head *entry)
 #define list_first_entry(ptr, type, member) \
         list_entry((ptr)->next, type, member)
 
+#define	list_next_entry(ptr, member)					\
+	list_entry(((ptr)->member.next), typeof(*(ptr)), member)
+
 #define	list_for_each(p, head)						\
 	for (p = (head)->next; p != (head); p = p->next)
 
@@ -134,6 +146,15 @@ list_del_init(struct list_head *entry)
 	    n = list_entry(p->field.next, typeof(*p), field); &p->field != (h);\
 	    p = n, n = list_entry(n->field.next, typeof(*n), field))
 
+#define	list_for_each_entry_continue(p, h, field)			\
+	for (p = list_next_entry((p), field); &p->field != (h);		\
+	    p = list_next_entry((p), field))
+
+#define	list_for_each_entry_safe_from(pos, n, head, member) 			\
+	for (n = list_entry(pos->member.next, typeof(*pos), member);		\
+	     &pos->member != (head);						\
+	     pos = n, n = list_entry(n->member.next, typeof(*n), member))
+
 #define	list_for_each_entry_reverse(p, h, field)			\
 	for (p = list_entry((h)->prev, typeof(*p), field); &p->field != (h); \
 	    p = list_entry(p->field.prev, typeof(*p), field))
@@ -381,10 +402,14 @@ static inline int list_is_last(const str
 #define	hlist_for_each_safe(p, n, head)					\
 	for (p = (head)->first; p && ({ n = p->next; 1; }); p = n)
 
-#define	hlist_for_each_entry(tp, p, head, field)			\
-	for (p = (head)->first;						\
-	    p ? (tp = hlist_entry(p, typeof(*tp), field)): NULL; p = p->next)
- 
+#define	hlist_entry_safe(ptr, type, member) \
+	((ptr) ? hlist_entry(ptr, type, member) : NULL)
+
+#define	hlist_for_each_entry(pos, head, member)				\
+	for (pos = hlist_entry_safe((head)->first, typeof(*(pos)), member);\
+	     pos;							\
+	     pos = hlist_entry_safe((pos)->member.next, typeof(*(pos)), member))
+
 #define hlist_for_each_entry_continue(tp, p, field)			\
 	for (p = (p)->next;						\
 	    p ? (tp = hlist_entry(p, typeof(*tp), field)): NULL; p = p->next)
@@ -398,4 +423,8 @@ static inline int list_is_last(const str
 		 tpos = hlist_entry((pos), typeof(*(tpos)), member); 1;}); \
 	     pos = (n))
 
+#define	hlist_add_head_rcu(n, h)	hlist_add_head(n, h)
+
+#define	hlist_del_init_rcu(n)		hlist_del_init(n)
+
 #endif /* _LINUX_LIST_H_ */



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201510191157.t9JBvYc5070159>