aboutsummaryrefslogtreecommitdiffstats
path: root/net/tipc/msg.h
diff options
context:
space:
mode:
authorGlenn Elliott <gelliott@cs.unc.edu>2012-03-04 19:47:13 -0500
committerGlenn Elliott <gelliott@cs.unc.edu>2012-03-04 19:47:13 -0500
commitc71c03bda1e86c9d5198c5d83f712e695c4f2a1e (patch)
treeecb166cb3e2b7e2adb3b5e292245fefd23381ac8 /net/tipc/msg.h
parentea53c912f8a86a8567697115b6a0d8152beee5c8 (diff)
parent6a00f206debf8a5c8899055726ad127dbeeed098 (diff)
Merge branch 'mpi-master' into wip-k-fmlpwip-k-fmlp
Conflicts: litmus/sched_cedf.c
Diffstat (limited to 'net/tipc/msg.h')
-rw-r--r--net/tipc/msg.h328
1 files changed, 183 insertions, 145 deletions
diff --git a/net/tipc/msg.h b/net/tipc/msg.h
index 995d2da35b01..8452454731fa 100644
--- a/net/tipc/msg.h
+++ b/net/tipc/msg.h
@@ -2,7 +2,7 @@
2 * net/tipc/msg.h: Include file for TIPC message header routines 2 * net/tipc/msg.h: Include file for TIPC message header routines
3 * 3 *
4 * Copyright (c) 2000-2007, Ericsson AB 4 * Copyright (c) 2000-2007, Ericsson AB
5 * Copyright (c) 2005-2008, Wind River Systems 5 * Copyright (c) 2005-2008, 2010-2011, Wind River Systems
6 * All rights reserved. 6 * All rights reserved.
7 * 7 *
8 * Redistribution and use in source and binary forms, with or without 8 * Redistribution and use in source and binary forms, with or without
@@ -37,10 +37,37 @@
37#ifndef _TIPC_MSG_H 37#ifndef _TIPC_MSG_H
38#define _TIPC_MSG_H 38#define _TIPC_MSG_H
39 39
40#include "core.h" 40#include "bearer.h"
41
42/*
43 * Constants and routines used to read and write TIPC payload message headers
44 *
45 * Note: Some items are also used with TIPC internal message headers
46 */
41 47
42#define TIPC_VERSION 2 48#define TIPC_VERSION 2
43 49
50/*
51 * Payload message users are defined in TIPC's public API:
52 * - TIPC_LOW_IMPORTANCE
53 * - TIPC_MEDIUM_IMPORTANCE
54 * - TIPC_HIGH_IMPORTANCE
55 * - TIPC_CRITICAL_IMPORTANCE
56 */
57
58/*
59 * Payload message types
60 */
61
62#define TIPC_CONN_MSG 0
63#define TIPC_MCAST_MSG 1
64#define TIPC_NAMED_MSG 2
65#define TIPC_DIRECT_MSG 3
66
67/*
68 * Message header sizes
69 */
70
44#define SHORT_H_SIZE 24 /* Connected, in-cluster messages */ 71#define SHORT_H_SIZE 24 /* Connected, in-cluster messages */
45#define DIR_MSG_H_SIZE 32 /* Directly addressed messages */ 72#define DIR_MSG_H_SIZE 32 /* Directly addressed messages */
46#define LONG_H_SIZE 40 /* Named messages */ 73#define LONG_H_SIZE 40 /* Named messages */
@@ -52,20 +79,26 @@
52#define MAX_MSG_SIZE (MAX_H_SIZE + TIPC_MAX_USER_MSG_SIZE) 79#define MAX_MSG_SIZE (MAX_H_SIZE + TIPC_MAX_USER_MSG_SIZE)
53 80
54 81
55/* 82struct tipc_msg {
56 TIPC user data message header format, version 2 83 __be32 hdr[15];
84};
57 85
58 - Fundamental definitions available to privileged TIPC users
59 are located in tipc_msg.h.
60 - Remaining definitions available to TIPC internal users appear below.
61*/
62 86
87static inline u32 msg_word(struct tipc_msg *m, u32 pos)
88{
89 return ntohl(m->hdr[pos]);
90}
63 91
64static inline void msg_set_word(struct tipc_msg *m, u32 w, u32 val) 92static inline void msg_set_word(struct tipc_msg *m, u32 w, u32 val)
65{ 93{
66 m->hdr[w] = htonl(val); 94 m->hdr[w] = htonl(val);
67} 95}
68 96
97static inline u32 msg_bits(struct tipc_msg *m, u32 w, u32 pos, u32 mask)
98{
99 return (msg_word(m, w) >> pos) & mask;
100}
101
69static inline void msg_set_bits(struct tipc_msg *m, u32 w, 102static inline void msg_set_bits(struct tipc_msg *m, u32 w,
70 u32 pos, u32 mask, u32 val) 103 u32 pos, u32 mask, u32 val)
71{ 104{
@@ -104,7 +137,7 @@ static inline u32 msg_user(struct tipc_msg *m)
104 137
105static inline u32 msg_isdata(struct tipc_msg *m) 138static inline u32 msg_isdata(struct tipc_msg *m)
106{ 139{
107 return (msg_user(m) <= TIPC_CRITICAL_IMPORTANCE); 140 return msg_user(m) <= TIPC_CRITICAL_IMPORTANCE;
108} 141}
109 142
110static inline void msg_set_user(struct tipc_msg *m, u32 n) 143static inline void msg_set_user(struct tipc_msg *m, u32 n)
@@ -112,16 +145,36 @@ static inline void msg_set_user(struct tipc_msg *m, u32 n)
112 msg_set_bits(m, 0, 25, 0xf, n); 145 msg_set_bits(m, 0, 25, 0xf, n);
113} 146}
114 147
148static inline u32 msg_importance(struct tipc_msg *m)
149{
150 return msg_bits(m, 0, 25, 0xf);
151}
152
115static inline void msg_set_importance(struct tipc_msg *m, u32 i) 153static inline void msg_set_importance(struct tipc_msg *m, u32 i)
116{ 154{
117 msg_set_user(m, i); 155 msg_set_user(m, i);
118} 156}
119 157
120static inline void msg_set_hdr_sz(struct tipc_msg *m,u32 n) 158static inline u32 msg_hdr_sz(struct tipc_msg *m)
159{
160 return msg_bits(m, 0, 21, 0xf) << 2;
161}
162
163static inline void msg_set_hdr_sz(struct tipc_msg *m, u32 n)
121{ 164{
122 msg_set_bits(m, 0, 21, 0xf, n>>2); 165 msg_set_bits(m, 0, 21, 0xf, n>>2);
123} 166}
124 167
168static inline u32 msg_size(struct tipc_msg *m)
169{
170 return msg_bits(m, 0, 0, 0x1ffff);
171}
172
173static inline u32 msg_data_sz(struct tipc_msg *m)
174{
175 return msg_size(m) - msg_hdr_sz(m);
176}
177
125static inline int msg_non_seq(struct tipc_msg *m) 178static inline int msg_non_seq(struct tipc_msg *m)
126{ 179{
127 return msg_bits(m, 0, 20, 1); 180 return msg_bits(m, 0, 20, 1);
@@ -162,11 +215,36 @@ static inline void msg_set_size(struct tipc_msg *m, u32 sz)
162 * Word 1 215 * Word 1
163 */ 216 */
164 217
218static inline u32 msg_type(struct tipc_msg *m)
219{
220 return msg_bits(m, 1, 29, 0x7);
221}
222
165static inline void msg_set_type(struct tipc_msg *m, u32 n) 223static inline void msg_set_type(struct tipc_msg *m, u32 n)
166{ 224{
167 msg_set_bits(m, 1, 29, 0x7, n); 225 msg_set_bits(m, 1, 29, 0x7, n);
168} 226}
169 227
228static inline u32 msg_named(struct tipc_msg *m)
229{
230 return msg_type(m) == TIPC_NAMED_MSG;
231}
232
233static inline u32 msg_mcast(struct tipc_msg *m)
234{
235 return msg_type(m) == TIPC_MCAST_MSG;
236}
237
238static inline u32 msg_connected(struct tipc_msg *m)
239{
240 return msg_type(m) == TIPC_CONN_MSG;
241}
242
243static inline u32 msg_errcode(struct tipc_msg *m)
244{
245 return msg_bits(m, 1, 25, 0xf);
246}
247
170static inline void msg_set_errcode(struct tipc_msg *m, u32 err) 248static inline void msg_set_errcode(struct tipc_msg *m, u32 err)
171{ 249{
172 msg_set_bits(m, 1, 25, 0xf, err); 250 msg_set_bits(m, 1, 25, 0xf, err);
@@ -257,71 +335,96 @@ static inline void msg_set_destnode_cache(struct tipc_msg *m, u32 dnode)
257 */ 335 */
258 336
259 337
338static inline u32 msg_prevnode(struct tipc_msg *m)
339{
340 return msg_word(m, 3);
341}
342
260static inline void msg_set_prevnode(struct tipc_msg *m, u32 a) 343static inline void msg_set_prevnode(struct tipc_msg *m, u32 a)
261{ 344{
262 msg_set_word(m, 3, a); 345 msg_set_word(m, 3, a);
263} 346}
264 347
348static inline u32 msg_origport(struct tipc_msg *m)
349{
350 return msg_word(m, 4);
351}
352
265static inline void msg_set_origport(struct tipc_msg *m, u32 p) 353static inline void msg_set_origport(struct tipc_msg *m, u32 p)
266{ 354{
267 msg_set_word(m, 4, p); 355 msg_set_word(m, 4, p);
268} 356}
269 357
358static inline u32 msg_destport(struct tipc_msg *m)
359{
360 return msg_word(m, 5);
361}
362
270static inline void msg_set_destport(struct tipc_msg *m, u32 p) 363static inline void msg_set_destport(struct tipc_msg *m, u32 p)
271{ 364{
272 msg_set_word(m, 5, p); 365 msg_set_word(m, 5, p);
273} 366}
274 367
368static inline u32 msg_mc_netid(struct tipc_msg *m)
369{
370 return msg_word(m, 5);
371}
372
275static inline void msg_set_mc_netid(struct tipc_msg *m, u32 p) 373static inline void msg_set_mc_netid(struct tipc_msg *m, u32 p)
276{ 374{
277 msg_set_word(m, 5, p); 375 msg_set_word(m, 5, p);
278} 376}
279 377
280static inline void msg_set_orignode(struct tipc_msg *m, u32 a) 378static inline int msg_short(struct tipc_msg *m)
281{ 379{
282 msg_set_word(m, 6, a); 380 return msg_hdr_sz(m) == 24;
283} 381}
284 382
285static inline void msg_set_destnode(struct tipc_msg *m, u32 a) 383static inline u32 msg_orignode(struct tipc_msg *m)
286{ 384{
287 msg_set_word(m, 7, a); 385 if (likely(msg_short(m)))
386 return msg_prevnode(m);
387 return msg_word(m, 6);
288} 388}
289 389
290static inline int msg_is_dest(struct tipc_msg *m, u32 d) 390static inline void msg_set_orignode(struct tipc_msg *m, u32 a)
291{ 391{
292 return(msg_short(m) || (msg_destnode(m) == d)); 392 msg_set_word(m, 6, a);
293} 393}
294 394
295static inline u32 msg_routed(struct tipc_msg *m) 395static inline u32 msg_destnode(struct tipc_msg *m)
296{ 396{
297 if (likely(msg_short(m))) 397 return msg_word(m, 7);
298 return 0;
299 return(msg_destnode(m) ^ msg_orignode(m)) >> 11;
300} 398}
301 399
302static inline void msg_set_nametype(struct tipc_msg *m, u32 n) 400static inline void msg_set_destnode(struct tipc_msg *m, u32 a)
303{ 401{
304 msg_set_word(m, 8, n); 402 msg_set_word(m, 7, a);
305} 403}
306 404
307static inline u32 msg_transp_seqno(struct tipc_msg *m) 405static inline int msg_is_dest(struct tipc_msg *m, u32 d)
406{
407 return msg_short(m) || (msg_destnode(m) == d);
408}
409
410static inline u32 msg_nametype(struct tipc_msg *m)
308{ 411{
309 return msg_word(m, 8); 412 return msg_word(m, 8);
310} 413}
311 414
312static inline void msg_set_timestamp(struct tipc_msg *m, u32 n) 415static inline void msg_set_nametype(struct tipc_msg *m, u32 n)
313{ 416{
314 msg_set_word(m, 8, n); 417 msg_set_word(m, 8, n);
315} 418}
316 419
317static inline u32 msg_timestamp(struct tipc_msg *m) 420static inline u32 msg_nameinst(struct tipc_msg *m)
318{ 421{
319 return msg_word(m, 8); 422 return msg_word(m, 9);
320} 423}
321 424
322static inline void msg_set_transp_seqno(struct tipc_msg *m, u32 n) 425static inline u32 msg_namelower(struct tipc_msg *m)
323{ 426{
324 msg_set_word(m, 8, n); 427 return msg_nameinst(m);
325} 428}
326 429
327static inline void msg_set_namelower(struct tipc_msg *m, u32 n) 430static inline void msg_set_namelower(struct tipc_msg *m, u32 n)
@@ -334,11 +437,21 @@ static inline void msg_set_nameinst(struct tipc_msg *m, u32 n)
334 msg_set_namelower(m, n); 437 msg_set_namelower(m, n);
335} 438}
336 439
440static inline u32 msg_nameupper(struct tipc_msg *m)
441{
442 return msg_word(m, 10);
443}
444
337static inline void msg_set_nameupper(struct tipc_msg *m, u32 n) 445static inline void msg_set_nameupper(struct tipc_msg *m, u32 n)
338{ 446{
339 msg_set_word(m, 10, n); 447 msg_set_word(m, 10, n);
340} 448}
341 449
450static inline unchar *msg_data(struct tipc_msg *m)
451{
452 return ((unchar *)m) + msg_hdr_sz(m);
453}
454
342static inline struct tipc_msg *msg_get_wrapped(struct tipc_msg *m) 455static inline struct tipc_msg *msg_get_wrapped(struct tipc_msg *m)
343{ 456{
344 return (struct tipc_msg *)msg_data(m); 457 return (struct tipc_msg *)msg_data(m);
@@ -346,55 +459,25 @@ static inline struct tipc_msg *msg_get_wrapped(struct tipc_msg *m)
346 459
347 460
348/* 461/*
349 TIPC internal message header format, version 2 462 * Constants and routines used to read and write TIPC internal message headers
350 463 */
351 1 0 9 8 7 6 5 4|3 2 1 0 9 8 7 6|5 4 3 2 1 0 9 8|7 6 5 4 3 2 1 0
352 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
353 w0:|vers |msg usr|hdr sz |n|resrv| packet size |
354 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
355 w1:|m typ| sequence gap | broadcast ack no |
356 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
357 w2:| link level ack no/bc_gap_from | seq no / bcast_gap_to |
358 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
359 w3:| previous node |
360 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
361 w4:| next sent broadcast/fragm no | next sent pkt/ fragm msg no |
362 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
363 w5:| session no |rsv=0|r|berid|link prio|netpl|p|
364 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
365 w6:| originating node |
366 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
367 w7:| destination node |
368 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
369 w8:| transport sequence number |
370 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
371 w9:| msg count / bcast tag | link tolerance |
372 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
373 \ \
374 / User Specific Data /
375 \ \
376 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
377
378 NB: CONN_MANAGER use data message format. LINK_CONFIG has own format.
379*/
380 464
381/* 465/*
382 * Internal users 466 * Internal message users
383 */ 467 */
384 468
385#define BCAST_PROTOCOL 5 469#define BCAST_PROTOCOL 5
386#define MSG_BUNDLER 6 470#define MSG_BUNDLER 6
387#define LINK_PROTOCOL 7 471#define LINK_PROTOCOL 7
388#define CONN_MANAGER 8 472#define CONN_MANAGER 8
389#define ROUTE_DISTRIBUTOR 9 473#define ROUTE_DISTRIBUTOR 9 /* obsoleted */
390#define CHANGEOVER_PROTOCOL 10 474#define CHANGEOVER_PROTOCOL 10
391#define NAME_DISTRIBUTOR 11 475#define NAME_DISTRIBUTOR 11
392#define MSG_FRAGMENTER 12 476#define MSG_FRAGMENTER 12
393#define LINK_CONFIG 13 477#define LINK_CONFIG 13
394#define DSC_H_SIZE 40
395 478
396/* 479/*
397 * Connection management protocol messages 480 * Connection management protocol message types
398 */ 481 */
399 482
400#define CONN_PROBE 0 483#define CONN_PROBE 0
@@ -402,12 +485,41 @@ static inline struct tipc_msg *msg_get_wrapped(struct tipc_msg *m)
402#define CONN_ACK 2 485#define CONN_ACK 2
403 486
404/* 487/*
405 * Name distributor messages 488 * Name distributor message types
406 */ 489 */
407 490
408#define PUBLICATION 0 491#define PUBLICATION 0
409#define WITHDRAWAL 1 492#define WITHDRAWAL 1
410 493
494/*
495 * Segmentation message types
496 */
497
498#define FIRST_FRAGMENT 0
499#define FRAGMENT 1
500#define LAST_FRAGMENT 2
501
502/*
503 * Link management protocol message types
504 */
505
506#define STATE_MSG 0
507#define RESET_MSG 1
508#define ACTIVATE_MSG 2
509
510/*
511 * Changeover tunnel message types
512 */
513#define DUPLICATE_MSG 0
514#define ORIGINAL_MSG 1
515
516/*
517 * Config protocol message types
518 */
519
520#define DSC_REQ_MSG 0
521#define DSC_RESP_MSG 1
522
411 523
412/* 524/*
413 * Word 1 525 * Word 1
@@ -423,16 +535,6 @@ static inline void msg_set_seq_gap(struct tipc_msg *m, u32 n)
423 msg_set_bits(m, 1, 16, 0x1fff, n); 535 msg_set_bits(m, 1, 16, 0x1fff, n);
424} 536}
425 537
426static inline u32 msg_req_links(struct tipc_msg *m)
427{
428 return msg_bits(m, 1, 16, 0xfff);
429}
430
431static inline void msg_set_req_links(struct tipc_msg *m, u32 n)
432{
433 msg_set_bits(m, 1, 16, 0xfff, n);
434}
435
436 538
437/* 539/*
438 * Word 2 540 * Word 2
@@ -595,14 +697,9 @@ static inline u32 msg_redundant_link(struct tipc_msg *m)
595 return msg_bits(m, 5, 12, 0x1); 697 return msg_bits(m, 5, 12, 0x1);
596} 698}
597 699
598static inline void msg_set_redundant_link(struct tipc_msg *m) 700static inline void msg_set_redundant_link(struct tipc_msg *m, u32 r)
599{ 701{
600 msg_set_bits(m, 5, 12, 0x1, 1); 702 msg_set_bits(m, 5, 12, 0x1, r);
601}
602
603static inline void msg_clear_redundant_link(struct tipc_msg *m)
604{
605 msg_set_bits(m, 5, 12, 0x1, 0);
606} 703}
607 704
608 705
@@ -632,7 +729,7 @@ static inline void msg_set_bcast_tag(struct tipc_msg *m, u32 n)
632 729
633static inline u32 msg_max_pkt(struct tipc_msg *m) 730static inline u32 msg_max_pkt(struct tipc_msg *m)
634{ 731{
635 return (msg_bits(m, 9, 16, 0xffff) * 4); 732 return msg_bits(m, 9, 16, 0xffff) * 4;
636} 733}
637 734
638static inline void msg_set_max_pkt(struct tipc_msg *m, u32 n) 735static inline void msg_set_max_pkt(struct tipc_msg *m, u32 n)
@@ -650,71 +747,12 @@ static inline void msg_set_link_tolerance(struct tipc_msg *m, u32 n)
650 msg_set_bits(m, 9, 0, 0xffff, n); 747 msg_set_bits(m, 9, 0, 0xffff, n);
651} 748}
652 749
653/*
654 * Routing table message data
655 */
656
657
658static inline u32 msg_remote_node(struct tipc_msg *m)
659{
660 return msg_word(m, msg_hdr_sz(m)/4);
661}
662
663static inline void msg_set_remote_node(struct tipc_msg *m, u32 a)
664{
665 msg_set_word(m, msg_hdr_sz(m)/4, a);
666}
667
668static inline void msg_set_dataoctet(struct tipc_msg *m, u32 pos)
669{
670 msg_data(m)[pos + 4] = 1;
671}
672
673/*
674 * Segmentation message types
675 */
676
677#define FIRST_FRAGMENT 0
678#define FRAGMENT 1
679#define LAST_FRAGMENT 2
680
681/*
682 * Link management protocol message types
683 */
684
685#define STATE_MSG 0
686#define RESET_MSG 1
687#define ACTIVATE_MSG 2
688
689/*
690 * Changeover tunnel message types
691 */
692#define DUPLICATE_MSG 0
693#define ORIGINAL_MSG 1
694
695/*
696 * Routing table message types
697 */
698#define EXT_ROUTING_TABLE 0
699#define LOCAL_ROUTING_TABLE 1
700#define SLAVE_ROUTING_TABLE 2
701#define ROUTE_ADDITION 3
702#define ROUTE_REMOVAL 4
703
704/*
705 * Config protocol message types
706 */
707
708#define DSC_REQ_MSG 0
709#define DSC_RESP_MSG 1
710
711u32 tipc_msg_tot_importance(struct tipc_msg *m); 750u32 tipc_msg_tot_importance(struct tipc_msg *m);
712void tipc_msg_init(struct tipc_msg *m, u32 user, u32 type, 751void tipc_msg_init(struct tipc_msg *m, u32 user, u32 type,
713 u32 hsize, u32 destnode); 752 u32 hsize, u32 destnode);
714int tipc_msg_calc_data_size(struct iovec const *msg_sect, u32 num_sect); 753int tipc_msg_build(struct tipc_msg *hdr, struct iovec const *msg_sect,
715int tipc_msg_build(struct tipc_msg *hdr, 754 u32 num_sect, unsigned int total_len,
716 struct iovec const *msg_sect, u32 num_sect, 755 int max_size, int usrmem, struct sk_buff **buf);
717 int max_size, int usrmem, struct sk_buff** buf);
718 756
719static inline void msg_set_media_addr(struct tipc_msg *m, struct tipc_media_addr *a) 757static inline void msg_set_media_addr(struct tipc_msg *m, struct tipc_media_addr *a)
720{ 758{
@@ -723,7 +761,7 @@ static inline void msg_set_media_addr(struct tipc_msg *m, struct tipc_media_addr
723 761
724static inline void msg_get_media_addr(struct tipc_msg *m, struct tipc_media_addr *a) 762static inline void msg_get_media_addr(struct tipc_msg *m, struct tipc_media_addr *a)
725{ 763{
726 memcpy(a, &((int*)m)[5], sizeof(*a)); 764 memcpy(a, &((int *)m)[5], sizeof(*a));
727} 765}
728 766
729#endif 767#endif