diff options
Diffstat (limited to 'net/tipc/msg.h')
| -rw-r--r-- | net/tipc/msg.h | 133 |
1 files changed, 74 insertions, 59 deletions
diff --git a/net/tipc/msg.h b/net/tipc/msg.h index 9ace47f44a69..e1d3595e2ee9 100644 --- a/net/tipc/msg.h +++ b/net/tipc/msg.h | |||
| @@ -1,7 +1,7 @@ | |||
| 1 | /* | 1 | /* |
| 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, 2014, Ericsson AB | 4 | * Copyright (c) 2000-2007, 2014-2015 Ericsson AB |
| 5 | * Copyright (c) 2005-2008, 2010-2011, Wind River Systems | 5 | * Copyright (c) 2005-2008, 2010-2011, Wind River Systems |
| 6 | * All rights reserved. | 6 | * All rights reserved. |
| 7 | * | 7 | * |
| @@ -54,6 +54,8 @@ struct plist; | |||
| 54 | * - TIPC_HIGH_IMPORTANCE | 54 | * - TIPC_HIGH_IMPORTANCE |
| 55 | * - TIPC_CRITICAL_IMPORTANCE | 55 | * - TIPC_CRITICAL_IMPORTANCE |
| 56 | */ | 56 | */ |
| 57 | #define TIPC_SYSTEM_IMPORTANCE 4 | ||
| 58 | |||
| 57 | 59 | ||
| 58 | /* | 60 | /* |
| 59 | * Payload message types | 61 | * Payload message types |
| @@ -64,6 +66,19 @@ struct plist; | |||
| 64 | #define TIPC_DIRECT_MSG 3 | 66 | #define TIPC_DIRECT_MSG 3 |
| 65 | 67 | ||
| 66 | /* | 68 | /* |
| 69 | * Internal message users | ||
| 70 | */ | ||
| 71 | #define BCAST_PROTOCOL 5 | ||
| 72 | #define MSG_BUNDLER 6 | ||
| 73 | #define LINK_PROTOCOL 7 | ||
| 74 | #define CONN_MANAGER 8 | ||
| 75 | #define TUNNEL_PROTOCOL 10 | ||
| 76 | #define NAME_DISTRIBUTOR 11 | ||
| 77 | #define MSG_FRAGMENTER 12 | ||
| 78 | #define LINK_CONFIG 13 | ||
| 79 | #define SOCK_WAKEUP 14 /* pseudo user */ | ||
| 80 | |||
| 81 | /* | ||
| 67 | * Message header sizes | 82 | * Message header sizes |
| 68 | */ | 83 | */ |
| 69 | #define SHORT_H_SIZE 24 /* In-cluster basic payload message */ | 84 | #define SHORT_H_SIZE 24 /* In-cluster basic payload message */ |
| @@ -76,7 +91,7 @@ struct plist; | |||
| 76 | 91 | ||
| 77 | #define MAX_MSG_SIZE (MAX_H_SIZE + TIPC_MAX_USER_MSG_SIZE) | 92 | #define MAX_MSG_SIZE (MAX_H_SIZE + TIPC_MAX_USER_MSG_SIZE) |
| 78 | 93 | ||
| 79 | #define TIPC_MEDIA_ADDR_OFFSET 5 | 94 | #define TIPC_MEDIA_INFO_OFFSET 5 |
| 80 | 95 | ||
| 81 | /** | 96 | /** |
| 82 | * TIPC message buffer code | 97 | * TIPC message buffer code |
| @@ -87,12 +102,12 @@ struct plist; | |||
| 87 | * Note: Headroom should be a multiple of 4 to ensure the TIPC header fields | 102 | * Note: Headroom should be a multiple of 4 to ensure the TIPC header fields |
| 88 | * are word aligned for quicker access | 103 | * are word aligned for quicker access |
| 89 | */ | 104 | */ |
| 90 | #define BUF_HEADROOM LL_MAX_HEADER | 105 | #define BUF_HEADROOM (LL_MAX_HEADER + 48) |
| 91 | 106 | ||
| 92 | struct tipc_skb_cb { | 107 | struct tipc_skb_cb { |
| 93 | void *handle; | 108 | void *handle; |
| 94 | struct sk_buff *tail; | 109 | struct sk_buff *tail; |
| 95 | bool deferred; | 110 | bool validated; |
| 96 | bool wakeup_pending; | 111 | bool wakeup_pending; |
| 97 | bool bundling; | 112 | bool bundling; |
| 98 | u16 chain_sz; | 113 | u16 chain_sz; |
| @@ -170,16 +185,6 @@ static inline void msg_set_user(struct tipc_msg *m, u32 n) | |||
| 170 | msg_set_bits(m, 0, 25, 0xf, n); | 185 | msg_set_bits(m, 0, 25, 0xf, n); |
| 171 | } | 186 | } |
| 172 | 187 | ||
| 173 | static inline u32 msg_importance(struct tipc_msg *m) | ||
| 174 | { | ||
| 175 | return msg_bits(m, 0, 25, 0xf); | ||
| 176 | } | ||
| 177 | |||
| 178 | static inline void msg_set_importance(struct tipc_msg *m, u32 i) | ||
| 179 | { | ||
| 180 | msg_set_user(m, i); | ||
| 181 | } | ||
| 182 | |||
| 183 | static inline u32 msg_hdr_sz(struct tipc_msg *m) | 188 | static inline u32 msg_hdr_sz(struct tipc_msg *m) |
| 184 | { | 189 | { |
| 185 | return msg_bits(m, 0, 21, 0xf) << 2; | 190 | return msg_bits(m, 0, 21, 0xf) << 2; |
| @@ -235,6 +240,15 @@ static inline void msg_set_size(struct tipc_msg *m, u32 sz) | |||
| 235 | m->hdr[0] = htonl((msg_word(m, 0) & ~0x1ffff) | sz); | 240 | m->hdr[0] = htonl((msg_word(m, 0) & ~0x1ffff) | sz); |
| 236 | } | 241 | } |
| 237 | 242 | ||
| 243 | static inline unchar *msg_data(struct tipc_msg *m) | ||
| 244 | { | ||
| 245 | return ((unchar *)m) + msg_hdr_sz(m); | ||
| 246 | } | ||
| 247 | |||
| 248 | static inline struct tipc_msg *msg_get_wrapped(struct tipc_msg *m) | ||
| 249 | { | ||
| 250 | return (struct tipc_msg *)msg_data(m); | ||
| 251 | } | ||
| 238 | 252 | ||
| 239 | /* | 253 | /* |
| 240 | * Word 1 | 254 | * Word 1 |
| @@ -336,6 +350,25 @@ static inline void msg_set_seqno(struct tipc_msg *m, u32 n) | |||
| 336 | /* | 350 | /* |
| 337 | * Words 3-10 | 351 | * Words 3-10 |
| 338 | */ | 352 | */ |
| 353 | static inline u32 msg_importance(struct tipc_msg *m) | ||
| 354 | { | ||
| 355 | if (unlikely(msg_user(m) == MSG_FRAGMENTER)) | ||
| 356 | return msg_bits(m, 5, 13, 0x7); | ||
| 357 | if (likely(msg_isdata(m) && !msg_errcode(m))) | ||
| 358 | return msg_user(m); | ||
| 359 | return TIPC_SYSTEM_IMPORTANCE; | ||
| 360 | } | ||
| 361 | |||
| 362 | static inline void msg_set_importance(struct tipc_msg *m, u32 i) | ||
| 363 | { | ||
| 364 | if (unlikely(msg_user(m) == MSG_FRAGMENTER)) | ||
| 365 | msg_set_bits(m, 5, 13, 0x7, i); | ||
| 366 | else if (likely(i < TIPC_SYSTEM_IMPORTANCE)) | ||
| 367 | msg_set_user(m, i); | ||
| 368 | else | ||
| 369 | pr_warn("Trying to set illegal importance in message\n"); | ||
| 370 | } | ||
| 371 | |||
| 339 | static inline u32 msg_prevnode(struct tipc_msg *m) | 372 | static inline u32 msg_prevnode(struct tipc_msg *m) |
| 340 | { | 373 | { |
| 341 | return msg_word(m, 3); | 374 | return msg_word(m, 3); |
| @@ -348,6 +381,8 @@ static inline void msg_set_prevnode(struct tipc_msg *m, u32 a) | |||
| 348 | 381 | ||
| 349 | static inline u32 msg_origport(struct tipc_msg *m) | 382 | static inline u32 msg_origport(struct tipc_msg *m) |
| 350 | { | 383 | { |
| 384 | if (msg_user(m) == MSG_FRAGMENTER) | ||
| 385 | m = msg_get_wrapped(m); | ||
| 351 | return msg_word(m, 4); | 386 | return msg_word(m, 4); |
| 352 | } | 387 | } |
| 353 | 388 | ||
| @@ -443,35 +478,11 @@ static inline void msg_set_nameupper(struct tipc_msg *m, u32 n) | |||
| 443 | msg_set_word(m, 10, n); | 478 | msg_set_word(m, 10, n); |
| 444 | } | 479 | } |
| 445 | 480 | ||
| 446 | static inline unchar *msg_data(struct tipc_msg *m) | ||
| 447 | { | ||
| 448 | return ((unchar *)m) + msg_hdr_sz(m); | ||
| 449 | } | ||
| 450 | |||
| 451 | static inline struct tipc_msg *msg_get_wrapped(struct tipc_msg *m) | ||
| 452 | { | ||
| 453 | return (struct tipc_msg *)msg_data(m); | ||
| 454 | } | ||
| 455 | |||
| 456 | /* | 481 | /* |
| 457 | * Constants and routines used to read and write TIPC internal message headers | 482 | * Constants and routines used to read and write TIPC internal message headers |
| 458 | */ | 483 | */ |
| 459 | 484 | ||
| 460 | /* | 485 | /* |
| 461 | * Internal message users | ||
| 462 | */ | ||
| 463 | #define BCAST_PROTOCOL 5 | ||
| 464 | #define MSG_BUNDLER 6 | ||
| 465 | #define LINK_PROTOCOL 7 | ||
| 466 | #define CONN_MANAGER 8 | ||
| 467 | #define ROUTE_DISTRIBUTOR 9 /* obsoleted */ | ||
| 468 | #define CHANGEOVER_PROTOCOL 10 | ||
| 469 | #define NAME_DISTRIBUTOR 11 | ||
| 470 | #define MSG_FRAGMENTER 12 | ||
| 471 | #define LINK_CONFIG 13 | ||
| 472 | #define SOCK_WAKEUP 14 /* pseudo user */ | ||
| 473 | |||
| 474 | /* | ||
| 475 | * Connection management protocol message types | 486 | * Connection management protocol message types |
| 476 | */ | 487 | */ |
| 477 | #define CONN_PROBE 0 | 488 | #define CONN_PROBE 0 |
| @@ -501,8 +512,8 @@ static inline struct tipc_msg *msg_get_wrapped(struct tipc_msg *m) | |||
| 501 | /* | 512 | /* |
| 502 | * Changeover tunnel message types | 513 | * Changeover tunnel message types |
| 503 | */ | 514 | */ |
| 504 | #define DUPLICATE_MSG 0 | 515 | #define SYNCH_MSG 0 |
| 505 | #define ORIGINAL_MSG 1 | 516 | #define FAILOVER_MSG 1 |
| 506 | 517 | ||
| 507 | /* | 518 | /* |
| 508 | * Config protocol message types | 519 | * Config protocol message types |
| @@ -510,7 +521,6 @@ static inline struct tipc_msg *msg_get_wrapped(struct tipc_msg *m) | |||
| 510 | #define DSC_REQ_MSG 0 | 521 | #define DSC_REQ_MSG 0 |
| 511 | #define DSC_RESP_MSG 1 | 522 | #define DSC_RESP_MSG 1 |
| 512 | 523 | ||
| 513 | |||
| 514 | /* | 524 | /* |
| 515 | * Word 1 | 525 | * Word 1 |
| 516 | */ | 526 | */ |
| @@ -534,6 +544,24 @@ static inline void msg_set_node_sig(struct tipc_msg *m, u32 n) | |||
| 534 | msg_set_bits(m, 1, 0, 0xffff, n); | 544 | msg_set_bits(m, 1, 0, 0xffff, n); |
| 535 | } | 545 | } |
| 536 | 546 | ||
| 547 | static inline u32 msg_node_capabilities(struct tipc_msg *m) | ||
| 548 | { | ||
| 549 | return msg_bits(m, 1, 15, 0x1fff); | ||
| 550 | } | ||
| 551 | |||
| 552 | static inline void msg_set_node_capabilities(struct tipc_msg *m, u32 n) | ||
| 553 | { | ||
| 554 | msg_set_bits(m, 1, 15, 0x1fff, n); | ||
| 555 | } | ||
| 556 | |||
| 557 | static inline bool msg_dup(struct tipc_msg *m) | ||
| 558 | { | ||
| 559 | if (likely(msg_user(m) != TUNNEL_PROTOCOL)) | ||
| 560 | return false; | ||
| 561 | if (msg_type(m) != SYNCH_MSG) | ||
| 562 | return false; | ||
| 563 | return true; | ||
| 564 | } | ||
| 537 | 565 | ||
| 538 | /* | 566 | /* |
| 539 | * Word 2 | 567 | * Word 2 |
| @@ -688,7 +716,7 @@ static inline void msg_set_redundant_link(struct tipc_msg *m, u32 r) | |||
| 688 | 716 | ||
| 689 | static inline char *msg_media_addr(struct tipc_msg *m) | 717 | static inline char *msg_media_addr(struct tipc_msg *m) |
| 690 | { | 718 | { |
| 691 | return (char *)&m->hdr[TIPC_MEDIA_ADDR_OFFSET]; | 719 | return (char *)&m->hdr[TIPC_MEDIA_INFO_OFFSET]; |
| 692 | } | 720 | } |
| 693 | 721 | ||
| 694 | /* | 722 | /* |
| @@ -734,21 +762,8 @@ static inline void msg_set_link_tolerance(struct tipc_msg *m, u32 n) | |||
| 734 | msg_set_bits(m, 9, 0, 0xffff, n); | 762 | msg_set_bits(m, 9, 0, 0xffff, n); |
| 735 | } | 763 | } |
| 736 | 764 | ||
| 737 | static inline u32 tipc_msg_tot_importance(struct tipc_msg *m) | ||
| 738 | { | ||
| 739 | if ((msg_user(m) == MSG_FRAGMENTER) && (msg_type(m) == FIRST_FRAGMENT)) | ||
| 740 | return msg_importance(msg_get_wrapped(m)); | ||
| 741 | return msg_importance(m); | ||
| 742 | } | ||
| 743 | |||
| 744 | static inline u32 msg_tot_origport(struct tipc_msg *m) | ||
| 745 | { | ||
| 746 | if ((msg_user(m) == MSG_FRAGMENTER) && (msg_type(m) == FIRST_FRAGMENT)) | ||
| 747 | return msg_origport(msg_get_wrapped(m)); | ||
| 748 | return msg_origport(m); | ||
| 749 | } | ||
| 750 | |||
| 751 | struct sk_buff *tipc_buf_acquire(u32 size); | 765 | struct sk_buff *tipc_buf_acquire(u32 size); |
| 766 | bool tipc_msg_validate(struct sk_buff *skb); | ||
| 752 | bool tipc_msg_reverse(u32 own_addr, struct sk_buff *buf, u32 *dnode, | 767 | bool tipc_msg_reverse(u32 own_addr, struct sk_buff *buf, u32 *dnode, |
| 753 | int err); | 768 | int err); |
| 754 | void tipc_msg_init(u32 own_addr, struct tipc_msg *m, u32 user, u32 type, | 769 | void tipc_msg_init(u32 own_addr, struct tipc_msg *m, u32 user, u32 type, |
| @@ -757,9 +772,9 @@ struct sk_buff *tipc_msg_create(uint user, uint type, uint hdr_sz, | |||
| 757 | uint data_sz, u32 dnode, u32 onode, | 772 | uint data_sz, u32 dnode, u32 onode, |
| 758 | u32 dport, u32 oport, int errcode); | 773 | u32 dport, u32 oport, int errcode); |
| 759 | int tipc_buf_append(struct sk_buff **headbuf, struct sk_buff **buf); | 774 | int tipc_buf_append(struct sk_buff **headbuf, struct sk_buff **buf); |
| 760 | bool tipc_msg_bundle(struct sk_buff_head *list, struct sk_buff *skb, u32 mtu); | 775 | bool tipc_msg_bundle(struct sk_buff *bskb, struct sk_buff *skb, u32 mtu); |
| 761 | bool tipc_msg_make_bundle(struct sk_buff_head *list, | 776 | |
| 762 | struct sk_buff *skb, u32 mtu, u32 dnode); | 777 | bool tipc_msg_make_bundle(struct sk_buff **skb, u32 mtu, u32 dnode); |
| 763 | bool tipc_msg_extract(struct sk_buff *skb, struct sk_buff **iskb, int *pos); | 778 | bool tipc_msg_extract(struct sk_buff *skb, struct sk_buff **iskb, int *pos); |
| 764 | int tipc_msg_build(struct tipc_msg *mhdr, struct msghdr *m, | 779 | int tipc_msg_build(struct tipc_msg *mhdr, struct msghdr *m, |
| 765 | int offset, int dsz, int mtu, struct sk_buff_head *list); | 780 | int offset, int dsz, int mtu, struct sk_buff_head *list); |
