diff options
author | Varun Prakash <varun@chelsio.com> | 2016-09-13 11:54:06 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2016-09-15 20:49:20 -0400 |
commit | 6e3b6fc201fe16d3944e2b293e7f47a72f4a56c1 (patch) | |
tree | d95302cbabb87e60d4cb455f26e50e4cf247bbbc | |
parent | 052f4731ed1fd6b132a14c56f49435377a246834 (diff) |
libcxgb,iw_cxgb4,cxgbit: add cxgb_mk_rx_data_ack()
Add cxgb_mk_rx_data_ack() to remove duplicate
code to form CPL_RX_DATA_ACK hardware command.
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 | 19 | ||||
-rw-r--r-- | drivers/net/ethernet/chelsio/libcxgb/libcxgb_cm.h | 15 | ||||
-rw-r--r-- | drivers/target/iscsi/cxgbit/cxgbit_cm.c | 16 |
3 files changed, 29 insertions, 21 deletions
diff --git a/drivers/infiniband/hw/cxgb4/cm.c b/drivers/infiniband/hw/cxgb4/cm.c index a6d5fcb9d8d7..3cbbfbe7da7c 100644 --- a/drivers/infiniband/hw/cxgb4/cm.c +++ b/drivers/infiniband/hw/cxgb4/cm.c | |||
@@ -1354,9 +1354,9 @@ static void established_upcall(struct c4iw_ep *ep) | |||
1354 | 1354 | ||
1355 | static int update_rx_credits(struct c4iw_ep *ep, u32 credits) | 1355 | static int update_rx_credits(struct c4iw_ep *ep, u32 credits) |
1356 | { | 1356 | { |
1357 | struct cpl_rx_data_ack *req; | ||
1358 | struct sk_buff *skb; | 1357 | struct sk_buff *skb; |
1359 | int wrlen = roundup(sizeof *req, 16); | 1358 | u32 wrlen = roundup(sizeof(struct cpl_rx_data_ack), 16); |
1359 | u32 credit_dack; | ||
1360 | 1360 | ||
1361 | PDBG("%s ep %p tid %u credits %u\n", __func__, ep, ep->hwtid, credits); | 1361 | PDBG("%s ep %p tid %u credits %u\n", __func__, ep, ep->hwtid, credits); |
1362 | skb = get_skb(NULL, wrlen, GFP_KERNEL); | 1362 | skb = get_skb(NULL, wrlen, GFP_KERNEL); |
@@ -1373,15 +1373,12 @@ static int update_rx_credits(struct c4iw_ep *ep, u32 credits) | |||
1373 | if (ep->rcv_win > RCV_BUFSIZ_M * 1024) | 1373 | if (ep->rcv_win > RCV_BUFSIZ_M * 1024) |
1374 | credits += ep->rcv_win - RCV_BUFSIZ_M * 1024; | 1374 | credits += ep->rcv_win - RCV_BUFSIZ_M * 1024; |
1375 | 1375 | ||
1376 | req = (struct cpl_rx_data_ack *) skb_put(skb, wrlen); | 1376 | credit_dack = credits | RX_FORCE_ACK_F | RX_DACK_CHANGE_F | |
1377 | memset(req, 0, wrlen); | 1377 | RX_DACK_MODE_V(dack_mode); |
1378 | INIT_TP_WR(req, ep->hwtid); | 1378 | |
1379 | OPCODE_TID(req) = cpu_to_be32(MK_OPCODE_TID(CPL_RX_DATA_ACK, | 1379 | cxgb_mk_rx_data_ack(skb, wrlen, ep->hwtid, ep->ctrlq_idx, |
1380 | ep->hwtid)); | 1380 | credit_dack); |
1381 | req->credit_dack = cpu_to_be32(credits | RX_FORCE_ACK_F | | 1381 | |
1382 | RX_DACK_CHANGE_F | | ||
1383 | RX_DACK_MODE_V(dack_mode)); | ||
1384 | set_wr_txq(skb, CPL_PRIORITY_ACK, ep->ctrlq_idx); | ||
1385 | c4iw_ofld_send(&ep->com.dev->rdev, skb); | 1382 | c4iw_ofld_send(&ep->com.dev->rdev, skb); |
1386 | return credits; | 1383 | return credits; |
1387 | } | 1384 | } |
diff --git a/drivers/net/ethernet/chelsio/libcxgb/libcxgb_cm.h b/drivers/net/ethernet/chelsio/libcxgb/libcxgb_cm.h index 70999e8cf4b7..515b94ff9080 100644 --- a/drivers/net/ethernet/chelsio/libcxgb/libcxgb_cm.h +++ b/drivers/net/ethernet/chelsio/libcxgb/libcxgb_cm.h | |||
@@ -142,4 +142,19 @@ cxgb_mk_abort_rpl(struct sk_buff *skb, u32 len, u32 tid, u16 chan) | |||
142 | rpl->cmd = CPL_ABORT_NO_RST; | 142 | rpl->cmd = CPL_ABORT_NO_RST; |
143 | set_wr_txq(skb, CPL_PRIORITY_DATA, chan); | 143 | set_wr_txq(skb, CPL_PRIORITY_DATA, chan); |
144 | } | 144 | } |
145 | |||
146 | static inline void | ||
147 | cxgb_mk_rx_data_ack(struct sk_buff *skb, u32 len, u32 tid, u16 chan, | ||
148 | u32 credit_dack) | ||
149 | { | ||
150 | struct cpl_rx_data_ack *req; | ||
151 | |||
152 | req = (struct cpl_rx_data_ack *)__skb_put(skb, len); | ||
153 | memset(req, 0, len); | ||
154 | |||
155 | INIT_TP_WR(req, tid); | ||
156 | OPCODE_TID(req) = cpu_to_be32(MK_OPCODE_TID(CPL_RX_DATA_ACK, tid)); | ||
157 | req->credit_dack = cpu_to_be32(credit_dack); | ||
158 | set_wr_txq(skb, CPL_PRIORITY_ACK, chan); | ||
159 | } | ||
145 | #endif | 160 | #endif |
diff --git a/drivers/target/iscsi/cxgbit/cxgbit_cm.c b/drivers/target/iscsi/cxgbit/cxgbit_cm.c index 9bdbe3b84e19..2fb1bf1a26c5 100644 --- a/drivers/target/iscsi/cxgbit/cxgbit_cm.c +++ b/drivers/target/iscsi/cxgbit/cxgbit_cm.c | |||
@@ -994,22 +994,18 @@ static void cxgbit_send_rx_credits(struct cxgbit_sock *csk, struct sk_buff *skb) | |||
994 | int cxgbit_rx_data_ack(struct cxgbit_sock *csk) | 994 | int cxgbit_rx_data_ack(struct cxgbit_sock *csk) |
995 | { | 995 | { |
996 | struct sk_buff *skb; | 996 | struct sk_buff *skb; |
997 | struct cpl_rx_data_ack *req; | 997 | u32 len = roundup(sizeof(struct cpl_rx_data_ack), 16); |
998 | unsigned int len = roundup(sizeof(*req), 16); | 998 | u32 credit_dack; |
999 | 999 | ||
1000 | skb = alloc_skb(len, GFP_KERNEL); | 1000 | skb = alloc_skb(len, GFP_KERNEL); |
1001 | if (!skb) | 1001 | if (!skb) |
1002 | return -1; | 1002 | return -1; |
1003 | 1003 | ||
1004 | req = (struct cpl_rx_data_ack *)__skb_put(skb, len); | 1004 | credit_dack = RX_DACK_CHANGE_F | RX_DACK_MODE_V(1) | |
1005 | memset(req, 0, len); | 1005 | RX_CREDITS_V(csk->rx_credits); |
1006 | 1006 | ||
1007 | set_wr_txq(skb, CPL_PRIORITY_ACK, csk->ctrlq_idx); | 1007 | cxgb_mk_rx_data_ack(skb, len, csk->tid, csk->ctrlq_idx, |
1008 | INIT_TP_WR(req, csk->tid); | 1008 | credit_dack); |
1009 | OPCODE_TID(req) = cpu_to_be32(MK_OPCODE_TID(CPL_RX_DATA_ACK, | ||
1010 | csk->tid)); | ||
1011 | req->credit_dack = cpu_to_be32(RX_DACK_CHANGE_F | RX_DACK_MODE_V(1) | | ||
1012 | RX_CREDITS_V(csk->rx_credits)); | ||
1013 | 1009 | ||
1014 | csk->rx_credits = 0; | 1010 | csk->rx_credits = 0; |
1015 | 1011 | ||