netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Paul Gortmaker <paul.gortmaker@windriver.com>
To: davem@davemloft.net
Cc: netdev@vger.kernel.org, Allan.Stephens@windriver.com,
	Allan Stephens <allan.stephens@windriver.com>,
	Paul Gortmaker <paul.gortmaker@windriver.com>
Subject: [PATCH net-next 08/26] tipc: Split up unified structure of network-related variables
Date: Sun, 13 Mar 2011 17:33:56 -0400	[thread overview]
Message-ID: <1300052054-7531-9-git-send-email-paul.gortmaker@windriver.com> (raw)
In-Reply-To: <1300052054-7531-1-git-send-email-paul.gortmaker@windriver.com>

From: Allan Stephens <allan.stephens@windriver.com>

Converts the fields of the global "tipc_net" structure into individual
variables.  Since the struct was never referenced as a complete unit,
its existence was pointless.  This will facilitate upcoming changes to
TIPC's node table and simpify upcoming relocation of the variables so
they are only visible to the files that actually use them.

This change is essentially cosmetic in nature, and doesn't affect the
operation of TIPC.

Signed-off-by: Allan Stephens <allan.stephens@windriver.com>
Signed-off-by: Paul Gortmaker <paul.gortmaker@windriver.com>
---
 net/tipc/name_distr.c |    4 ++--
 net/tipc/net.c        |   22 ++++++++++++----------
 net/tipc/net.h        |   17 +++--------------
 net/tipc/node.c       |   30 +++++++++++++++---------------
 net/tipc/node.h       |    2 +-
 5 files changed, 33 insertions(+), 42 deletions(-)

diff --git a/net/tipc/name_distr.c b/net/tipc/name_distr.c
index d58dae7..f2086f6 100644
--- a/net/tipc/name_distr.c
+++ b/net/tipc/name_distr.c
@@ -111,8 +111,8 @@ static void named_cluster_distribute(struct sk_buff *buf)
 	struct tipc_node *n_ptr;
 	u32 n_num;
 
-	for (n_num = 1; n_num <= tipc_net.highest_node; n_num++) {
-		n_ptr = tipc_net.nodes[n_num];
+	for (n_num = 1; n_num <= tipc_highest_node; n_num++) {
+		n_ptr = tipc_nodes[n_num];
 		if (n_ptr && tipc_node_has_active_links(n_ptr)) {
 			buf_copy = skb_copy(buf, GFP_ATOMIC);
 			if (!buf_copy)
diff --git a/net/tipc/net.c b/net/tipc/net.c
index dd78d86..f6303d7 100644
--- a/net/tipc/net.c
+++ b/net/tipc/net.c
@@ -108,26 +108,28 @@
 */
 
 DEFINE_RWLOCK(tipc_net_lock);
-struct network tipc_net;
+struct tipc_node **tipc_nodes;
+u32 tipc_highest_node;
+atomic_t tipc_num_links;
 
 static int net_start(void)
 {
-	tipc_net.nodes = kcalloc(tipc_max_nodes + 1,
-				 sizeof(*tipc_net.nodes), GFP_ATOMIC);
-	tipc_net.highest_node = 0;
-	atomic_set(&tipc_net.links, 0);
+	tipc_nodes = kcalloc(tipc_max_nodes + 1,
+				 sizeof(*tipc_nodes), GFP_ATOMIC);
+	tipc_highest_node = 0;
+	atomic_set(&tipc_num_links, 0);
 
-	return tipc_net.nodes ? 0 : -ENOMEM;
+	return tipc_nodes ? 0 : -ENOMEM;
 }
 
 static void net_stop(void)
 {
 	u32 n_num;
 
-	for (n_num = 1; n_num <= tipc_net.highest_node; n_num++)
-		tipc_node_delete(tipc_net.nodes[n_num]);
-	kfree(tipc_net.nodes);
-	tipc_net.nodes = NULL;
+	for (n_num = 1; n_num <= tipc_highest_node; n_num++)
+		tipc_node_delete(tipc_nodes[n_num]);
+	kfree(tipc_nodes);
+	tipc_nodes = NULL;
 }
 
 static void net_route_named_msg(struct sk_buff *buf)
diff --git a/net/tipc/net.h b/net/tipc/net.h
index aa431ef..b52b974 100644
--- a/net/tipc/net.h
+++ b/net/tipc/net.h
@@ -39,21 +39,10 @@
 
 struct tipc_node;
 
-/**
- * struct network - TIPC network structure
- * @nodes: array of pointers to all nodes within cluster
- * @highest_node: id of highest numbered node within cluster
- * @links: number of (unicast) links to cluster
- */
-
-struct network {
-	struct tipc_node **nodes;
-	u32 highest_node;
-	atomic_t links;
-};
-
+extern struct tipc_node **tipc_nodes;
+extern u32 tipc_highest_node;
+extern atomic_t tipc_num_links;
 
-extern struct network tipc_net;
 extern rwlock_t tipc_net_lock;
 
 void tipc_net_route_msg(struct sk_buff *buf);
diff --git a/net/tipc/node.c b/net/tipc/node.c
index a24fad3..64976f2 100644
--- a/net/tipc/node.c
+++ b/net/tipc/node.c
@@ -81,9 +81,9 @@ struct tipc_node *tipc_node_create(u32 addr)
 	INIT_LIST_HEAD(&n_ptr->nsub);
 
 	n_num = tipc_node(addr);
-	tipc_net.nodes[n_num] = n_ptr;
-	if (n_num > tipc_net.highest_node)
-		tipc_net.highest_node = n_num;
+	tipc_nodes[n_num] = n_ptr;
+	if (n_num > tipc_highest_node)
+		tipc_highest_node = n_num;
 
 	spin_unlock_bh(&node_create_lock);
 	return n_ptr;
@@ -97,11 +97,11 @@ void tipc_node_delete(struct tipc_node *n_ptr)
 		return;
 
 	n_num = tipc_node(n_ptr->addr);
-	tipc_net.nodes[n_num] = NULL;
+	tipc_nodes[n_num] = NULL;
 	kfree(n_ptr);
 
-	while (!tipc_net.nodes[tipc_net.highest_node])
-		if (--tipc_net.highest_node == 0)
+	while (!tipc_nodes[tipc_highest_node])
+		if (--tipc_highest_node == 0)
 			break;
 }
 
@@ -233,7 +233,7 @@ struct tipc_node *tipc_node_attach_link(struct link *l_ptr)
 
 		if (!n_ptr->links[bearer_id]) {
 			n_ptr->links[bearer_id] = l_ptr;
-			atomic_inc(&tipc_net.links);
+			atomic_inc(&tipc_num_links);
 			n_ptr->link_cnt++;
 			return n_ptr;
 		}
@@ -247,7 +247,7 @@ struct tipc_node *tipc_node_attach_link(struct link *l_ptr)
 void tipc_node_detach_link(struct tipc_node *n_ptr, struct link *l_ptr)
 {
 	n_ptr->links[l_ptr->b_ptr->identity] = NULL;
-	atomic_dec(&tipc_net.links);
+	atomic_dec(&tipc_num_links);
 	n_ptr->link_cnt--;
 }
 
@@ -390,7 +390,7 @@ struct sk_buff *tipc_node_get_nodes(const void *req_tlv_area, int req_tlv_space)
 						   " (network address)");
 
 	read_lock_bh(&tipc_net_lock);
-	if (!tipc_net.nodes) {
+	if (!tipc_nodes) {
 		read_unlock_bh(&tipc_net_lock);
 		return tipc_cfg_reply_none();
 	}
@@ -398,7 +398,7 @@ struct sk_buff *tipc_node_get_nodes(const void *req_tlv_area, int req_tlv_space)
 	/* For now, get space for all other nodes */
 
 	payload_size = TLV_SPACE(sizeof(node_info)) *
-		(tipc_net.highest_node - 1);
+		(tipc_highest_node - 1);
 	if (payload_size > 32768u) {
 		read_unlock_bh(&tipc_net_lock);
 		return tipc_cfg_reply_error_string(TIPC_CFG_NOT_SUPPORTED
@@ -412,8 +412,8 @@ struct sk_buff *tipc_node_get_nodes(const void *req_tlv_area, int req_tlv_space)
 
 	/* Add TLVs for all nodes in scope */
 
-	for (n_num = 1; n_num <= tipc_net.highest_node; n_num++) {
-		n_ptr = tipc_net.nodes[n_num];
+	for (n_num = 1; n_num <= tipc_highest_node; n_num++) {
+		n_ptr = tipc_nodes[n_num];
 		if (!n_ptr || !tipc_in_scope(domain, n_ptr->addr))
 			continue;
 		node_info.addr = htonl(n_ptr->addr);
@@ -451,7 +451,7 @@ struct sk_buff *tipc_node_get_links(const void *req_tlv_area, int req_tlv_space)
 	/* Get space for all unicast links + multicast link */
 
 	payload_size = TLV_SPACE(sizeof(link_info)) *
-		(atomic_read(&tipc_net.links) + 1);
+		(atomic_read(&tipc_num_links) + 1);
 	if (payload_size > 32768u) {
 		read_unlock_bh(&tipc_net_lock);
 		return tipc_cfg_reply_error_string(TIPC_CFG_NOT_SUPPORTED
@@ -472,10 +472,10 @@ struct sk_buff *tipc_node_get_links(const void *req_tlv_area, int req_tlv_space)
 
 	/* Add TLVs for any other links in scope */
 
-	for (n_num = 1; n_num <= tipc_net.highest_node; n_num++) {
+	for (n_num = 1; n_num <= tipc_highest_node; n_num++) {
 		u32 i;
 
-		n_ptr = tipc_net.nodes[n_num];
+		n_ptr = tipc_nodes[n_num];
 		if (!n_ptr || !tipc_in_scope(domain, n_ptr->addr))
 			continue;
 		tipc_node_lock(n_ptr);
diff --git a/net/tipc/node.h b/net/tipc/node.h
index 206a8ef..c510a2a 100644
--- a/net/tipc/node.h
+++ b/net/tipc/node.h
@@ -107,7 +107,7 @@ struct sk_buff *tipc_node_get_nodes(const void *req_tlv_area, int req_tlv_space)
 static inline struct tipc_node *tipc_node_find(u32 addr)
 {
 	if (likely(in_own_cluster(addr)))
-		return tipc_net.nodes[tipc_node(addr)];
+		return tipc_nodes[tipc_node(addr)];
 	return NULL;
 }
 
-- 
1.7.3.3


  parent reply	other threads:[~2011-03-13 21:34 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-03-13 21:33 [PATCH net-next 00/26] tipc: Yet another mixed bag of updates Paul Gortmaker
2011-03-13 21:33 ` [PATCH net-next 01/26] tipc: Allow receiving into iovec containing multiple entries Paul Gortmaker
2011-03-13 21:33 ` [PATCH net-next 02/26] tipc: Correct broadcast link peer info when displaying links Paul Gortmaker
2011-03-13 21:33 ` [PATCH net-next 03/26] tipc: Add network address mask helper routines Paul Gortmaker
2011-03-13 21:33 ` [PATCH net-next 04/26] tipc: Prevent null pointer error when removing a node subscription Paul Gortmaker
2011-03-13 21:33 ` [PATCH net-next 05/26] tipc: Cosmetic changes to node subscription code Paul Gortmaker
2011-03-13 21:33 ` [PATCH net-next 06/26] tipc: Add support for SO_RCVTIMEO socket option Paul Gortmaker
2011-03-13 21:33 ` [PATCH net-next 07/26] tipc: Fix problem with missing link in "tipc-config -l" output Paul Gortmaker
2011-03-13 21:33 ` Paul Gortmaker [this message]
2011-03-13 21:33 ` [PATCH net-next 09/26] tipc: Eliminate configuration for maximum number of cluster nodes Paul Gortmaker
2011-03-13 21:33 ` [PATCH net-next 10/26] tipc: Convert node object array to a hash table Paul Gortmaker
2011-03-13 21:33 ` [PATCH net-next 11/26] tipc: manually inline net_start/stop, make assoc. vars static Paul Gortmaker
2011-03-13 21:34 ` [PATCH net-next 12/26] tipc: Eliminate timestamp from link protocol messages Paul Gortmaker
2011-03-13 21:34 ` [PATCH net-next 13/26] tipc: cosmetic - function names are not to be full sentences Paul Gortmaker
2011-03-13 21:34 ` [PATCH net-next 14/26] tipc: make msg_set_redundant_link() consistent with other set ops Paul Gortmaker
2011-03-13 21:34 ` [PATCH net-next 15/26] tipc: Fix redundant link field handling in link protocol message Paul Gortmaker
2011-03-13 21:34 ` [PATCH net-next 16/26] tipc: Cosmetic changes to neighbor discovery logic Paul Gortmaker
2011-03-13 21:34 ` [PATCH net-next 17/26] tipc: Give Tx of discovery responses priority over link messages Paul Gortmaker
2011-03-13 21:34 ` [PATCH net-next 18/26] tipc: Optimizations to link creation code Paul Gortmaker
2011-03-13 21:34 ` [PATCH net-next 19/26] tipc: Correct misnamed references to neighbor discovery domain Paul Gortmaker
2011-03-13 21:34 ` [PATCH net-next 20/26] tipc: Remove unused field in bearer structure Paul Gortmaker
2011-03-13 21:34 ` [PATCH net-next 21/26] tipc: Eliminate unnecessary constant for neighbor discovery msg size Paul Gortmaker
2011-03-13 21:34 ` [PATCH net-next 22/26] tipc: Don't respond to neighbor discovery request on blocked bearer Paul Gortmaker
2011-03-13 21:34 ` [PATCH net-next 23/26] tipc: Remove bearer flag indicating existence of broadcast address Paul Gortmaker
2011-03-13 21:34 ` [PATCH net-next 24/26] tipc: Eliminate remaining support for routing table messages Paul Gortmaker
2011-03-13 21:34 ` [PATCH net-next 25/26] tipc: Eliminate obsolete routine for handling routed messages Paul Gortmaker
2011-03-13 21:34 ` [PATCH net-next 26/26] tipc: Update maintenance information Paul Gortmaker
2011-03-14  1:53 ` [PATCH net-next 00/26] tipc: Yet another mixed bag of updates David Miller

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1300052054-7531-9-git-send-email-paul.gortmaker@windriver.com \
    --to=paul.gortmaker@windriver.com \
    --cc=Allan.Stephens@windriver.com \
    --cc=davem@davemloft.net \
    --cc=netdev@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).