]> git.proxmox.com Git - mirror_ubuntu-kernels.git/commitdiff
tipc: Add support for customized subscription endianness
authorAllan Stephens <allan.stephens@windriver.com>
Mon, 19 May 2008 20:28:32 +0000 (13:28 -0700)
committerDavid S. Miller <davem@davemloft.net>
Mon, 19 May 2008 20:28:32 +0000 (13:28 -0700)
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>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/tipc/subscr.c
net/tipc/subscr.h

index 81e2bd5f2413819da3d2b0c84cb5627e87ceadc3..a62e5d30638c1651aec0183a54d99087497e9e44 100644 (file)
@@ -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,
index d9553683290793b1dda7982fef9202cf7c68a0ed..3e3e0265146eeb566d3731f400110b59c3c3989b 100644 (file)
@@ -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;