[PATCH] cleanup the usage of SEND_SIG_xxx constants
[powerpc.git] / include / net / sock.h
index 312cb25..e0498bd 100644 (file)
@@ -99,6 +99,7 @@ struct proto;
  *     @skc_node: main hash linkage for various protocol lookup tables
  *     @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_prot: protocol handlers inside a network family
  *
  *     This is the minimal network layer representation of sockets, the header
@@ -112,6 +113,7 @@ struct sock_common {
        struct hlist_node       skc_node;
        struct hlist_node       skc_bind_node;
        atomic_t                skc_refcnt;
+       unsigned int            skc_hash;
        struct proto            *skc_prot;
 };
 
@@ -139,7 +141,6 @@ struct sock_common {
   *    @sk_no_check: %SO_NO_CHECK setting, wether or not checkup packets
   *    @sk_route_caps: route capabilities (e.g. %NETIF_F_TSO)
   *    @sk_lingertime: %SO_LINGER l_linger setting
-  *    @sk_hashent: hash entry in several tables (e.g. inet_hashinfo.ehash)
   *    @sk_backlog: always used with the per-socket spinlock held
   *    @sk_callback_lock: used with the callbacks in the end of this struct
   *    @sk_error_queue: rarely used
@@ -186,6 +187,7 @@ struct sock {
 #define sk_node                        __sk_common.skc_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
        unsigned char           sk_shutdown : 2,
                                sk_no_check : 2,
@@ -205,10 +207,9 @@ struct sock {
        struct sk_buff_head     sk_write_queue;
        int                     sk_wmem_queued;
        int                     sk_forward_alloc;
-       unsigned int            sk_allocation;
+       gfp_t                   sk_allocation;
        int                     sk_sndbuf;
        int                     sk_route_caps;
-       int                     sk_hashent;
        unsigned long           sk_flags;
        unsigned long           sk_lingertime;
        /*
@@ -709,6 +710,12 @@ static inline int sk_stream_rmem_schedule(struct sock *sk, struct sk_buff *skb)
                sk_stream_mem_schedule(sk, skb->truesize, 1);
 }
 
+static inline int sk_stream_wmem_schedule(struct sock *sk, int size)
+{
+       return size <= sk->sk_forward_alloc ||
+              sk_stream_mem_schedule(sk, size, 0);
+}
+
 /* Used by processes to "lock" a socket state, so that
  * interrupts and bottom half handlers won't change it
  * from under us. It essentially blocks any incoming
@@ -732,18 +739,18 @@ extern void FASTCALL(release_sock(struct sock *sk));
 #define bh_unlock_sock(__sk)   spin_unlock(&((__sk)->sk_lock.slock))
 
 extern struct sock             *sk_alloc(int family,
-                                         unsigned int __nocast priority,
+                                         gfp_t priority,
                                          struct proto *prot, int zero_it);
 extern void                    sk_free(struct sock *sk);
 extern struct sock             *sk_clone(const struct sock *sk,
-                                         const unsigned int __nocast priority);
+                                         const gfp_t priority);
 
 extern struct sk_buff          *sock_wmalloc(struct sock *sk,
                                              unsigned long size, int force,
-                                             unsigned int __nocast priority);
+                                             gfp_t priority);
 extern struct sk_buff          *sock_rmalloc(struct sock *sk,
                                              unsigned long size, int force,
-                                             unsigned int __nocast priority);
+                                             gfp_t priority);
 extern void                    sock_wfree(struct sk_buff *skb);
 extern void                    sock_rfree(struct sk_buff *skb);
 
@@ -759,7 +766,7 @@ extern struct sk_buff               *sock_alloc_send_skb(struct sock *sk,
                                                     int noblock,
                                                     int *errcode);
 extern void *sock_kmalloc(struct sock *sk, int size,
-                         unsigned int __nocast priority);
+                         gfp_t priority);
 extern void sock_kfree_s(struct sock *sk, void *mem, int size);
 extern void sk_send_sigurg(struct sock *sk);
 
@@ -1194,7 +1201,7 @@ static inline void sk_stream_moderate_sndbuf(struct sock *sk)
 
 static inline struct sk_buff *sk_stream_alloc_pskb(struct sock *sk,
                                                   int size, int mem,
-                                                  unsigned int __nocast gfp)
+                                                  gfp_t gfp)
 {
        struct sk_buff *skb;
        int hdr_len;
@@ -1203,8 +1210,7 @@ static inline struct sk_buff *sk_stream_alloc_pskb(struct sock *sk,
        skb = alloc_skb_fclone(size + hdr_len, gfp);
        if (skb) {
                skb->truesize += mem;
-               if (sk->sk_forward_alloc >= (int)skb->truesize ||
-                   sk_stream_mem_schedule(sk, skb->truesize, 0)) {
+               if (sk_stream_wmem_schedule(sk, skb->truesize)) {
                        skb_reserve(skb, hdr_len);
                        return skb;
                }
@@ -1218,7 +1224,7 @@ static inline struct sk_buff *sk_stream_alloc_pskb(struct sock *sk,
 
 static inline struct sk_buff *sk_stream_alloc_skb(struct sock *sk,
                                                  int size,
-                                                 unsigned int __nocast gfp)
+                                                 gfp_t gfp)
 {
        return sk_stream_alloc_pskb(sk, size, 0, gfp);
 }
@@ -1227,10 +1233,8 @@ static inline struct page *sk_stream_alloc_page(struct sock *sk)
 {
        struct page *page = NULL;
 
-       if (sk->sk_forward_alloc >= (int)PAGE_SIZE ||
-           sk_stream_mem_schedule(sk, PAGE_SIZE, 0))
-               page = alloc_pages(sk->sk_allocation, 0);
-       else {
+       page = alloc_pages(sk->sk_allocation, 0);
+       if (!page) {
                sk->sk_prot->enter_memory_pressure();
                sk_stream_moderate_sndbuf(sk);
        }
@@ -1251,7 +1255,7 @@ static inline int sock_writeable(const struct sock *sk)
        return atomic_read(&sk->sk_wmem_alloc) < (sk->sk_sndbuf / 2);
 }
 
-static inline unsigned int __nocast gfp_any(void)
+static inline gfp_t gfp_any(void)
 {
        return in_softirq() ? GFP_ATOMIC : GFP_KERNEL;
 }
@@ -1374,9 +1378,10 @@ extern void sk_init(void);
 
 #ifdef CONFIG_SYSCTL
 extern struct ctl_table core_table[];
-extern int sysctl_optmem_max;
 #endif
 
+extern int sysctl_optmem_max;
+
 extern __u32 sysctl_wmem_default;
 extern __u32 sysctl_rmem_default;