libcxgb,iw_cxgb4,cxgbit: add cxgb_best_mtu()
authorVarun Prakash <varun@chelsio.com>
Tue, 13 Sep 2016 15:54:00 +0000 (21:24 +0530)
committerDavid S. Miller <davem@davemloft.net>
Fri, 16 Sep 2016 00:49:20 +0000 (20:49 -0400)
Add cxgb_best_mtu() in libcxgb_cm.h to remove
it's duplicate definitions from cxgb4/cm.c and
cxgbit/cxgbit_cm.c

Signed-off-by: Varun Prakash <varun@chelsio.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/infiniband/hw/cxgb4/cm.c
drivers/net/ethernet/chelsio/libcxgb/libcxgb_cm.h
drivers/target/iscsi/cxgbit/cxgbit_cm.c

index b35fdc0e00043c70888c6a0375cc6cee715f57b2..c3c678ff6ebbc18c5851f94c8f36348e2f2374fa 100644 (file)
@@ -677,20 +677,6 @@ static int send_abort(struct c4iw_ep *ep)
        return c4iw_l2t_send(&ep->com.dev->rdev, req_skb, ep->l2t);
 }
 
-static void best_mtu(const unsigned short *mtus, unsigned short mtu,
-                    unsigned int *idx, int use_ts, int ipv6)
-{
-       unsigned short hdr_size = (ipv6 ?
-                                  sizeof(struct ipv6hdr) :
-                                  sizeof(struct iphdr)) +
-                                 sizeof(struct tcphdr) +
-                                 (use_ts ?
-                                  round_up(TCPOLEN_TIMESTAMP, 4) : 0);
-       unsigned short data_size = mtu - hdr_size;
-
-       cxgb4_best_aligned_mtu(mtus, hdr_size, data_size, 8, idx);
-}
-
 static int send_connect(struct c4iw_ep *ep)
 {
        struct cpl_act_open_req *req = NULL;
@@ -750,9 +736,9 @@ static int send_connect(struct c4iw_ep *ep)
        }
        set_wr_txq(skb, CPL_PRIORITY_SETUP, ep->ctrlq_idx);
 
-       best_mtu(ep->com.dev->rdev.lldi.mtus, ep->mtu, &mtu_idx,
-                enable_tcp_timestamps,
-                (AF_INET == ep->com.remote_addr.ss_family) ? 0 : 1);
+       cxgb_best_mtu(ep->com.dev->rdev.lldi.mtus, ep->mtu, &mtu_idx,
+                     enable_tcp_timestamps,
+                     (ep->com.remote_addr.ss_family == AF_INET) ? 0 : 1);
        wscale = compute_wscale(rcv_win);
 
        /*
@@ -1930,9 +1916,9 @@ static int send_fw_act_open_req(struct c4iw_ep *ep, unsigned int atid)
                        htons(FW_OFLD_CONNECTION_WR_CPLRXDATAACK_F);
        req->tcb.tx_max = (__force __be32) jiffies;
        req->tcb.rcv_adv = htons(1);
-       best_mtu(ep->com.dev->rdev.lldi.mtus, ep->mtu, &mtu_idx,
-                enable_tcp_timestamps,
-                (AF_INET == ep->com.remote_addr.ss_family) ? 0 : 1);
+       cxgb_best_mtu(ep->com.dev->rdev.lldi.mtus, ep->mtu, &mtu_idx,
+                     enable_tcp_timestamps,
+                     (ep->com.remote_addr.ss_family == AF_INET) ? 0 : 1);
        wscale = compute_wscale(rcv_win);
 
        /*
@@ -2374,9 +2360,9 @@ static int accept_cr(struct c4iw_ep *ep, struct sk_buff *skb,
        OPCODE_TID(rpl) = cpu_to_be32(MK_OPCODE_TID(CPL_PASS_ACCEPT_RPL,
                                                    ep->hwtid));
 
-       best_mtu(ep->com.dev->rdev.lldi.mtus, ep->mtu, &mtu_idx,
-                enable_tcp_timestamps && req->tcpopt.tstamp,
-                (AF_INET == ep->com.remote_addr.ss_family) ? 0 : 1);
+       cxgb_best_mtu(ep->com.dev->rdev.lldi.mtus, ep->mtu, &mtu_idx,
+                     enable_tcp_timestamps && req->tcpopt.tstamp,
+                     (ep->com.remote_addr.ss_family == AF_INET) ? 0 : 1);
        wscale = compute_wscale(rcv_win);
 
        /*
index 57fcc98992346512a37f94b7e61af159f832d095..7fb4feb3c221d2c0068bc3a65fe432fafbae400c 100644 (file)
@@ -33,6 +33,9 @@
 #ifndef __LIBCXGB_CM_H__
 #define __LIBCXGB_CM_H__
 
+
+#include <net/tcp.h>
+
 #include <cxgb4.h>
 #include <t4_msg.h>
 
@@ -56,4 +59,19 @@ static inline bool cxgb_is_neg_adv(unsigned int status)
               status == CPL_ERR_PERSIST_NEG_ADVICE ||
               status == CPL_ERR_KEEPALV_NEG_ADVICE;
 }
+
+static inline void
+cxgb_best_mtu(const unsigned short *mtus, unsigned short mtu,
+             unsigned int *idx, int use_ts, int ipv6)
+{
+       unsigned short hdr_size = (ipv6 ?
+                                  sizeof(struct ipv6hdr) :
+                                  sizeof(struct iphdr)) +
+                                 sizeof(struct tcphdr) +
+                                 (use_ts ?
+                                  round_up(TCPOLEN_TIMESTAMP, 4) : 0);
+       unsigned short data_size = mtu - hdr_size;
+
+       cxgb4_best_aligned_mtu(mtus, hdr_size, data_size, 8, idx);
+}
 #endif
index c46bdd5d58ca99c811b24d6cac984180a241310f..b09c09ba965970edf0517296b70b9798f6d03e42 100644 (file)
@@ -997,20 +997,6 @@ cxgbit_l2t_send(struct cxgbit_device *cdev, struct sk_buff *skb,
        return ret < 0 ? ret : 0;
 }
 
-static void
-cxgbit_best_mtu(const unsigned short *mtus, unsigned short mtu,
-               unsigned int *idx, int use_ts, int ipv6)
-{
-       unsigned short hdr_size = (ipv6 ? sizeof(struct ipv6hdr) :
-                                  sizeof(struct iphdr)) +
-                                  sizeof(struct tcphdr) +
-                                  (use_ts ? round_up(TCPOLEN_TIMESTAMP,
-                                   4) : 0);
-       unsigned short data_size = mtu - hdr_size;
-
-       cxgb4_best_aligned_mtu(mtus, hdr_size, data_size, 8, idx);
-}
-
 static void cxgbit_send_rx_credits(struct cxgbit_sock *csk, struct sk_buff *skb)
 {
        if (csk->com.state != CSK_STATE_ESTABLISHED) {
@@ -1135,9 +1121,9 @@ cxgbit_pass_accept_rpl(struct cxgbit_sock *csk, struct cpl_pass_accept_req *req)
        INIT_TP_WR(rpl5, csk->tid);
        OPCODE_TID(rpl5) = cpu_to_be32(MK_OPCODE_TID(CPL_PASS_ACCEPT_RPL,
                                                     csk->tid));
-       cxgbit_best_mtu(csk->com.cdev->lldi.mtus, csk->mtu, &mtu_idx,
-                       req->tcpopt.tstamp,
-                       (csk->com.remote_addr.ss_family == AF_INET) ? 0 : 1);
+       cxgb_best_mtu(csk->com.cdev->lldi.mtus, csk->mtu, &mtu_idx,
+                     req->tcpopt.tstamp,
+                     (csk->com.remote_addr.ss_family == AF_INET) ? 0 : 1);
        wscale = cxgbit_compute_wscale(csk->rcv_win);
        /*
         * Specify the largest window that will fit in opt0. The