]> err.no Git - linux-2.6/commitdiff
[TIPC] Updated link priority macros
authorPer Liden <per.liden@nospam.ericsson.com>
Fri, 13 Jan 2006 21:22:22 +0000 (22:22 +0100)
committerPer Liden <per.liden@ericsson.com>
Tue, 17 Jan 2006 23:45:15 +0000 (00:45 +0100)
Added macros for min/default/max link priority in tipc_config.h.
Also renamed TIPC_NUM_LINK_PRI to TIPC_MEDIA_LINK_PRI since that
is a more accurate description of what it is used for.

Signed-off-by: Per Liden <per.liden@ericsson.com>
include/linux/tipc_config.h
net/tipc/bcast.c
net/tipc/bearer.c
net/tipc/eth_media.c
net/tipc/link.c

index a52c8c64a5a3af1f23d0f36f72491f9d4a7a2855..33a653913d942fa35c263edf1d019f36f4e0f5b1 100644 (file)
 #define TIPC_MAX_LINK_NAME     60      /* format = Z.C.N:interface-Z.C.N:interface */
 
 /*
- * Link priority limits (range from 0 to # priorities - 1)
+ * Link priority limits (min, default, max, media default)
  */
 
-#define TIPC_NUM_LINK_PRI 32
+#define TIPC_MIN_LINK_PRI      0
+#define TIPC_DEF_LINK_PRI      10
+#define TIPC_MAX_LINK_PRI      31
+#define TIPC_MEDIA_LINK_PRI    (TIPC_MAX_LINK_PRI + 1)
 
 /*
  * Link tolerance limits (min, default, max), in ms
index 9713d622efb864c5b6ab069ff836b855704bc623..af9743a52d6c27fecc91f73021321d97e9bd76dc 100644 (file)
@@ -82,7 +82,7 @@ struct bcbearer {
        struct bearer bearer;
        struct media media;
        struct bcbearer_pair bpairs[MAX_BEARERS];
-       struct bcbearer_pair bpairs_temp[TIPC_NUM_LINK_PRI];
+       struct bcbearer_pair bpairs_temp[TIPC_MAX_LINK_PRI + 1];
 };
 
 /**
@@ -630,7 +630,7 @@ void bcbearer_sort(void)
        bp_curr = bcbearer->bpairs;
        memset(bcbearer->bpairs, 0, sizeof(bcbearer->bpairs));
 
-       for (pri = (TIPC_NUM_LINK_PRI - 1); pri >= 0; pri--) {
+       for (pri = TIPC_MAX_LINK_PRI; pri >= 0; pri--) {
 
                if (!bp_temp[pri].primary)
                        continue;
index 3dd19fdc5a2cf5a97fc7f68f03bd5a58794d8569..02b6cf6ab7a404e7105ed40d63a7179c9bd939ef 100644 (file)
@@ -119,7 +119,8 @@ int  tipc_register_media(u32 media_type,
                warn("Media registration error: no broadcast address supplied\n");
                goto exit;
        }
-       if (bearer_priority >= TIPC_NUM_LINK_PRI) {
+       if ((bearer_priority < TIPC_MIN_LINK_PRI) &&
+           (bearer_priority > TIPC_MAX_LINK_PRI)) {
                warn("Media registration error: priority %u\n", bearer_priority);
                goto exit;
        }
@@ -476,10 +477,15 @@ int tipc_enable_bearer(const char *name, u32 bcast_scope, u32 priority)
 
        if (tipc_mode != TIPC_NET_MODE)
                return -ENOPROTOOPT;
+
        if (!bearer_name_validate(name, &b_name) ||
            !addr_domain_valid(bcast_scope) ||
-           !in_scope(bcast_scope, tipc_own_addr) ||
-           (priority > TIPC_NUM_LINK_PRI))
+           !in_scope(bcast_scope, tipc_own_addr))
+               return -EINVAL;
+
+       if ((priority < TIPC_MIN_LINK_PRI ||
+            priority > TIPC_MAX_LINK_PRI) &&
+           (priority != TIPC_MEDIA_LINK_PRI))
                return -EINVAL;
 
        write_lock_bh(&net_lock);
@@ -491,7 +497,8 @@ int tipc_enable_bearer(const char *name, u32 bcast_scope, u32 priority)
                warn("No media <%s>\n", b_name.media_name);
                goto failed;
        }
-       if (priority == TIPC_NUM_LINK_PRI)
+
+       if (priority == TIPC_MEDIA_LINK_PRI)
                priority = m_ptr->priority;
 
 restart:
@@ -547,8 +554,8 @@ restart:
        }
        b_ptr->publ.lock = SPIN_LOCK_UNLOCKED;
        write_unlock_bh(&net_lock);
-       info("Enabled bearer <%s>, discovery domain %s\n",
-            name, addr_string_fill(addr_string, bcast_scope));
+       info("Enabled bearer <%s>, discovery domain %s, priority %u\n",
+            name, addr_string_fill(addr_string, bcast_scope), priority);
        return 0;
 failed:
        write_unlock_bh(&net_lock);
index 34d0462db3aa139d1c25d4ab734b015214eb7db7..2ab6c16280e63a44e0058f89dbb71ad08efaefbd 100644 (file)
@@ -42,9 +42,9 @@
 
 #define MAX_ETH_BEARERS                2
 #define TIPC_PROTOCOL          0x88ca
-#define ETH_LINK_PRIORITY      10
+#define ETH_LINK_PRIORITY      TIPC_DEF_LINK_PRI
 #define ETH_LINK_TOLERANCE     TIPC_DEF_LINK_TOL
-
+#define ETH_LINK_WINDOW                TIPC_DEF_LINK_WIN
 
 /**
  * struct eth_bearer - Ethernet bearer data structure
@@ -260,7 +260,7 @@ int eth_media_start(void)
        res = tipc_register_media(TIPC_MEDIA_TYPE_ETH, "eth",
                                  enable_bearer, disable_bearer, send_msg, 
                                  eth_addr2str, &bcast_addr, ETH_LINK_PRIORITY, 
-                                 ETH_LINK_TOLERANCE, TIPC_DEF_LINK_WIN);
+                                 ETH_LINK_TOLERANCE, ETH_LINK_WINDOW);
        if (res)
                return res;
 
index 7265f4be47664a29bc084b963c096695086ea64a..d1e1ae66464a26c1abd222cdb1a56daedec04803 100644 (file)
@@ -2812,7 +2812,8 @@ struct sk_buff *link_cmd_config(const void *req_tlv_area, int req_tlv_space,
                }
                break;
        case TIPC_CMD_SET_LINK_PRI: 
-               if (new_value < TIPC_NUM_LINK_PRI) {
+               if ((new_value >= TIPC_MIN_LINK_PRI) &&
+                   (new_value <= TIPC_MAX_LINK_PRI)) {
                        l_ptr->priority = new_value;
                        link_send_proto_msg(l_ptr, STATE_MSG, 
                                            0, 0, 0, new_value, 0);