diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2010-05-21 00:04:44 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2010-05-21 00:04:44 -0400 |
commit | f8965467f366fd18f01feafb5db10512d7b4422c (patch) | |
tree | 3706a9cd779859271ca61b85c63a1bc3f82d626e /net/tipc/msg.h | |
parent | a26272e5200765691e67d6780e52b32498fdb659 (diff) | |
parent | 2ec8c6bb5d8f3a62a79f463525054bae1e3d4487 (diff) |
Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next-2.6
* git://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next-2.6: (1674 commits)
qlcnic: adding co maintainer
ixgbe: add support for active DA cables
ixgbe: dcb, do not tag tc_prio_control frames
ixgbe: fix ixgbe_tx_is_paused logic
ixgbe: always enable vlan strip/insert when DCB is enabled
ixgbe: remove some redundant code in setting FCoE FIP filter
ixgbe: fix wrong offset to fc_frame_header in ixgbe_fcoe_ddp
ixgbe: fix header len when unsplit packet overflows to data buffer
ipv6: Never schedule DAD timer on dead address
ipv6: Use POSTDAD state
ipv6: Use state_lock to protect ifa state
ipv6: Replace inet6_ifaddr->dead with state
cxgb4: notify upper drivers if the device is already up when they load
cxgb4: keep interrupts available when the ports are brought down
cxgb4: fix initial addition of MAC address
cnic: Return SPQ credit to bnx2x after ring setup and shutdown.
cnic: Convert cnic_local_flags to atomic ops.
can: Fix SJA1000 command register writes on SMP systems
bridge: fix build for CONFIG_SYSFS disabled
ARCNET: Limit com20020 PCI ID matches for SOHARD cards
...
Fix up various conflicts with pcmcia tree drivers/net/
{pcmcia/3c589_cs.c, wireless/orinoco/orinoco_cs.c and
wireless/orinoco/spectrum_cs.c} and feature removal
(Documentation/feature-removal-schedule.txt).
Also fix a non-content conflict due to pm_qos_requirement getting
renamed in the PM tree (now pm_qos_request) in net/mac80211/scan.c
Diffstat (limited to 'net/tipc/msg.h')
-rw-r--r-- | net/tipc/msg.h | 99 |
1 files changed, 6 insertions, 93 deletions
diff --git a/net/tipc/msg.h b/net/tipc/msg.h index 7ee6ae238147..995d2da35b01 100644 --- a/net/tipc/msg.h +++ b/net/tipc/msg.h | |||
@@ -708,100 +708,13 @@ static inline void msg_set_dataoctet(struct tipc_msg *m, u32 pos) | |||
708 | #define DSC_REQ_MSG 0 | 708 | #define DSC_REQ_MSG 0 |
709 | #define DSC_RESP_MSG 1 | 709 | #define DSC_RESP_MSG 1 |
710 | 710 | ||
711 | static inline u32 msg_tot_importance(struct tipc_msg *m) | 711 | u32 tipc_msg_tot_importance(struct tipc_msg *m); |
712 | { | 712 | void tipc_msg_init(struct tipc_msg *m, u32 user, u32 type, |
713 | if (likely(msg_isdata(m))) { | 713 | u32 hsize, u32 destnode); |
714 | if (likely(msg_orignode(m) == tipc_own_addr)) | 714 | int tipc_msg_calc_data_size(struct iovec const *msg_sect, u32 num_sect); |
715 | return msg_importance(m); | 715 | int tipc_msg_build(struct tipc_msg *hdr, |
716 | return msg_importance(m) + 4; | ||
717 | } | ||
718 | if ((msg_user(m) == MSG_FRAGMENTER) && | ||
719 | (msg_type(m) == FIRST_FRAGMENT)) | ||
720 | return msg_importance(msg_get_wrapped(m)); | ||
721 | return msg_importance(m); | ||
722 | } | ||
723 | |||
724 | |||
725 | static inline void msg_init(struct tipc_msg *m, u32 user, u32 type, | ||
726 | u32 hsize, u32 destnode) | ||
727 | { | ||
728 | memset(m, 0, hsize); | ||
729 | msg_set_version(m); | ||
730 | msg_set_user(m, user); | ||
731 | msg_set_hdr_sz(m, hsize); | ||
732 | msg_set_size(m, hsize); | ||
733 | msg_set_prevnode(m, tipc_own_addr); | ||
734 | msg_set_type(m, type); | ||
735 | if (!msg_short(m)) { | ||
736 | msg_set_orignode(m, tipc_own_addr); | ||
737 | msg_set_destnode(m, destnode); | ||
738 | } | ||
739 | } | ||
740 | |||
741 | /** | ||
742 | * msg_calc_data_size - determine total data size for message | ||
743 | */ | ||
744 | |||
745 | static inline int msg_calc_data_size(struct iovec const *msg_sect, u32 num_sect) | ||
746 | { | ||
747 | int dsz = 0; | ||
748 | int i; | ||
749 | |||
750 | for (i = 0; i < num_sect; i++) | ||
751 | dsz += msg_sect[i].iov_len; | ||
752 | return dsz; | ||
753 | } | ||
754 | |||
755 | /** | ||
756 | * msg_build - create message using specified header and data | ||
757 | * | ||
758 | * Note: Caller must not hold any locks in case copy_from_user() is interrupted! | ||
759 | * | ||
760 | * Returns message data size or errno | ||
761 | */ | ||
762 | |||
763 | static inline int msg_build(struct tipc_msg *hdr, | ||
764 | struct iovec const *msg_sect, u32 num_sect, | 716 | struct iovec const *msg_sect, u32 num_sect, |
765 | int max_size, int usrmem, struct sk_buff** buf) | 717 | int max_size, int usrmem, struct sk_buff** buf); |
766 | { | ||
767 | int dsz, sz, hsz, pos, res, cnt; | ||
768 | |||
769 | dsz = msg_calc_data_size(msg_sect, num_sect); | ||
770 | if (unlikely(dsz > TIPC_MAX_USER_MSG_SIZE)) { | ||
771 | *buf = NULL; | ||
772 | return -EINVAL; | ||
773 | } | ||
774 | |||
775 | pos = hsz = msg_hdr_sz(hdr); | ||
776 | sz = hsz + dsz; | ||
777 | msg_set_size(hdr, sz); | ||
778 | if (unlikely(sz > max_size)) { | ||
779 | *buf = NULL; | ||
780 | return dsz; | ||
781 | } | ||
782 | |||
783 | *buf = buf_acquire(sz); | ||
784 | if (!(*buf)) | ||
785 | return -ENOMEM; | ||
786 | skb_copy_to_linear_data(*buf, hdr, hsz); | ||
787 | for (res = 1, cnt = 0; res && (cnt < num_sect); cnt++) { | ||
788 | if (likely(usrmem)) | ||
789 | res = !copy_from_user((*buf)->data + pos, | ||
790 | msg_sect[cnt].iov_base, | ||
791 | msg_sect[cnt].iov_len); | ||
792 | else | ||
793 | skb_copy_to_linear_data_offset(*buf, pos, | ||
794 | msg_sect[cnt].iov_base, | ||
795 | msg_sect[cnt].iov_len); | ||
796 | pos += msg_sect[cnt].iov_len; | ||
797 | } | ||
798 | if (likely(res)) | ||
799 | return dsz; | ||
800 | |||
801 | buf_discard(*buf); | ||
802 | *buf = NULL; | ||
803 | return -EFAULT; | ||
804 | } | ||
805 | 718 | ||
806 | static inline void msg_set_media_addr(struct tipc_msg *m, struct tipc_media_addr *a) | 719 | static inline void msg_set_media_addr(struct tipc_msg *m, struct tipc_media_addr *a) |
807 | { | 720 | { |