diff options
author | Varun Prakash <varun@chelsio.com> | 2016-09-13 11:54:00 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2016-09-15 20:49:20 -0400 |
commit | 44c6d06992ac663e5163bdbe00844cb845ed5703 (patch) | |
tree | 3f88dc3159752fddf5b06345fb6ff2fb564101fa | |
parent | b65eef0a5b1a635f9b056cf74d3ef778f3794a75 (diff) |
libcxgb,iw_cxgb4,cxgbit: add cxgb_best_mtu()
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>
-rw-r--r-- | drivers/infiniband/hw/cxgb4/cm.c | 32 | ||||
-rw-r--r-- | drivers/net/ethernet/chelsio/libcxgb/libcxgb_cm.h | 18 | ||||
-rw-r--r-- | drivers/target/iscsi/cxgbit/cxgbit_cm.c | 20 |
3 files changed, 30 insertions, 40 deletions
diff --git a/drivers/infiniband/hw/cxgb4/cm.c b/drivers/infiniband/hw/cxgb4/cm.c index b35fdc0e0004..c3c678ff6ebb 100644 --- a/drivers/infiniband/hw/cxgb4/cm.c +++ b/drivers/infiniband/hw/cxgb4/cm.c | |||
@@ -677,20 +677,6 @@ static int send_abort(struct c4iw_ep *ep) | |||
677 | return c4iw_l2t_send(&ep->com.dev->rdev, req_skb, ep->l2t); | 677 | return c4iw_l2t_send(&ep->com.dev->rdev, req_skb, ep->l2t); |
678 | } | 678 | } |
679 | 679 | ||
680 | static void best_mtu(const unsigned short *mtus, unsigned short mtu, | ||
681 | unsigned int *idx, int use_ts, int ipv6) | ||
682 | { | ||
683 | unsigned short hdr_size = (ipv6 ? | ||
684 | sizeof(struct ipv6hdr) : | ||
685 | sizeof(struct iphdr)) + | ||
686 | sizeof(struct tcphdr) + | ||
687 | (use_ts ? | ||
688 | round_up(TCPOLEN_TIMESTAMP, 4) : 0); | ||
689 | unsigned short data_size = mtu - hdr_size; | ||
690 | |||
691 | cxgb4_best_aligned_mtu(mtus, hdr_size, data_size, 8, idx); | ||
692 | } | ||
693 | |||
694 | static int send_connect(struct c4iw_ep *ep) | 680 | static int send_connect(struct c4iw_ep *ep) |
695 | { | 681 | { |
696 | struct cpl_act_open_req *req = NULL; | 682 | struct cpl_act_open_req *req = NULL; |
@@ -750,9 +736,9 @@ static int send_connect(struct c4iw_ep *ep) | |||
750 | } | 736 | } |
751 | set_wr_txq(skb, CPL_PRIORITY_SETUP, ep->ctrlq_idx); | 737 | set_wr_txq(skb, CPL_PRIORITY_SETUP, ep->ctrlq_idx); |
752 | 738 | ||
753 | 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, |
754 | enable_tcp_timestamps, | 740 | enable_tcp_timestamps, |
755 | (AF_INET == ep->com.remote_addr.ss_family) ? 0 : 1); | 741 | (ep->com.remote_addr.ss_family == AF_INET) ? 0 : 1); |
756 | wscale = compute_wscale(rcv_win); | 742 | wscale = compute_wscale(rcv_win); |
757 | 743 | ||
758 | /* | 744 | /* |
@@ -1930,9 +1916,9 @@ static int send_fw_act_open_req(struct c4iw_ep *ep, unsigned int atid) | |||
1930 | htons(FW_OFLD_CONNECTION_WR_CPLRXDATAACK_F); | 1916 | htons(FW_OFLD_CONNECTION_WR_CPLRXDATAACK_F); |
1931 | req->tcb.tx_max = (__force __be32) jiffies; | 1917 | req->tcb.tx_max = (__force __be32) jiffies; |
1932 | req->tcb.rcv_adv = htons(1); | 1918 | req->tcb.rcv_adv = htons(1); |
1933 | 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, |
1934 | enable_tcp_timestamps, | 1920 | enable_tcp_timestamps, |
1935 | (AF_INET == ep->com.remote_addr.ss_family) ? 0 : 1); | 1921 | (ep->com.remote_addr.ss_family == AF_INET) ? 0 : 1); |
1936 | wscale = compute_wscale(rcv_win); | 1922 | wscale = compute_wscale(rcv_win); |
1937 | 1923 | ||
1938 | /* | 1924 | /* |
@@ -2374,9 +2360,9 @@ static int accept_cr(struct c4iw_ep *ep, struct sk_buff *skb, | |||
2374 | OPCODE_TID(rpl) = cpu_to_be32(MK_OPCODE_TID(CPL_PASS_ACCEPT_RPL, | 2360 | OPCODE_TID(rpl) = cpu_to_be32(MK_OPCODE_TID(CPL_PASS_ACCEPT_RPL, |
2375 | ep->hwtid)); | 2361 | ep->hwtid)); |
2376 | 2362 | ||
2377 | 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, |
2378 | enable_tcp_timestamps && req->tcpopt.tstamp, | 2364 | enable_tcp_timestamps && req->tcpopt.tstamp, |
2379 | (AF_INET == ep->com.remote_addr.ss_family) ? 0 : 1); | 2365 | (ep->com.remote_addr.ss_family == AF_INET) ? 0 : 1); |
2380 | wscale = compute_wscale(rcv_win); | 2366 | wscale = compute_wscale(rcv_win); |
2381 | 2367 | ||
2382 | /* | 2368 | /* |
diff --git a/drivers/net/ethernet/chelsio/libcxgb/libcxgb_cm.h b/drivers/net/ethernet/chelsio/libcxgb/libcxgb_cm.h index 57fcc9899234..7fb4feb3c221 100644 --- a/drivers/net/ethernet/chelsio/libcxgb/libcxgb_cm.h +++ b/drivers/net/ethernet/chelsio/libcxgb/libcxgb_cm.h | |||
@@ -33,6 +33,9 @@ | |||
33 | #ifndef __LIBCXGB_CM_H__ | 33 | #ifndef __LIBCXGB_CM_H__ |
34 | #define __LIBCXGB_CM_H__ | 34 | #define __LIBCXGB_CM_H__ |
35 | 35 | ||
36 | |||
37 | #include <net/tcp.h> | ||
38 | |||
36 | #include <cxgb4.h> | 39 | #include <cxgb4.h> |
37 | #include <t4_msg.h> | 40 | #include <t4_msg.h> |
38 | 41 | ||
@@ -56,4 +59,19 @@ static inline bool cxgb_is_neg_adv(unsigned int status) | |||
56 | status == CPL_ERR_PERSIST_NEG_ADVICE || | 59 | status == CPL_ERR_PERSIST_NEG_ADVICE || |
57 | status == CPL_ERR_KEEPALV_NEG_ADVICE; | 60 | status == CPL_ERR_KEEPALV_NEG_ADVICE; |
58 | } | 61 | } |
62 | |||
63 | static inline void | ||
64 | cxgb_best_mtu(const unsigned short *mtus, unsigned short mtu, | ||
65 | unsigned int *idx, int use_ts, int ipv6) | ||
66 | { | ||
67 | unsigned short hdr_size = (ipv6 ? | ||
68 | sizeof(struct ipv6hdr) : | ||
69 | sizeof(struct iphdr)) + | ||
70 | sizeof(struct tcphdr) + | ||
71 | (use_ts ? | ||
72 | round_up(TCPOLEN_TIMESTAMP, 4) : 0); | ||
73 | unsigned short data_size = mtu - hdr_size; | ||
74 | |||
75 | cxgb4_best_aligned_mtu(mtus, hdr_size, data_size, 8, idx); | ||
76 | } | ||
59 | #endif | 77 | #endif |
diff --git a/drivers/target/iscsi/cxgbit/cxgbit_cm.c b/drivers/target/iscsi/cxgbit/cxgbit_cm.c index c46bdd5d58ca..b09c09ba9659 100644 --- a/drivers/target/iscsi/cxgbit/cxgbit_cm.c +++ b/drivers/target/iscsi/cxgbit/cxgbit_cm.c | |||
@@ -997,20 +997,6 @@ cxgbit_l2t_send(struct cxgbit_device *cdev, struct sk_buff *skb, | |||
997 | return ret < 0 ? ret : 0; | 997 | return ret < 0 ? ret : 0; |
998 | } | 998 | } |
999 | 999 | ||
1000 | static void | ||
1001 | cxgbit_best_mtu(const unsigned short *mtus, unsigned short mtu, | ||
1002 | unsigned int *idx, int use_ts, int ipv6) | ||
1003 | { | ||
1004 | unsigned short hdr_size = (ipv6 ? sizeof(struct ipv6hdr) : | ||
1005 | sizeof(struct iphdr)) + | ||
1006 | sizeof(struct tcphdr) + | ||
1007 | (use_ts ? round_up(TCPOLEN_TIMESTAMP, | ||
1008 | 4) : 0); | ||
1009 | unsigned short data_size = mtu - hdr_size; | ||
1010 | |||
1011 | cxgb4_best_aligned_mtu(mtus, hdr_size, data_size, 8, idx); | ||
1012 | } | ||
1013 | |||
1014 | static void cxgbit_send_rx_credits(struct cxgbit_sock *csk, struct sk_buff *skb) | 1000 | static void cxgbit_send_rx_credits(struct cxgbit_sock *csk, struct sk_buff *skb) |
1015 | { | 1001 | { |
1016 | if (csk->com.state != CSK_STATE_ESTABLISHED) { | 1002 | 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) | |||
1135 | INIT_TP_WR(rpl5, csk->tid); | 1121 | INIT_TP_WR(rpl5, csk->tid); |
1136 | OPCODE_TID(rpl5) = cpu_to_be32(MK_OPCODE_TID(CPL_PASS_ACCEPT_RPL, | 1122 | OPCODE_TID(rpl5) = cpu_to_be32(MK_OPCODE_TID(CPL_PASS_ACCEPT_RPL, |
1137 | csk->tid)); | 1123 | csk->tid)); |
1138 | cxgbit_best_mtu(csk->com.cdev->lldi.mtus, csk->mtu, &mtu_idx, | 1124 | cxgb_best_mtu(csk->com.cdev->lldi.mtus, csk->mtu, &mtu_idx, |
1139 | req->tcpopt.tstamp, | 1125 | req->tcpopt.tstamp, |
1140 | (csk->com.remote_addr.ss_family == AF_INET) ? 0 : 1); | 1126 | (csk->com.remote_addr.ss_family == AF_INET) ? 0 : 1); |
1141 | wscale = cxgbit_compute_wscale(csk->rcv_win); | 1127 | wscale = cxgbit_compute_wscale(csk->rcv_win); |
1142 | /* | 1128 | /* |
1143 | * Specify the largest window that will fit in opt0. The | 1129 | * Specify the largest window that will fit in opt0. The |