Skip to content

Commit

Permalink
tipc: Hide internal details of node table implementation
Browse files Browse the repository at this point in the history
Relocates information about the size of TIPC's node table index and
its associated hash function, since only node subsystem routines need
to have access to this information.

Note that these changes are essentially cosmetic in nature, and have
no impact on the actual operation of TIPC.

Signed-off-by: Allan Stephens <allan.stephens@windriver.com>
Signed-off-by: Paul Gortmaker <paul.gortmaker@windriver.com>
  • Loading branch information
Allan Stephens authored and Paul Gortmaker committed Feb 24, 2012
1 parent 9efde4a commit a635b46
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 12 deletions.
13 changes: 13 additions & 0 deletions net/tipc/node.c
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@
#include "node.h"
#include "name_distr.h"

#define NODE_HTABLE_SIZE 512

static void node_lost_contact(struct tipc_node *n_ptr);
static void node_established_contact(struct tipc_node *n_ptr);

Expand All @@ -50,6 +52,17 @@ static u32 tipc_num_nodes;

static atomic_t tipc_num_links = ATOMIC_INIT(0);

/*
* A trivial power-of-two bitmask technique is used for speed, since this
* operation is done for every incoming TIPC packet. The number of hash table
* entries has been chosen so that no hash chain exceeds 8 nodes and will
* usually be much smaller (typically only a single node).
*/
static inline unsigned int tipc_hashfn(u32 addr)
{
return addr & (NODE_HTABLE_SIZE - 1);
}

/*
* tipc_node_find - locate specified node object, if it exists
*/
Expand Down
12 changes: 0 additions & 12 deletions net/tipc/node.h
Original file line number Diff line number Diff line change
Expand Up @@ -107,20 +107,8 @@ struct tipc_node {
} bclink;
};

#define NODE_HTABLE_SIZE 512
extern struct list_head tipc_node_list;

/*
* A trivial power-of-two bitmask technique is used for speed, since this
* operation is done for every incoming TIPC packet. The number of hash table
* entries has been chosen so that no hash chain exceeds 8 nodes and will
* usually be much smaller (typically only a single node).
*/
static inline unsigned int tipc_hashfn(u32 addr)
{
return addr & (NODE_HTABLE_SIZE - 1);
}

struct tipc_node *tipc_node_find(u32 addr);
struct tipc_node *tipc_node_create(u32 addr);
void tipc_node_delete(struct tipc_node *n_ptr);
Expand Down

0 comments on commit a635b46

Please sign in to comment.