Whamcloud - gitweb
LU-2675 lnet: remove lnet/include/lnet/linux/
[fs/lustre-release.git] / lnet / klnds / ralnd / ralnd_cb.c
index ba744c6..2e6ba70 100644 (file)
@@ -38,6 +38,7 @@
  * Author: Eric Barton <eric@bartonsoftware.com>
  */
 
+#include <asm/page.h>
 #include "ralnd.h"
 
 void
@@ -229,7 +230,7 @@ kranal_setup_phys_buffer (kra_tx_t *tx, int nkiov, lnet_kiov_t *kiov,
         tx->tx_nob = nob;
         tx->tx_buffer = (void *)((unsigned long)(kiov->kiov_offset + offset));
 
-        phys->Address = lnet_page2phys(kiov->kiov_page);
+       phys->Address = page_to_phys(kiov->kiov_page);
         phys++;
 
         resid = nob - (kiov->kiov_len - offset);
@@ -254,7 +255,7 @@ kranal_setup_phys_buffer (kra_tx_t *tx, int nkiov, lnet_kiov_t *kiov,
                         return -EMSGSIZE;
                 }
 
-                phys->Address = lnet_page2phys(kiov->kiov_page);
+               phys->Address = page_to_phys(kiov->kiov_page);
                 phys++;
 
                 resid -= PAGE_SIZE;
@@ -385,34 +386,34 @@ kranal_unmap_buffer (kra_tx_t *tx)
 void
 kranal_tx_done (kra_tx_t *tx, int completion)
 {
-        lnet_msg_t      *lnetmsg[2];
-        unsigned long    flags;
-        int              i;
+       lnet_msg_t      *lnetmsg[2];
+       unsigned long    flags;
+       int              i;
 
-        LASSERT (!cfs_in_interrupt());
+       LASSERT (!in_interrupt());
 
-        kranal_unmap_buffer(tx);
+       kranal_unmap_buffer(tx);
 
-        lnetmsg[0] = tx->tx_lntmsg[0]; tx->tx_lntmsg[0] = NULL;
-        lnetmsg[1] = tx->tx_lntmsg[1]; tx->tx_lntmsg[1] = NULL;
+       lnetmsg[0] = tx->tx_lntmsg[0]; tx->tx_lntmsg[0] = NULL;
+       lnetmsg[1] = tx->tx_lntmsg[1]; tx->tx_lntmsg[1] = NULL;
 
-        tx->tx_buftype = RANAL_BUF_NONE;
-        tx->tx_msg.ram_type = RANAL_MSG_NONE;
-        tx->tx_conn = NULL;
+       tx->tx_buftype = RANAL_BUF_NONE;
+       tx->tx_msg.ram_type = RANAL_MSG_NONE;
+       tx->tx_conn = NULL;
 
        spin_lock_irqsave(&kranal_data.kra_tx_lock, flags);
 
-        cfs_list_add_tail(&tx->tx_list, &kranal_data.kra_idle_txs);
+       cfs_list_add_tail(&tx->tx_list, &kranal_data.kra_idle_txs);
 
        spin_unlock_irqrestore(&kranal_data.kra_tx_lock, flags);
 
-        /* finalize AFTER freeing lnet msgs */
-        for (i = 0; i < 2; i++) {
-                if (lnetmsg[i] == NULL)
-                        continue;
+       /* finalize AFTER freeing lnet msgs */
+       for (i = 0; i < 2; i++) {
+               if (lnetmsg[i] == NULL)
+                       continue;
 
-                lnet_finalize(kranal_data.kra_ni, lnetmsg[i], completion);
-        }
+               lnet_finalize(kranal_data.kra_ni, lnetmsg[i], completion);
+       }
 }
 
 kra_conn_t *
@@ -622,20 +623,20 @@ kranal_send (lnet_ni_t *ni, void *private, lnet_msg_t *lntmsg)
 
         /* NB 'private' is different depending on what we're sending.... */
 
-        CDEBUG(D_NET, "sending %d bytes in %d frags to %s\n",
-               nob, niov, libcfs_id2str(target));
+       CDEBUG(D_NET, "sending %d bytes in %d frags to %s\n",
+              nob, niov, libcfs_id2str(target));
 
-        LASSERT (nob == 0 || niov > 0);
-        LASSERT (niov <= LNET_MAX_IOV);
+       LASSERT (nob == 0 || niov > 0);
+       LASSERT (niov <= LNET_MAX_IOV);
 
-        LASSERT (!cfs_in_interrupt());
-        /* payload is either all vaddrs or all pages */
-        LASSERT (!(kiov != NULL && iov != NULL));
+       LASSERT (!in_interrupt());
+       /* payload is either all vaddrs or all pages */
+       LASSERT (!(kiov != NULL && iov != NULL));
 
-        if (routing) {
-                CERROR ("Can't route\n");
-                return -EIO;
-        }
+       if (routing) {
+               CERROR ("Can't route\n");
+               return -EIO;
+       }
 
         switch(type) {
         default:
@@ -795,18 +796,18 @@ kranal_recv (lnet_ni_t *ni, void *private, lnet_msg_t *lntmsg,
              struct iovec *iov, lnet_kiov_t *kiov,
              unsigned int offset, unsigned int mlen, unsigned int rlen)
 {
-        kra_conn_t  *conn = private;
-        kra_msg_t   *rxmsg = conn->rac_rxmsg;
-        kra_tx_t    *tx;
-        void        *buffer;
-        int          rc;
+       kra_conn_t  *conn = private;
+       kra_msg_t   *rxmsg = conn->rac_rxmsg;
+       kra_tx_t    *tx;
+       void        *buffer;
+       int          rc;
 
-        LASSERT (mlen <= rlen);
-        LASSERT (!cfs_in_interrupt());
-        /* Either all pages or all vaddrs */
-        LASSERT (!(kiov != NULL && iov != NULL));
+       LASSERT (mlen <= rlen);
+       LASSERT (!in_interrupt());
+       /* Either all pages or all vaddrs */
+       LASSERT (!(kiov != NULL && iov != NULL));
 
-        CDEBUG(D_NET, "conn %p, rxmsg %p, lntmsg %p\n", conn, rxmsg, lntmsg);
+       CDEBUG(D_NET, "conn %p, rxmsg %p, lntmsg %p\n", conn, rxmsg, lntmsg);
 
         switch(rxmsg->ram_type) {
         default:
@@ -893,17 +894,17 @@ kranal_recv (lnet_ni_t *ni, void *private, lnet_msg_t *lntmsg,
 int
 kranal_thread_start(int(*fn)(void *arg), void *arg, char *name)
 {
-       cfs_task_t *task = cfs_thread_run(fn, arg, name);
+       struct task_struct *task = cfs_thread_run(fn, arg, name);
 
        if (!IS_ERR(task))
-               cfs_atomic_inc(&kranal_data.kra_nthreads);
+               atomic_inc(&kranal_data.kra_nthreads);
        return PTR_ERR(task);
 }
 
 void
 kranal_thread_fini (void)
 {
-        cfs_atomic_dec(&kranal_data.kra_nthreads);
+       atomic_dec(&kranal_data.kra_nthreads);
 }
 
 int
@@ -919,15 +920,16 @@ kranal_check_conn_timeouts (kra_conn_t *conn)
                  conn->rac_state == RANAL_CONN_CLOSING);
 
        if (!conn->rac_close_sent &&
-           cfs_time_aftereq(now, conn->rac_last_tx + conn->rac_keepalive *
-                            HZ)) {
+           cfs_time_aftereq(now, conn->rac_last_tx +
+                            msecs_to_jiffies(conn->rac_keepalive *
+                                             MSEC_PER_SEC))) {
                /* not sent in a while; schedule conn so scheduler sends a keepalive */
                CDEBUG(D_NET, "Scheduling keepalive %p->%s\n",
                       conn, libcfs_nid2str(conn->rac_peer->rap_nid));
                kranal_schedule_conn(conn);
        }
 
-       timeout = conn->rac_timeout * HZ;
+       timeout = msecs_to_jiffies(conn->rac_timeout * MSEC_PER_SEC);
 
        if (!conn->rac_close_recvd &&
            cfs_time_aftereq(now, conn->rac_last_rx + timeout)) {
@@ -935,7 +937,7 @@ kranal_check_conn_timeouts (kra_conn_t *conn)
                       (conn->rac_state == RANAL_CONN_ESTABLISHED) ?
                       "Nothing" : "CLOSE not",
                       libcfs_nid2str(conn->rac_peer->rap_nid),
-                      (now - conn->rac_last_rx)/HZ);
+                      jiffies_to_msecs(now - conn->rac_last_rx)/MSEC_PER_SEC);
                return -ETIMEDOUT;
        }
 
@@ -955,7 +957,7 @@ kranal_check_conn_timeouts (kra_conn_t *conn)
                        spin_unlock_irqrestore(&conn->rac_lock, flags);
                        CERROR("tx on fmaq for %s blocked %lu seconds\n",
                               libcfs_nid2str(conn->rac_peer->rap_nid),
-                              (now - tx->tx_qtime)/HZ);
+                              jiffies_to_msecs(now-tx->tx_qtime)/MSEC_PER_SEC);
                        return -ETIMEDOUT;
                }
        }
@@ -967,7 +969,7 @@ kranal_check_conn_timeouts (kra_conn_t *conn)
                        spin_unlock_irqrestore(&conn->rac_lock, flags);
                        CERROR("tx on rdmaq for %s blocked %lu seconds\n",
                               libcfs_nid2str(conn->rac_peer->rap_nid),
-                              (now - tx->tx_qtime)/HZ);
+                              jiffies_to_msecs(now-tx->tx_qtime)/MSEC_PER_SEC);
                        return -ETIMEDOUT;
                }
        }
@@ -979,7 +981,7 @@ kranal_check_conn_timeouts (kra_conn_t *conn)
                        spin_unlock_irqrestore(&conn->rac_lock, flags);
                        CERROR("tx on replyq for %s blocked %lu seconds\n",
                               libcfs_nid2str(conn->rac_peer->rap_nid),
-                              (now - tx->tx_qtime)/HZ);
+                              jiffies_to_msecs(now-tx->tx_qtime)/MSEC_PER_SEC);
                        return -ETIMEDOUT;
                }
        }
@@ -1231,7 +1233,7 @@ kranal_reaper (void *arg)
                        conn_index = (conn_index + 1) % conn_entries;
                }
 
-               next_check_time += p * HZ;
+               next_check_time += msecs_to_jiffies(p * MSEC_PER_SEC);
 
                spin_lock_irqsave(&kranal_data.kra_reaper_lock, flags);
 
@@ -1420,11 +1422,13 @@ kranal_sendmsg(kra_conn_t *conn, kra_msg_t *msg,
 
         case RAP_NOT_DONE:
                if (cfs_time_aftereq(jiffies,
-                                    conn->rac_last_tx + conn->rac_keepalive *
-                                    HZ))
+                                    conn->rac_last_tx +
+                                    msecs_to_jiffies(conn->rac_keepalive *
+                                                     MSEC_PER_SEC)))
                        CWARN("EAGAIN sending %02x (idle %lu secs)\n",
                              msg->ram_type,
-                             (jiffies - conn->rac_last_tx)/HZ);
+                             jiffies_to_msecs(jiffies - conn->rac_last_tx) /
+                             MSEC_PER_SEC);
                return -EAGAIN;
         }
 }
@@ -1456,7 +1460,8 @@ kranal_process_fmaq (kra_conn_t *conn)
 
                        if (cfs_time_aftereq(jiffies,
                                             conn->rac_last_tx +
-                                            conn->rac_keepalive * HZ)) {
+                                            msecs_to_jiffies(conn->rac_keepalive *
+                                                             MSEC_PER_SEC))) {
                                CDEBUG(D_NET, "sending NOOP (rdma in progress)\n");
                                kranal_init_msg(&conn->rac_msg, RANAL_MSG_NOOP);
                                kranal_sendmsg(conn, &conn->rac_msg, NULL, 0);
@@ -1495,11 +1500,13 @@ kranal_process_fmaq (kra_conn_t *conn)
                spin_unlock_irqrestore(&conn->rac_lock, flags);
 
                if (cfs_time_aftereq(jiffies,
-                                    conn->rac_last_tx + conn->rac_keepalive *
-                                    HZ)) {
+                                    conn->rac_last_tx +
+                                    msecs_to_jiffies(conn->rac_keepalive *
+                                                     MSEC_PER_SEC))) {
                        CDEBUG(D_NET, "sending NOOP -> %s (%p idle %lu(%ld))\n",
                               libcfs_nid2str(conn->rac_peer->rap_nid), conn,
-                              (jiffies - conn->rac_last_tx)/HZ,
+                              jiffies_to_msecs(jiffies - conn->rac_last_tx) /
+                              MSEC_PER_SEC,
                               conn->rac_keepalive);
                        kranal_init_msg(&conn->rac_msg, RANAL_MSG_NOOP);
                        kranal_sendmsg(conn, &conn->rac_msg, NULL, 0);
@@ -1911,7 +1918,7 @@ int kranal_process_new_conn (kra_conn_t *conn)
 
        LASSERT (rrc == RAP_NOT_DONE);
        if (!cfs_time_aftereq(jiffies, conn->rac_last_tx +
-                             conn->rac_timeout * HZ))
+                             msecs_to_jiffies(conn->rac_timeout*MSEC_PER_SEC)))
                return -EAGAIN;
 
        /* Too late */
@@ -2021,10 +2028,12 @@ kranal_scheduler (void *arg)
                                /* retry with exponential backoff until HZ */
                                if (conn->rac_keepalive == 0)
                                        conn->rac_keepalive = 1;
-                               else if (conn->rac_keepalive <= HZ)
+                               else if (conn->rac_keepalive <=
+                                        msecs_to_jiffies(MSEC_PER_SEC))
                                        conn->rac_keepalive *= 2;
                                else
-                                       conn->rac_keepalive += HZ;
+                                       conn->rac_keepalive +=
+                                               msecs_to_jiffies(MSEC_PER_SEC);
 
                                deadline = conn->rac_last_tx + conn->rac_keepalive;
                                spin_lock_irqsave(&dev->rad_lock, flags);