Skip to content

Commit

Permalink
Merge branch 'tipc-Sep17-2011' of git://openlinux.windriver.com/peopl…
Browse files Browse the repository at this point in the history
…e/paulg/net-next
  • Loading branch information
David S. Miller committed Sep 20, 2011
2 parents 653fc91 + 94362c7 commit 46151ae
Show file tree
Hide file tree
Showing 16 changed files with 239 additions and 197 deletions.
111 changes: 52 additions & 59 deletions net/tipc/bcast.c
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
#include "link.h"
#include "port.h"
#include "bcast.h"
#include "name_distr.h"

#define MAX_PKT_DEFAULT_MCAST 1500 /* bcast link max packet size (fixed) */

Expand Down Expand Up @@ -298,14 +299,9 @@ static void bclink_send_nack(struct tipc_node *n_ptr)
msg_set_bcgap_to(msg, n_ptr->bclink.gap_to);
msg_set_bcast_tag(msg, tipc_own_tag);

if (tipc_bearer_send(&bcbearer->bearer, buf, NULL)) {
bcl->stats.sent_nacks++;
buf_discard(buf);
} else {
tipc_bearer_schedule(bcl->b_ptr, bcl);
bcl->proto_msg_queue = buf;
bcl->stats.bearer_congs++;
}
tipc_bearer_send(&bcbearer->bearer, buf, NULL);
bcl->stats.sent_nacks++;
buf_discard(buf);

/*
* Ensure we doesn't send another NACK msg to the node
Expand Down Expand Up @@ -426,20 +422,28 @@ int tipc_bclink_send_msg(struct sk_buff *buf)
void tipc_bclink_recv_pkt(struct sk_buff *buf)
{
struct tipc_msg *msg = buf_msg(buf);
struct tipc_node *node = tipc_node_find(msg_prevnode(msg));
struct tipc_node *node;
u32 next_in;
u32 seqno;
struct sk_buff *deferred;

if (unlikely(!node || !tipc_node_is_up(node) || !node->bclink.supported ||
(msg_mc_netid(msg) != tipc_net_id))) {
buf_discard(buf);
return;
}
/* Screen out unwanted broadcast messages */

if (msg_mc_netid(msg) != tipc_net_id)
goto exit;

node = tipc_node_find(msg_prevnode(msg));
if (unlikely(!node))
goto exit;

tipc_node_lock(node);
if (unlikely(!node->bclink.supported))
goto unlock;

if (unlikely(msg_user(msg) == BCAST_PROTOCOL)) {
if (msg_type(msg) != STATE_MSG)
goto unlock;
if (msg_destnode(msg) == tipc_own_addr) {
tipc_node_lock(node);
tipc_bclink_acknowledge(node, msg_bcast_ack(msg));
tipc_node_unlock(node);
spin_lock_bh(&bc_lock);
Expand All @@ -449,18 +453,18 @@ void tipc_bclink_recv_pkt(struct sk_buff *buf)
msg_bcgap_to(msg));
spin_unlock_bh(&bc_lock);
} else {
tipc_node_unlock(node);
tipc_bclink_peek_nack(msg_destnode(msg),
msg_bcast_tag(msg),
msg_bcgap_after(msg),
msg_bcgap_to(msg));
}
buf_discard(buf);
return;
goto exit;
}

tipc_node_lock(node);
/* Handle in-sequence broadcast message */

receive:
deferred = node->bclink.deferred_head;
next_in = mod(node->bclink.last_in + 1);
seqno = msg_seqno(msg);

Expand All @@ -474,7 +478,10 @@ void tipc_bclink_recv_pkt(struct sk_buff *buf)
}
if (likely(msg_isdata(msg))) {
tipc_node_unlock(node);
tipc_port_recv_mcast(buf, NULL);
if (likely(msg_mcast(msg)))
tipc_port_recv_mcast(buf, NULL);
else
buf_discard(buf);
} else if (msg_user(msg) == MSG_BUNDLER) {
bcl->stats.recv_bundles++;
bcl->stats.recv_bundled += msg_msgcnt(msg);
Expand All @@ -487,18 +494,22 @@ void tipc_bclink_recv_pkt(struct sk_buff *buf)
bcl->stats.recv_fragmented++;
tipc_node_unlock(node);
tipc_net_route_msg(buf);
} else if (msg_user(msg) == NAME_DISTRIBUTOR) {
tipc_node_unlock(node);
tipc_named_recv(buf);
} else {
tipc_node_unlock(node);
tipc_net_route_msg(buf);
buf_discard(buf);
}
buf = NULL;
tipc_node_lock(node);
deferred = node->bclink.deferred_head;
if (deferred && (buf_seqno(deferred) == mod(next_in + 1))) {
tipc_node_lock(node);
buf = deferred;
msg = buf_msg(buf);
node->bclink.deferred_head = deferred->next;
goto receive;
}
return;
} else if (less(next_in, seqno)) {
u32 gap_after = node->bclink.gap_after;
u32 gap_to = node->bclink.gap_to;
Expand All @@ -513,16 +524,19 @@ void tipc_bclink_recv_pkt(struct sk_buff *buf)
else if (less(gap_after, seqno) && less(seqno, gap_to))
node->bclink.gap_to = seqno;
}
buf = NULL;
if (bclink_ack_allowed(node->bclink.nack_sync)) {
if (gap_to != gap_after)
bclink_send_nack(node);
bclink_set_gap(node);
}
} else {
bcl->stats.duplicates++;
buf_discard(buf);
}
unlock:
tipc_node_unlock(node);
exit:
buf_discard(buf);
}

u32 tipc_bclink_acks_missing(struct tipc_node *n_ptr)
Expand All @@ -535,10 +549,11 @@ u32 tipc_bclink_acks_missing(struct tipc_node *n_ptr)
/**
* tipc_bcbearer_send - send a packet through the broadcast pseudo-bearer
*
* Send through as many bearers as necessary to reach all nodes
* that support TIPC multicasting.
* Send packet over as many bearers as necessary to reach all nodes
* that have joined the broadcast link.
*
* Returns 0 if packet sent successfully, non-zero if not
* Returns 0 (packet sent successfully) under all circumstances,
* since the broadcast link's pseudo-bearer never blocks
*/

static int tipc_bcbearer_send(struct sk_buff *buf,
Expand All @@ -547,7 +562,12 @@ static int tipc_bcbearer_send(struct sk_buff *buf,
{
int bp_index;

/* Prepare buffer for broadcasting (if first time trying to send it) */
/*
* Prepare broadcast link message for reliable transmission,
* if first time trying to send it;
* preparation is skipped for broadcast link protocol messages
* since they are sent in an unreliable manner and don't need it
*/

if (likely(!msg_non_seq(buf_msg(buf)))) {
struct tipc_msg *msg;
Expand Down Expand Up @@ -596,18 +616,12 @@ static int tipc_bcbearer_send(struct sk_buff *buf,
}

if (bcbearer->remains_new.count == 0)
return 0;
break; /* all targets reached */

bcbearer->remains = bcbearer->remains_new;
}

/*
* Unable to reach all targets (indicate success, since currently
* there isn't code in place to properly block & unblock the
* pseudo-bearer used by the broadcast link)
*/

return TIPC_OK;
return 0;
}

/**
Expand Down Expand Up @@ -667,27 +681,6 @@ void tipc_bcbearer_sort(void)
spin_unlock_bh(&bc_lock);
}

/**
* tipc_bcbearer_push - resolve bearer congestion
*
* Forces bclink to push out any unsent packets, until all packets are gone
* or congestion reoccurs.
* No locks set when function called
*/

void tipc_bcbearer_push(void)
{
struct tipc_bearer *b_ptr;

spin_lock_bh(&bc_lock);
b_ptr = &bcbearer->bearer;
if (b_ptr->blocked) {
b_ptr->blocked = 0;
tipc_bearer_lock_push(b_ptr);
}
spin_unlock_bh(&bc_lock);
}


int tipc_bclink_stats(char *buf, const u32 buf_size)
{
Expand Down Expand Up @@ -764,7 +757,7 @@ int tipc_bclink_init(void)
bcbearer = kzalloc(sizeof(*bcbearer), GFP_ATOMIC);
bclink = kzalloc(sizeof(*bclink), GFP_ATOMIC);
if (!bcbearer || !bclink) {
warn("Multicast link creation failed, no memory\n");
warn("Broadcast link creation failed, no memory\n");
kfree(bcbearer);
bcbearer = NULL;
kfree(bclink);
Expand All @@ -775,7 +768,7 @@ int tipc_bclink_init(void)
INIT_LIST_HEAD(&bcbearer->bearer.cong_links);
bcbearer->bearer.media = &bcbearer->media;
bcbearer->media.send_msg = tipc_bcbearer_send;
sprintf(bcbearer->media.name, "tipc-multicast");
sprintf(bcbearer->media.name, "tipc-broadcast");

bcl = &bclink->link;
INIT_LIST_HEAD(&bcl->waiting_ports);
Expand Down
1 change: 0 additions & 1 deletion net/tipc/bcast.h
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,5 @@ int tipc_bclink_stats(char *stats_buf, const u32 buf_size);
int tipc_bclink_reset_stats(void);
int tipc_bclink_set_queue_limits(u32 limit);
void tipc_bcbearer_sort(void);
void tipc_bcbearer_push(void);

#endif
8 changes: 3 additions & 5 deletions net/tipc/bearer.c
Original file line number Diff line number Diff line change
Expand Up @@ -385,13 +385,9 @@ static int bearer_push(struct tipc_bearer *b_ptr)

void tipc_bearer_lock_push(struct tipc_bearer *b_ptr)
{
int res;

spin_lock_bh(&b_ptr->lock);
res = bearer_push(b_ptr);
bearer_push(b_ptr);
spin_unlock_bh(&b_ptr->lock);
if (res)
tipc_bcbearer_push();
}


Expand Down Expand Up @@ -608,6 +604,7 @@ int tipc_block_bearer(const char *name)
info("Blocking bearer <%s>\n", name);
spin_lock_bh(&b_ptr->lock);
b_ptr->blocked = 1;
list_splice_init(&b_ptr->cong_links, &b_ptr->links);
list_for_each_entry_safe(l_ptr, temp_l_ptr, &b_ptr->links, link_list) {
struct tipc_node *n_ptr = l_ptr->owner;

Expand Down Expand Up @@ -635,6 +632,7 @@ static void bearer_disable(struct tipc_bearer *b_ptr)
spin_lock_bh(&b_ptr->lock);
b_ptr->blocked = 1;
b_ptr->media->disable_bearer(b_ptr);
list_splice_init(&b_ptr->cong_links, &b_ptr->links);
list_for_each_entry_safe(l_ptr, temp_l_ptr, &b_ptr->links, link_list) {
tipc_link_delete(l_ptr);
}
Expand Down
4 changes: 2 additions & 2 deletions net/tipc/bearer.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@

#include "bcast.h"

#define MAX_BEARERS 8
#define MAX_MEDIA 4
#define MAX_BEARERS 2
#define MAX_MEDIA 2

/*
* Identifiers of supported TIPC media types
Expand Down
1 change: 0 additions & 1 deletion net/tipc/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@ struct sk_buff *tipc_cfg_do_cmd(u32 orig_node, u16 cmd,
const void *req_tlv_area, int req_tlv_space,
int headroom);

void tipc_cfg_link_event(u32 addr, char *name, int up);
int tipc_cfg_init(void);
void tipc_cfg_stop(void);

Expand Down
6 changes: 0 additions & 6 deletions net/tipc/discover.c
Original file line number Diff line number Diff line change
Expand Up @@ -159,12 +159,6 @@ void tipc_disc_recv_msg(struct sk_buff *buf, struct tipc_bearer *b_ptr)
}
tipc_node_lock(n_ptr);

/* Don't talk to neighbor during cleanup after last session */
if (n_ptr->cleanup_required) {
tipc_node_unlock(n_ptr);
return;
}

link = n_ptr->links[b_ptr->identity];

/* Create a link endpoint for this bearer, if necessary */
Expand Down
32 changes: 14 additions & 18 deletions net/tipc/eth_media.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* net/tipc/eth_media.c: Ethernet bearer support for TIPC
*
* Copyright (c) 2001-2007, Ericsson AB
* Copyright (c) 2005-2007, Wind River Systems
* Copyright (c) 2005-2008, 2011, Wind River Systems
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
Expand Down Expand Up @@ -37,7 +37,7 @@
#include "core.h"
#include "bearer.h"

#define MAX_ETH_BEARERS 2
#define MAX_ETH_BEARERS MAX_BEARERS
#define ETH_LINK_PRIORITY TIPC_DEF_LINK_PRI
#define ETH_LINK_TOLERANCE TIPC_DEF_LINK_TOL
#define ETH_LINK_WINDOW TIPC_DEF_LINK_WIN
Expand Down Expand Up @@ -144,31 +144,27 @@ static int enable_bearer(struct tipc_bearer *tb_ptr)

/* Find device with specified name */

read_lock(&dev_base_lock);
for_each_netdev(&init_net, pdev) {
if (!strncmp(pdev->name, driver_name, IFNAMSIZ)) {
dev = pdev;
dev_hold(dev);
break;
}
}
read_unlock(&dev_base_lock);
if (!dev)
return -ENODEV;

/* Find Ethernet bearer for device (or create one) */

while ((eb_ptr != stop) && eb_ptr->dev && (eb_ptr->dev != dev))
eb_ptr++;
if (eb_ptr == stop)
return -EDQUOT;
if (!eb_ptr->dev) {
eb_ptr->dev = dev;
eb_ptr->tipc_packet_type.type = htons(ETH_P_TIPC);
eb_ptr->tipc_packet_type.dev = dev;
eb_ptr->tipc_packet_type.func = recv_msg;
eb_ptr->tipc_packet_type.af_packet_priv = eb_ptr;
INIT_LIST_HEAD(&(eb_ptr->tipc_packet_type.list));
dev_hold(dev);
dev_add_pack(&eb_ptr->tipc_packet_type);
}
/* Create Ethernet bearer for device */

eb_ptr->dev = dev;
eb_ptr->tipc_packet_type.type = htons(ETH_P_TIPC);
eb_ptr->tipc_packet_type.dev = dev;
eb_ptr->tipc_packet_type.func = recv_msg;
eb_ptr->tipc_packet_type.af_packet_priv = eb_ptr;
INIT_LIST_HEAD(&(eb_ptr->tipc_packet_type.list));
dev_add_pack(&eb_ptr->tipc_packet_type);

/* Associate TIPC bearer with Ethernet bearer */

Expand Down
Loading

0 comments on commit 46151ae

Please sign in to comment.