aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVarun Prakash <varun@chelsio.com>2016-09-13 11:54:01 -0400
committerDavid S. Miller <davem@davemloft.net>2016-09-15 20:49:20 -0400
commitcc516700c7edab4197d08998ac023c3043369391 (patch)
tree7066c61e5639f393e5edf15e36d1c8712d78c1ea
parent44c6d06992ac663e5163bdbe00844cb845ed5703 (diff)
libcxgb,iw_cxgb4,cxgbit: add cxgb_compute_wscale()
Add cxgb_compute_wscale() 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>
-rw-r--r--drivers/infiniband/hw/cxgb4/cm.c12
-rw-r--r--drivers/infiniband/hw/cxgb4/iw_cxgb4.h9
-rw-r--r--drivers/net/ethernet/chelsio/libcxgb/libcxgb_cm.h9
-rw-r--r--drivers/target/iscsi/cxgbit/cxgbit_cm.c11
4 files changed, 16 insertions, 25 deletions
diff --git a/drivers/infiniband/hw/cxgb4/cm.c b/drivers/infiniband/hw/cxgb4/cm.c
index c3c678ff6ebb..b9d77df0a2f6 100644
--- a/drivers/infiniband/hw/cxgb4/cm.c
+++ b/drivers/infiniband/hw/cxgb4/cm.c
@@ -689,7 +689,7 @@ static int send_connect(struct c4iw_ep *ep)
689 u64 opt0; 689 u64 opt0;
690 u32 opt2; 690 u32 opt2;
691 unsigned int mtu_idx; 691 unsigned int mtu_idx;
692 int wscale; 692 u32 wscale;
693 int win, sizev4, sizev6, wrlen; 693 int win, sizev4, sizev6, wrlen;
694 struct sockaddr_in *la = (struct sockaddr_in *) 694 struct sockaddr_in *la = (struct sockaddr_in *)
695 &ep->com.local_addr; 695 &ep->com.local_addr;
@@ -739,7 +739,7 @@ static int send_connect(struct c4iw_ep *ep)
739 cxgb_best_mtu(ep->com.dev->rdev.lldi.mtus, ep->mtu, &mtu_idx, 739 cxgb_best_mtu(ep->com.dev->rdev.lldi.mtus, ep->mtu, &mtu_idx,
740 enable_tcp_timestamps, 740 enable_tcp_timestamps,
741 (ep->com.remote_addr.ss_family == AF_INET) ? 0 : 1); 741 (ep->com.remote_addr.ss_family == AF_INET) ? 0 : 1);
742 wscale = compute_wscale(rcv_win); 742 wscale = cxgb_compute_wscale(rcv_win);
743 743
744 /* 744 /*
745 * Specify the largest window that will fit in opt0. The 745 * Specify the largest window that will fit in opt0. The
@@ -1891,7 +1891,7 @@ static int send_fw_act_open_req(struct c4iw_ep *ep, unsigned int atid)
1891 struct sk_buff *skb; 1891 struct sk_buff *skb;
1892 struct fw_ofld_connection_wr *req; 1892 struct fw_ofld_connection_wr *req;
1893 unsigned int mtu_idx; 1893 unsigned int mtu_idx;
1894 int wscale; 1894 u32 wscale;
1895 struct sockaddr_in *sin; 1895 struct sockaddr_in *sin;
1896 int win; 1896 int win;
1897 1897
@@ -1919,7 +1919,7 @@ static int send_fw_act_open_req(struct c4iw_ep *ep, unsigned int atid)
1919 cxgb_best_mtu(ep->com.dev->rdev.lldi.mtus, ep->mtu, &mtu_idx, 1919 cxgb_best_mtu(ep->com.dev->rdev.lldi.mtus, ep->mtu, &mtu_idx,
1920 enable_tcp_timestamps, 1920 enable_tcp_timestamps,
1921 (ep->com.remote_addr.ss_family == AF_INET) ? 0 : 1); 1921 (ep->com.remote_addr.ss_family == AF_INET) ? 0 : 1);
1922 wscale = compute_wscale(rcv_win); 1922 wscale = cxgb_compute_wscale(rcv_win);
1923 1923
1924 /* 1924 /*
1925 * Specify the largest window that will fit in opt0. The 1925 * Specify the largest window that will fit in opt0. The
@@ -2339,7 +2339,7 @@ static int accept_cr(struct c4iw_ep *ep, struct sk_buff *skb,
2339 unsigned int mtu_idx; 2339 unsigned int mtu_idx;
2340 u64 opt0; 2340 u64 opt0;
2341 u32 opt2; 2341 u32 opt2;
2342 int wscale; 2342 u32 wscale;
2343 struct cpl_t5_pass_accept_rpl *rpl5 = NULL; 2343 struct cpl_t5_pass_accept_rpl *rpl5 = NULL;
2344 int win; 2344 int win;
2345 enum chip_type adapter_type = ep->com.dev->rdev.lldi.adapter_type; 2345 enum chip_type adapter_type = ep->com.dev->rdev.lldi.adapter_type;
@@ -2363,7 +2363,7 @@ static int accept_cr(struct c4iw_ep *ep, struct sk_buff *skb,
2363 cxgb_best_mtu(ep->com.dev->rdev.lldi.mtus, ep->mtu, &mtu_idx, 2363 cxgb_best_mtu(ep->com.dev->rdev.lldi.mtus, ep->mtu, &mtu_idx,
2364 enable_tcp_timestamps && req->tcpopt.tstamp, 2364 enable_tcp_timestamps && req->tcpopt.tstamp,
2365 (ep->com.remote_addr.ss_family == AF_INET) ? 0 : 1); 2365 (ep->com.remote_addr.ss_family == AF_INET) ? 0 : 1);
2366 wscale = compute_wscale(rcv_win); 2366 wscale = cxgb_compute_wscale(rcv_win);
2367 2367
2368 /* 2368 /*
2369 * Specify the largest window that will fit in opt0. The 2369 * Specify the largest window that will fit in opt0. The
diff --git a/drivers/infiniband/hw/cxgb4/iw_cxgb4.h b/drivers/infiniband/hw/cxgb4/iw_cxgb4.h
index aa47e0ae80bc..6a9bef1f09a8 100644
--- a/drivers/infiniband/hw/cxgb4/iw_cxgb4.h
+++ b/drivers/infiniband/hw/cxgb4/iw_cxgb4.h
@@ -881,15 +881,6 @@ static inline struct c4iw_listen_ep *to_listen_ep(struct iw_cm_id *cm_id)
881 return cm_id->provider_data; 881 return cm_id->provider_data;
882} 882}
883 883
884static inline int compute_wscale(int win)
885{
886 int wscale = 0;
887
888 while (wscale < 14 && (65535<<wscale) < win)
889 wscale++;
890 return wscale;
891}
892
893static inline int ocqp_supported(const struct cxgb4_lld_info *infop) 884static inline int ocqp_supported(const struct cxgb4_lld_info *infop)
894{ 885{
895#if defined(__i386__) || defined(__x86_64__) || defined(CONFIG_PPC64) 886#if defined(__i386__) || defined(__x86_64__) || defined(CONFIG_PPC64)
diff --git a/drivers/net/ethernet/chelsio/libcxgb/libcxgb_cm.h b/drivers/net/ethernet/chelsio/libcxgb/libcxgb_cm.h
index 7fb4feb3c221..ecf3baa940b9 100644
--- a/drivers/net/ethernet/chelsio/libcxgb/libcxgb_cm.h
+++ b/drivers/net/ethernet/chelsio/libcxgb/libcxgb_cm.h
@@ -74,4 +74,13 @@ cxgb_best_mtu(const unsigned short *mtus, unsigned short mtu,
74 74
75 cxgb4_best_aligned_mtu(mtus, hdr_size, data_size, 8, idx); 75 cxgb4_best_aligned_mtu(mtus, hdr_size, data_size, 8, idx);
76} 76}
77
78static inline u32 cxgb_compute_wscale(u32 win)
79{
80 u32 wscale = 0;
81
82 while (wscale < 14 && (65535 << wscale) < win)
83 wscale++;
84 return wscale;
85}
77#endif 86#endif
diff --git a/drivers/target/iscsi/cxgbit/cxgbit_cm.c b/drivers/target/iscsi/cxgbit/cxgbit_cm.c
index b09c09ba9659..cd29c91d01fc 100644
--- a/drivers/target/iscsi/cxgbit/cxgbit_cm.c
+++ b/drivers/target/iscsi/cxgbit/cxgbit_cm.c
@@ -1085,15 +1085,6 @@ out:
1085 return -ENOMEM; 1085 return -ENOMEM;
1086} 1086}
1087 1087
1088static u32 cxgbit_compute_wscale(u32 win)
1089{
1090 u32 wscale = 0;
1091
1092 while (wscale < 14 && (65535 << wscale) < win)
1093 wscale++;
1094 return wscale;
1095}
1096
1097static void 1088static void
1098cxgbit_pass_accept_rpl(struct cxgbit_sock *csk, struct cpl_pass_accept_req *req) 1089cxgbit_pass_accept_rpl(struct cxgbit_sock *csk, struct cpl_pass_accept_req *req)
1099{ 1090{
@@ -1124,7 +1115,7 @@ cxgbit_pass_accept_rpl(struct cxgbit_sock *csk, struct cpl_pass_accept_req *req)
1124 cxgb_best_mtu(csk->com.cdev->lldi.mtus, csk->mtu, &mtu_idx, 1115 cxgb_best_mtu(csk->com.cdev->lldi.mtus, csk->mtu, &mtu_idx,
1125 req->tcpopt.tstamp, 1116 req->tcpopt.tstamp,
1126 (csk->com.remote_addr.ss_family == AF_INET) ? 0 : 1); 1117 (csk->com.remote_addr.ss_family == AF_INET) ? 0 : 1);
1127 wscale = cxgbit_compute_wscale(csk->rcv_win); 1118 wscale = cxgb_compute_wscale(csk->rcv_win);
1128 /* 1119 /*
1129 * Specify the largest window that will fit in opt0. The 1120 * Specify the largest window that will fit in opt0. The
1130 * remainder will be specified in the rx_data_ack. 1121 * remainder will be specified in the rx_data_ack.