Whamcloud - gitweb
* Changed socknal to cope with sk_xxxxx
authoreeb <eeb>
Mon, 23 Jun 2003 19:07:05 +0000 (19:07 +0000)
committereeb <eeb>
Mon, 23 Jun 2003 19:07:05 +0000 (19:07 +0000)
*   Removed spurious #define of smp_processor_id() in kp30.h

*   Tried to get everything to compile under 2.4 as well as 2.5 but
    retired hurt

lnet/include/linux/kp30.h
lnet/klnds/socklnd/socklnd.c
lnet/klnds/socklnd/socklnd.h
lnet/klnds/socklnd/socklnd_cb.c
lustre/portals/include/linux/kp30.h
lustre/portals/knals/socknal/socknal.c
lustre/portals/knals/socknal/socknal.h
lustre/portals/knals/socknal/socknal_cb.c

index 9a3e64a..bc563fe 100644 (file)
 
 #define LOWEST_BIT_SET(x)      ((x) & ~((x) - 1))
 
-#ifndef CONFIG_SMP
-# define smp_processor_id() 0
-#endif
-
 /*
  *  Debugging
  */
@@ -104,7 +100,7 @@ extern unsigned int portal_printk;
         } while (0)
 #else
 #define CHECK_STACK(stack) do{}while(0)
-#define CDEBUG_STACK(var) (0)
+#define CDEBUG_STACK(var) (0L)
 #endif
 
 #if 1
index fc952f9..da2b453 100644 (file)
@@ -169,7 +169,7 @@ ksocknal_add_sock (ptl_nid_t nid, int fd, int bind_irq)
         struct socket     *sock = NULL;
         ksock_sched_t     *sched = NULL;
         unsigned int       irq = 0;
-        struct net_device *dev = NULL;
+        struct dst_entry  *dst;
         int                ret;
         int                idx;
         ENTRY;
@@ -194,8 +194,8 @@ ksocknal_add_sock (ptl_nid_t nid, int fd, int bind_irq)
 
         conn->ksnc_file = file;
         conn->ksnc_sock = sock;
-        conn->ksnc_saved_data_ready = sock->sk->data_ready;
-        conn->ksnc_saved_write_space = sock->sk->write_space;
+        conn->ksnc_saved_data_ready = sock->sk->sk_data_ready;
+        conn->ksnc_saved_write_space = sock->sk->sk_write_space;
         conn->ksnc_peernid = nid;
         atomic_set (&conn->ksnc_refcount, 1);    /* 1 ref for socklist */
 
@@ -207,22 +207,18 @@ ksocknal_add_sock (ptl_nid_t nid, int fd, int bind_irq)
         conn->ksnc_tx_ready = 0;
         conn->ksnc_tx_scheduled = 0;
 
-#warning check it is OK to derefence sk->dst_cache->dev like this...
-        lock_sock (conn->ksnc_sock->sk);
-
-        if (conn->ksnc_sock->sk->dst_cache != NULL) {
-                dev = conn->ksnc_sock->sk->dst_cache->dev;
-                if (dev != NULL) {
-                        irq = dev->irq;
+        dst = sk_dst_get (conn->ksnc_sock->sk);
+        if (dst != NULL) {
+                if (dst->dev != NULL) {
+                        irq = dst->dev->irq;
                         if (irq >= NR_IRQS) {
                                 CERROR ("Unexpected IRQ %x\n", irq);
                                 irq = 0;
                         }
                 }
+                dst_release (dst);
         }
 
-        release_sock (conn->ksnc_sock->sk);
-
         write_lock_irqsave (&ksocknal_data.ksnd_socklist_lock, flags);
 
         if (irq == 0 ||
@@ -271,9 +267,9 @@ ksocknal_add_sock (ptl_nid_t nid, int fd, int bind_irq)
                 ksocknal_bind_irq (irq, sched - ksocknal_data.ksnd_schedulers);
 
         /* NOW it's safe to get called back when socket is ready... */
-        sock->sk->user_data = conn;
-        sock->sk->data_ready = ksocknal_data_ready;
-        sock->sk->write_space = ksocknal_write_space;
+        sock->sk->sk_user_data = conn;
+        sock->sk->sk_data_ready = ksocknal_data_ready;
+        sock->sk->sk_write_space = ksocknal_write_space;
 
         /* ...which I call right now to get things going */
         ksocknal_data_ready (sock->sk, 0);
@@ -332,8 +328,8 @@ ksocknal_close_sock(ptl_nid_t nid)
                 /* NB I _have_ to restore the callback, rather than storing
                  * a noop, since the socket could survive past this module
                  * being unloaded!! */
-                conn->ksnc_sock->sk->data_ready = conn->ksnc_saved_data_ready;
-                conn->ksnc_sock->sk->write_space = conn->ksnc_saved_write_space;
+                conn->ksnc_sock->sk->sk_data_ready = conn->ksnc_saved_data_ready;
+                conn->ksnc_sock->sk->sk_write_space = conn->ksnc_saved_write_space;
 
                 /* OK; no more callbacks, but they could be in progress now,
                  * so wait for them to complete... */
@@ -342,7 +338,7 @@ ksocknal_close_sock(ptl_nid_t nid)
                 /* ...however if I get the lock before a callback gets it,
                  * this will make them noop
                  */
-                conn->ksnc_sock->sk->user_data = NULL;
+                conn->ksnc_sock->sk->sk_user_data = NULL;
 
                 /* And drop the scheduler's connection count while I've got
                  * the exclusive lock */
@@ -388,8 +384,8 @@ ksocknal_push_conn (ksock_conn_t *conn)
         oldmm = get_fs ();
         set_fs (KERNEL_DS);
 
-        rc = sk->prot->setsockopt (sk, SOL_TCP, TCP_NODELAY,
-                                   (char *)&val, sizeof (val));
+        rc = sk->sk_prot->setsockopt (sk, SOL_TCP, TCP_NODELAY,
+                                      (char *)&val, sizeof (val));
         LASSERT (rc == 0);
 
         set_fs (oldmm);
@@ -508,9 +504,9 @@ _ksocknal_put_conn (ksock_conn_t *conn)
          * "That's a summons, mate..." */
 
         LASSERT (atomic_read (&conn->ksnc_refcount) == 0);
-        LASSERT (conn->ksnc_sock->sk->data_ready != ksocknal_data_ready);
-        LASSERT (conn->ksnc_sock->sk->write_space != ksocknal_write_space);
-        LASSERT (conn->ksnc_sock->sk->user_data == NULL);
+        LASSERT (conn->ksnc_sock->sk->sk_data_ready != ksocknal_data_ready);
+        LASSERT (conn->ksnc_sock->sk->sk_write_space != ksocknal_write_space);
+        LASSERT (conn->ksnc_sock->sk->sk_user_data == NULL);
         LASSERT (!conn->ksnc_rx_scheduled);
 
         spin_lock_irqsave (&ksocknal_data.ksnd_reaper_lock, flags);
index be94bbb..f959889 100644 (file)
 
 #define SOCKNAL_RESCHED         100             /* # scheduler loops before reschedule */
 
-#define SOCKNAL_TX_LOW_WATER(sk) (((sk)->sndbuf*8)/10)
+#define SOCKNAL_TX_LOW_WATER(sk) (((sk)->sk_sndbuf*8)/10)
+
+#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,5,72))
+# define sk_data_ready data_ready
+# define sk_write_space write_space
+# define sk_user_data   user_data
+# define sk_prot        prot
+# define sk_sndbuf      sndbuf
+# define sk_socket      socket
+#endif
 
 typedef struct                                  /* pool of forwarding buffers */
 {
index 16ee04a..ef74bc9 100644 (file)
@@ -1467,10 +1467,10 @@ ksocknal_data_ready (struct sock *sk, int n)
         /* interleave correctly with closing sockets... */
         read_lock (&ksocknal_data.ksnd_socklist_lock);
 
-        conn = sk->user_data;
+        conn = sk->sk_user_data;
         if (conn == NULL) {             /* raced with ksocknal_close_sock */
-                LASSERT (sk->data_ready != &ksocknal_data_ready);
-                sk->data_ready (sk, n);
+                LASSERT (sk->sk_data_ready != &ksocknal_data_ready);
+                sk->sk_data_ready (sk, n);
         } else if (!conn->ksnc_rx_ready) {        /* new news */
                 /* Set ASAP in case of concurrent calls to me */
                 conn->ksnc_rx_ready = 1;
@@ -1511,7 +1511,7 @@ ksocknal_write_space (struct sock *sk)
         /* interleave correctly with closing sockets... */
         read_lock (&ksocknal_data.ksnd_socklist_lock);
 
-        conn = sk->user_data;
+        conn = sk->sk_user_data;
 
         CDEBUG(D_NET, "sk %p wspace %d low water %d conn %p%s%s%s\n",
                sk, tcp_wspace(sk), SOCKNAL_TX_LOW_WATER(sk), conn,
@@ -1523,10 +1523,10 @@ ksocknal_write_space (struct sock *sk)
                                       " empty" : " queued"));
 
         if (conn == NULL) {             /* raced with ksocknal_close_sock */
-                LASSERT (sk->write_space != &ksocknal_write_space);
-                sk->write_space (sk);
+                LASSERT (sk->sk_write_space != &ksocknal_write_space);
+                sk->sk_write_space (sk);
         } else if (tcp_wspace(sk) >= SOCKNAL_TX_LOW_WATER(sk)) { /* got enough space */
-                clear_bit (SOCK_NOSPACE, &sk->socket->flags);
+                clear_bit (SOCK_NOSPACE, &sk->sk_socket->flags);
 
                 if (!conn->ksnc_tx_ready) {      /* new news */
                         /* Set ASAP in case of concurrent calls to me */
index 9a3e64a..bc563fe 100644 (file)
 
 #define LOWEST_BIT_SET(x)      ((x) & ~((x) - 1))
 
-#ifndef CONFIG_SMP
-# define smp_processor_id() 0
-#endif
-
 /*
  *  Debugging
  */
@@ -104,7 +100,7 @@ extern unsigned int portal_printk;
         } while (0)
 #else
 #define CHECK_STACK(stack) do{}while(0)
-#define CDEBUG_STACK(var) (0)
+#define CDEBUG_STACK(var) (0L)
 #endif
 
 #if 1
index fc952f9..da2b453 100644 (file)
@@ -169,7 +169,7 @@ ksocknal_add_sock (ptl_nid_t nid, int fd, int bind_irq)
         struct socket     *sock = NULL;
         ksock_sched_t     *sched = NULL;
         unsigned int       irq = 0;
-        struct net_device *dev = NULL;
+        struct dst_entry  *dst;
         int                ret;
         int                idx;
         ENTRY;
@@ -194,8 +194,8 @@ ksocknal_add_sock (ptl_nid_t nid, int fd, int bind_irq)
 
         conn->ksnc_file = file;
         conn->ksnc_sock = sock;
-        conn->ksnc_saved_data_ready = sock->sk->data_ready;
-        conn->ksnc_saved_write_space = sock->sk->write_space;
+        conn->ksnc_saved_data_ready = sock->sk->sk_data_ready;
+        conn->ksnc_saved_write_space = sock->sk->sk_write_space;
         conn->ksnc_peernid = nid;
         atomic_set (&conn->ksnc_refcount, 1);    /* 1 ref for socklist */
 
@@ -207,22 +207,18 @@ ksocknal_add_sock (ptl_nid_t nid, int fd, int bind_irq)
         conn->ksnc_tx_ready = 0;
         conn->ksnc_tx_scheduled = 0;
 
-#warning check it is OK to derefence sk->dst_cache->dev like this...
-        lock_sock (conn->ksnc_sock->sk);
-
-        if (conn->ksnc_sock->sk->dst_cache != NULL) {
-                dev = conn->ksnc_sock->sk->dst_cache->dev;
-                if (dev != NULL) {
-                        irq = dev->irq;
+        dst = sk_dst_get (conn->ksnc_sock->sk);
+        if (dst != NULL) {
+                if (dst->dev != NULL) {
+                        irq = dst->dev->irq;
                         if (irq >= NR_IRQS) {
                                 CERROR ("Unexpected IRQ %x\n", irq);
                                 irq = 0;
                         }
                 }
+                dst_release (dst);
         }
 
-        release_sock (conn->ksnc_sock->sk);
-
         write_lock_irqsave (&ksocknal_data.ksnd_socklist_lock, flags);
 
         if (irq == 0 ||
@@ -271,9 +267,9 @@ ksocknal_add_sock (ptl_nid_t nid, int fd, int bind_irq)
                 ksocknal_bind_irq (irq, sched - ksocknal_data.ksnd_schedulers);
 
         /* NOW it's safe to get called back when socket is ready... */
-        sock->sk->user_data = conn;
-        sock->sk->data_ready = ksocknal_data_ready;
-        sock->sk->write_space = ksocknal_write_space;
+        sock->sk->sk_user_data = conn;
+        sock->sk->sk_data_ready = ksocknal_data_ready;
+        sock->sk->sk_write_space = ksocknal_write_space;
 
         /* ...which I call right now to get things going */
         ksocknal_data_ready (sock->sk, 0);
@@ -332,8 +328,8 @@ ksocknal_close_sock(ptl_nid_t nid)
                 /* NB I _have_ to restore the callback, rather than storing
                  * a noop, since the socket could survive past this module
                  * being unloaded!! */
-                conn->ksnc_sock->sk->data_ready = conn->ksnc_saved_data_ready;
-                conn->ksnc_sock->sk->write_space = conn->ksnc_saved_write_space;
+                conn->ksnc_sock->sk->sk_data_ready = conn->ksnc_saved_data_ready;
+                conn->ksnc_sock->sk->sk_write_space = conn->ksnc_saved_write_space;
 
                 /* OK; no more callbacks, but they could be in progress now,
                  * so wait for them to complete... */
@@ -342,7 +338,7 @@ ksocknal_close_sock(ptl_nid_t nid)
                 /* ...however if I get the lock before a callback gets it,
                  * this will make them noop
                  */
-                conn->ksnc_sock->sk->user_data = NULL;
+                conn->ksnc_sock->sk->sk_user_data = NULL;
 
                 /* And drop the scheduler's connection count while I've got
                  * the exclusive lock */
@@ -388,8 +384,8 @@ ksocknal_push_conn (ksock_conn_t *conn)
         oldmm = get_fs ();
         set_fs (KERNEL_DS);
 
-        rc = sk->prot->setsockopt (sk, SOL_TCP, TCP_NODELAY,
-                                   (char *)&val, sizeof (val));
+        rc = sk->sk_prot->setsockopt (sk, SOL_TCP, TCP_NODELAY,
+                                      (char *)&val, sizeof (val));
         LASSERT (rc == 0);
 
         set_fs (oldmm);
@@ -508,9 +504,9 @@ _ksocknal_put_conn (ksock_conn_t *conn)
          * "That's a summons, mate..." */
 
         LASSERT (atomic_read (&conn->ksnc_refcount) == 0);
-        LASSERT (conn->ksnc_sock->sk->data_ready != ksocknal_data_ready);
-        LASSERT (conn->ksnc_sock->sk->write_space != ksocknal_write_space);
-        LASSERT (conn->ksnc_sock->sk->user_data == NULL);
+        LASSERT (conn->ksnc_sock->sk->sk_data_ready != ksocknal_data_ready);
+        LASSERT (conn->ksnc_sock->sk->sk_write_space != ksocknal_write_space);
+        LASSERT (conn->ksnc_sock->sk->sk_user_data == NULL);
         LASSERT (!conn->ksnc_rx_scheduled);
 
         spin_lock_irqsave (&ksocknal_data.ksnd_reaper_lock, flags);
index be94bbb..f959889 100644 (file)
 
 #define SOCKNAL_RESCHED         100             /* # scheduler loops before reschedule */
 
-#define SOCKNAL_TX_LOW_WATER(sk) (((sk)->sndbuf*8)/10)
+#define SOCKNAL_TX_LOW_WATER(sk) (((sk)->sk_sndbuf*8)/10)
+
+#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,5,72))
+# define sk_data_ready data_ready
+# define sk_write_space write_space
+# define sk_user_data   user_data
+# define sk_prot        prot
+# define sk_sndbuf      sndbuf
+# define sk_socket      socket
+#endif
 
 typedef struct                                  /* pool of forwarding buffers */
 {
index 16ee04a..ef74bc9 100644 (file)
@@ -1467,10 +1467,10 @@ ksocknal_data_ready (struct sock *sk, int n)
         /* interleave correctly with closing sockets... */
         read_lock (&ksocknal_data.ksnd_socklist_lock);
 
-        conn = sk->user_data;
+        conn = sk->sk_user_data;
         if (conn == NULL) {             /* raced with ksocknal_close_sock */
-                LASSERT (sk->data_ready != &ksocknal_data_ready);
-                sk->data_ready (sk, n);
+                LASSERT (sk->sk_data_ready != &ksocknal_data_ready);
+                sk->sk_data_ready (sk, n);
         } else if (!conn->ksnc_rx_ready) {        /* new news */
                 /* Set ASAP in case of concurrent calls to me */
                 conn->ksnc_rx_ready = 1;
@@ -1511,7 +1511,7 @@ ksocknal_write_space (struct sock *sk)
         /* interleave correctly with closing sockets... */
         read_lock (&ksocknal_data.ksnd_socklist_lock);
 
-        conn = sk->user_data;
+        conn = sk->sk_user_data;
 
         CDEBUG(D_NET, "sk %p wspace %d low water %d conn %p%s%s%s\n",
                sk, tcp_wspace(sk), SOCKNAL_TX_LOW_WATER(sk), conn,
@@ -1523,10 +1523,10 @@ ksocknal_write_space (struct sock *sk)
                                       " empty" : " queued"));
 
         if (conn == NULL) {             /* raced with ksocknal_close_sock */
-                LASSERT (sk->write_space != &ksocknal_write_space);
-                sk->write_space (sk);
+                LASSERT (sk->sk_write_space != &ksocknal_write_space);
+                sk->sk_write_space (sk);
         } else if (tcp_wspace(sk) >= SOCKNAL_TX_LOW_WATER(sk)) { /* got enough space */
-                clear_bit (SOCK_NOSPACE, &sk->socket->flags);
+                clear_bit (SOCK_NOSPACE, &sk->sk_socket->flags);
 
                 if (!conn->ksnc_tx_ready) {      /* new news */
                         /* Set ASAP in case of concurrent calls to me */