nl80211: add power save commands
[safe/jmp/linux-2.6] / include / net / sock.h
index 4eb8409..3f1a480 100644 (file)
@@ -104,15 +104,18 @@ struct net;
 
 /**
  *     struct sock_common - minimal network layer representation of sockets
+ *     @skc_node: main hash linkage for various protocol lookup tables
+ *     @skc_nulls_node: main hash linkage for TCP/UDP/UDP-Lite protocol
+ *     @skc_refcnt: reference count
+ *     @skc_tx_queue_mapping: tx queue number for this connection
+ *     @skc_hash: hash value used with various protocol lookup tables
+ *     @skc_u16hashes: two u16 hash values used by UDP lookup tables
  *     @skc_family: network address family
  *     @skc_state: Connection state
  *     @skc_reuse: %SO_REUSEADDR setting
  *     @skc_bound_dev_if: bound device index if != 0
- *     @skc_node: main hash linkage for various protocol lookup tables
- *     @skc_nulls_node: main hash linkage for UDP/UDP-Lite protocol
  *     @skc_bind_node: bind hash linkage for various protocol lookup tables
- *     @skc_refcnt: reference count
- *     @skc_hash: hash value used with various protocol lookup tables
+ *     @skc_portaddr_node: second hash linkage for UDP/UDP-Lite protocol
  *     @skc_prot: protocol handlers inside a network family
  *     @skc_net: reference to the network namespace of this socket
  *
@@ -120,17 +123,28 @@ struct net;
  *     for struct sock and struct inet_timewait_sock.
  */
 struct sock_common {
+       /*
+        * first fields are not copied in sock_copy()
+        */
+       union {
+               struct hlist_node       skc_node;
+               struct hlist_nulls_node skc_nulls_node;
+       };
+       atomic_t                skc_refcnt;
+       int                     skc_tx_queue_mapping;
+
+       union  {
+               unsigned int    skc_hash;
+               __u16           skc_u16hashes[2];
+       };
        unsigned short          skc_family;
        volatile unsigned char  skc_state;
        unsigned char           skc_reuse;
        int                     skc_bound_dev_if;
        union {
-               struct hlist_node       skc_node;
-               struct hlist_nulls_node skc_nulls_node;
+               struct hlist_node       skc_bind_node;
+               struct hlist_nulls_node skc_portaddr_node;
        };
-       struct hlist_node       skc_bind_node;
-       atomic_t                skc_refcnt;
-       unsigned int            skc_hash;
        struct proto            *skc_prot;
 #ifdef CONFIG_NET_NS
        struct net              *skc_net;
@@ -208,24 +222,27 @@ struct sock {
         * don't add nothing before this first member (__sk_common) --acme
         */
        struct sock_common      __sk_common;
+#define sk_node                        __sk_common.skc_node
+#define sk_nulls_node          __sk_common.skc_nulls_node
+#define sk_refcnt              __sk_common.skc_refcnt
+#define sk_tx_queue_mapping    __sk_common.skc_tx_queue_mapping
+
+#define sk_copy_start          __sk_common.skc_hash
+#define sk_hash                        __sk_common.skc_hash
 #define sk_family              __sk_common.skc_family
 #define sk_state               __sk_common.skc_state
 #define sk_reuse               __sk_common.skc_reuse
 #define sk_bound_dev_if                __sk_common.skc_bound_dev_if
-#define sk_node                        __sk_common.skc_node
-#define sk_nulls_node          __sk_common.skc_nulls_node
 #define sk_bind_node           __sk_common.skc_bind_node
-#define sk_refcnt              __sk_common.skc_refcnt
-#define sk_hash                        __sk_common.skc_hash
 #define sk_prot                        __sk_common.skc_prot
 #define sk_net                 __sk_common.skc_net
        kmemcheck_bitfield_begin(flags);
-       unsigned char           sk_shutdown : 2,
-                               sk_no_check : 2,
-                               sk_userlocks : 4;
+       unsigned int            sk_shutdown  : 2,
+                               sk_no_check  : 2,
+                               sk_userlocks : 4,
+                               sk_protocol  : 8,
+                               sk_type      : 16;
        kmemcheck_bitfield_end(flags);
-       unsigned char           sk_protocol;
-       unsigned short          sk_type;
        int                     sk_rcvbuf;
        socket_lock_t           sk_lock;
        /*
@@ -498,6 +515,8 @@ enum sock_flags {
        SOCK_TIMESTAMPING_SOFTWARE,     /* %SOF_TIMESTAMPING_SOFTWARE */
        SOCK_TIMESTAMPING_RAW_HARDWARE, /* %SOF_TIMESTAMPING_RAW_HARDWARE */
        SOCK_TIMESTAMPING_SYS_HARDWARE, /* %SOF_TIMESTAMPING_SYS_HARDWARE */
+       SOCK_FASYNC, /* fasync() active */
+       SOCK_RXQ_OVFL,
 };
 
 static inline void sock_copy_flags(struct sock *nsk, struct sock *osk)
@@ -618,7 +637,7 @@ struct proto {
        void                    (*shutdown)(struct sock *sk, int how);
        int                     (*setsockopt)(struct sock *sk, int level, 
                                        int optname, char __user *optval,
-                                       int optlen);
+                                       unsigned int optlen);
        int                     (*getsockopt)(struct sock *sk, int level, 
                                        int optname, char __user *optval, 
                                        int __user *option);     
@@ -626,7 +645,7 @@ struct proto {
        int                     (*compat_setsockopt)(struct sock *sk,
                                        int level,
                                        int optname, char __user *optval,
-                                       int optlen);
+                                       unsigned int optlen);
        int                     (*compat_getsockopt)(struct sock *sk,
                                        int level,
                                        int optname, char __user *optval,
@@ -945,7 +964,7 @@ extern void                 sock_rfree(struct sk_buff *skb);
 
 extern int                     sock_setsockopt(struct socket *sock, int level,
                                                int op, char __user *optval,
-                                               int optlen);
+                                               unsigned int optlen);
 
 extern int                     sock_getsockopt(struct socket *sock, int level,
                                                int op, char __user *optval, 
@@ -987,7 +1006,7 @@ extern int                      sock_no_shutdown(struct socket *, int);
 extern int                     sock_no_getsockopt(struct socket *, int , int,
                                                   char __user *, int __user *);
 extern int                     sock_no_setsockopt(struct socket *, int, int,
-                                                  char __user *, int);
+                                                  char __user *, unsigned int);
 extern int                      sock_no_sendmsg(struct kiocb *, struct socket *,
                                                struct msghdr *, size_t);
 extern int                      sock_no_recvmsg(struct kiocb *, struct socket *,
@@ -1009,11 +1028,11 @@ extern int sock_common_getsockopt(struct socket *sock, int level, int optname,
 extern int sock_common_recvmsg(struct kiocb *iocb, struct socket *sock,
                               struct msghdr *msg, size_t size, int flags);
 extern int sock_common_setsockopt(struct socket *sock, int level, int optname,
-                                 char __user *optval, int optlen);
+                                 char __user *optval, unsigned int optlen);
 extern int compat_sock_common_getsockopt(struct socket *sock, int level,
                int optname, char __user *optval, int __user *optlen);
 extern int compat_sock_common_setsockopt(struct socket *sock, int level,
-               int optname, char __user *optval, int optlen);
+               int optname, char __user *optval, unsigned int optlen);
 
 extern void sk_common_release(struct sock *sk);
 
@@ -1086,8 +1105,29 @@ static inline void sock_put(struct sock *sk)
 extern int sk_receive_skb(struct sock *sk, struct sk_buff *skb,
                          const int nested);
 
+static inline void sk_tx_queue_set(struct sock *sk, int tx_queue)
+{
+       sk->sk_tx_queue_mapping = tx_queue;
+}
+
+static inline void sk_tx_queue_clear(struct sock *sk)
+{
+       sk->sk_tx_queue_mapping = -1;
+}
+
+static inline int sk_tx_queue_get(const struct sock *sk)
+{
+       return sk->sk_tx_queue_mapping;
+}
+
+static inline bool sk_tx_queue_recorded(const struct sock *sk)
+{
+       return (sk && sk->sk_tx_queue_mapping >= 0);
+}
+
 static inline void sk_set_socket(struct sock *sk, struct socket *sock)
 {
+       sk_tx_queue_clear(sk);
        sk->sk_socket = sock;
 }
 
@@ -1144,6 +1184,7 @@ __sk_dst_set(struct sock *sk, struct dst_entry *dst)
 {
        struct dst_entry *old_dst;
 
+       sk_tx_queue_clear(sk);
        old_dst = sk->sk_dst_cache;
        sk->sk_dst_cache = dst;
        dst_release(old_dst);
@@ -1162,6 +1203,7 @@ __sk_dst_reset(struct sock *sk)
 {
        struct dst_entry *old_dst;
 
+       sk_tx_queue_clear(sk);
        old_dst = sk->sk_dst_cache;
        sk->sk_dst_cache = NULL;
        dst_release(old_dst);
@@ -1271,6 +1313,9 @@ static inline int sk_has_allocations(const struct sock *sk)
  * in its cache, and so does the tp->rcv_nxt update on CPU2 side.  The CPU1
  * could then endup calling schedule and sleep forever if there are no more
  * data on the socket.
+ *
+ * The sk_has_sleeper is always called right after a call to read_lock, so we
+ * can use smp_mb__after_lock barrier.
  */
 static inline int sk_has_sleeper(struct sock *sk)
 {
@@ -1280,7 +1325,7 @@ static inline int sk_has_sleeper(struct sock *sk)
         *
         * This memory barrier is paired in the sock_poll_wait.
         */
-       smp_mb();
+       smp_mb__after_lock();
        return sk->sk_sleep && waitqueue_active(sk->sk_sleep);
 }
 
@@ -1387,7 +1432,7 @@ static inline unsigned long sock_wspace(struct sock *sk)
 
 static inline void sk_wake_async(struct sock *sk, int how, int band)
 {
-       if (sk->sk_socket && sk->sk_socket->fasync_list)
+       if (sock_flag(sk, SOCK_FASYNC))
                sock_wake_async(sk->sk_socket, how, band);
 }
 
@@ -1483,6 +1528,8 @@ sock_recv_timestamp(struct msghdr *msg, struct sock *sk, struct sk_buff *skb)
                sk->sk_stamp = kt;
 }
 
+extern void sock_recv_ts_and_drops(struct msghdr *msg, struct sock *sk, struct sk_buff *skb);
+
 /**
  * sock_tx_timestamp - checks whether the outgoing packet is to be time stamped
  * @msg:       outgoing packet