From: Allan Stephens <allan.stephens@windriver.com>
To: David Miller <davem@davemloft.net>
Cc: netdev@vger.kernel.org, allan.stephens@windriver.com
Subject: [PATCH 2/5 net-next-2.6] [TIPC]: Add support for customized subscription endianness
Date: Tue, 13 May 2008 14:17:42 -0400 [thread overview]
Message-ID: <1210702665-5012-3-git-send-email-allan.stephens@windriver.com> (raw)
In-Reply-To: <1210702665-5012-1-git-send-email-allan.stephens@windriver.com>
This patch enables TIPC's topology server code to do customized
endianness conversions on a per-subscription basis. (This
capability is needed to support the upcoming consolidation of
subscriber and subscription object references.)
Signed-off-by: Allan Stephens <allan.stephens@windriver.com>
---
net/tipc/subscr.c | 35 ++++++++++++++++-------------------
net/tipc/subscr.h | 2 ++
2 files changed, 18 insertions(+), 19 deletions(-)
diff --git a/net/tipc/subscr.c b/net/tipc/subscr.c
index 81e2bd5..a62e5d3 100644
--- a/net/tipc/subscr.c
+++ b/net/tipc/subscr.c
@@ -47,7 +47,6 @@
* @subscriber_list: adjacent subscribers in top. server's list of subscribers
* @subscription_list: list of subscription objects for this subscriber
* @port_ref: object reference to port used to communicate with subscriber
- * @swap: indicates if subscriber uses opposite endianness in its messages
*/
struct subscriber {
@@ -56,7 +55,6 @@ struct subscriber {
struct list_head subscriber_list;
struct list_head subscription_list;
u32 port_ref;
- int swap;
};
/**
@@ -109,11 +107,11 @@ static void subscr_send_event(struct subscription *sub,
msg_sect.iov_base = (void *)&sub->evt;
msg_sect.iov_len = sizeof(struct tipc_event);
- sub->evt.event = htohl(event, sub->owner->swap);
- sub->evt.found_lower = htohl(found_lower, sub->owner->swap);
- sub->evt.found_upper = htohl(found_upper, sub->owner->swap);
- sub->evt.port.ref = htohl(port_ref, sub->owner->swap);
- sub->evt.port.node = htohl(node, sub->owner->swap);
+ sub->evt.event = htohl(event, sub->swap);
+ sub->evt.found_lower = htohl(found_lower, sub->swap);
+ sub->evt.found_upper = htohl(found_upper, sub->swap);
+ sub->evt.port.ref = htohl(port_ref, sub->swap);
+ sub->evt.port.node = htohl(node, sub->swap);
tipc_send(sub->owner->port_ref, 1, &msg_sect);
}
@@ -324,18 +322,16 @@ static void subscr_subscribe(struct tipc_subscr *s,
struct subscriber *subscriber)
{
struct subscription *sub;
+ int swap;
- /* Determine/update subscriber's endianness */
+ /* Determine subscriber's endianness */
- if (s->filter & (TIPC_SUB_PORTS | TIPC_SUB_SERVICE))
- subscriber->swap = 0;
- else
- subscriber->swap = 1;
+ swap = !(s->filter & (TIPC_SUB_PORTS | TIPC_SUB_SERVICE));
/* Detect & process a subscription cancellation request */
- if (s->filter & htohl(TIPC_SUB_CANCEL, subscriber->swap)) {
- s->filter &= ~htohl(TIPC_SUB_CANCEL, subscriber->swap);
+ if (s->filter & htohl(TIPC_SUB_CANCEL, swap)) {
+ s->filter &= ~htohl(TIPC_SUB_CANCEL, swap);
subscr_cancel(s, subscriber);
return;
}
@@ -360,11 +356,11 @@ static void subscr_subscribe(struct tipc_subscr *s,
/* Initialize subscription object */
- sub->seq.type = htohl(s->seq.type, subscriber->swap);
- sub->seq.lower = htohl(s->seq.lower, subscriber->swap);
- sub->seq.upper = htohl(s->seq.upper, subscriber->swap);
- sub->timeout = htohl(s->timeout, subscriber->swap);
- sub->filter = htohl(s->filter, subscriber->swap);
+ sub->seq.type = htohl(s->seq.type, swap);
+ sub->seq.lower = htohl(s->seq.lower, swap);
+ sub->seq.upper = htohl(s->seq.upper, swap);
+ sub->timeout = htohl(s->timeout, swap);
+ sub->filter = htohl(s->filter, swap);
if ((!(sub->filter & TIPC_SUB_PORTS)
== !(sub->filter & TIPC_SUB_SERVICE))
|| (sub->seq.lower > sub->seq.upper)) {
@@ -378,6 +374,7 @@ static void subscr_subscribe(struct tipc_subscr *s,
INIT_LIST_HEAD(&sub->subscription_list);
INIT_LIST_HEAD(&sub->nameseq_list);
list_add(&sub->subscription_list, &subscriber->subscription_list);
+ sub->swap = swap;
atomic_inc(&topsrv.subscription_count);
if (sub->timeout != TIPC_WAIT_FOREVER) {
k_init_timer(&sub->timer,
diff --git a/net/tipc/subscr.h b/net/tipc/subscr.h
index d955368..3e3e026 100644
--- a/net/tipc/subscr.h
+++ b/net/tipc/subscr.h
@@ -49,6 +49,7 @@ typedef void (*tipc_subscr_event) (struct subscription *sub,
* @timeout: duration of subscription (in ms)
* @filter: event filtering to be done for subscription
* @event_cb: routine invoked when a subscription event is detected
+ * @swap: indicates if subscriber uses opposite endianness in its messages
* @evt: template for events generated by subscription
* @subscription_list: adjacent subscriptions in subscriber's subscription list
* @nameseq_list: adjacent subscriptions in name sequence's subscription list
@@ -61,6 +62,7 @@ struct subscription {
u32 timeout;
u32 filter;
tipc_subscr_event event_cb;
+ int swap;
struct tipc_event evt;
struct list_head subscription_list;
struct list_head nameseq_list;
--
1.5.3.2
next prev parent reply other threads:[~2008-05-13 18:18 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-05-13 18:17 [PATCH 0/5 net-next-2.6] [TIPC]: Network topology server modifications Allan Stephens
2008-05-13 18:17 ` [PATCH 1/5 net-next-2.6] [TIPC]: Add support for customized subscription overlap handling Allan Stephens
2008-05-19 20:30 ` David Miller
2008-05-13 18:17 ` Allan Stephens [this message]
2008-05-19 20:30 ` [PATCH 2/5 net-next-2.6] [TIPC]: Add support for customized subscription endianness David Miller
2008-05-13 18:17 ` [PATCH 3/5 net-next-2.6] [TIPC]: Fix bug in topology server byte swapping routine Allan Stephens
2008-05-19 20:30 ` David Miller
2008-05-13 18:17 ` [PATCH 4/5 net-next-2.6] [TIPC]: Consolidate subscriber & subscriber port references Allan Stephens
2008-05-19 20:30 ` David Miller
2008-05-13 18:17 ` [PATCH 5/5 net-next-2.6] [TIPC]: Cosmetic cleanup of topology service code Allan Stephens
2008-05-19 20:30 ` 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=1210702665-5012-3-git-send-email-allan.stephens@windriver.com \
--to=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).