Skip to content

Commit 2e51e45

Browse files
bharatpotnurijgunthorpe
authored andcommitted
iw_cxgb4: pass window scale in flowc work request
This will allow FW to not send more data to TP (which would then need to be buffered). Pass the negotiated TCP window scale to FW in the FLOWC WR. Also refactor send_flowc() a bit to clean it up. Signed-off-by: Steve Wise <[email protected]> Signed-off-by: Potnuri Bharat Teja <[email protected]> Signed-off-by: Jason Gunthorpe <[email protected]>
1 parent 0dfe452 commit 2e51e45

File tree

2 files changed

+28
-24
lines changed

2 files changed

+28
-24
lines changed

drivers/infiniband/hw/cxgb4/cm.c

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -587,24 +587,29 @@ static int send_flowc(struct c4iw_ep *ep)
587587
{
588588
struct fw_flowc_wr *flowc;
589589
struct sk_buff *skb = skb_dequeue(&ep->com.ep_skb_list);
590-
int i;
591590
u16 vlan = ep->l2t->vlan;
592591
int nparams;
592+
int flowclen, flowclen16;
593593

594594
if (WARN_ON(!skb))
595595
return -ENOMEM;
596596

597597
if (vlan == CPL_L2T_VLAN_NONE)
598-
nparams = 8;
599-
else
600598
nparams = 9;
599+
else
600+
nparams = 10;
601+
602+
flowclen = offsetof(struct fw_flowc_wr, mnemval[nparams]);
603+
flowclen16 = DIV_ROUND_UP(flowclen, 16);
604+
flowclen = flowclen16 * 16;
601605

602-
flowc = __skb_put(skb, FLOWC_LEN);
606+
flowc = __skb_put(skb, flowclen);
607+
memset(flowc, 0, flowclen);
603608

604609
flowc->op_to_nparams = cpu_to_be32(FW_WR_OP_V(FW_FLOWC_WR) |
605610
FW_FLOWC_WR_NPARAMS_V(nparams));
606-
flowc->flowid_len16 = cpu_to_be32(FW_WR_LEN16_V(DIV_ROUND_UP(FLOWC_LEN,
607-
16)) | FW_WR_FLOWID_V(ep->hwtid));
611+
flowc->flowid_len16 = cpu_to_be32(FW_WR_LEN16_V(flowclen16) |
612+
FW_WR_FLOWID_V(ep->hwtid));
608613

609614
flowc->mnemval[0].mnemonic = FW_FLOWC_MNEM_PFNVFN;
610615
flowc->mnemval[0].val = cpu_to_be32(FW_PFVF_CMD_PFN_V
@@ -623,21 +628,13 @@ static int send_flowc(struct c4iw_ep *ep)
623628
flowc->mnemval[6].val = cpu_to_be32(ep->snd_win);
624629
flowc->mnemval[7].mnemonic = FW_FLOWC_MNEM_MSS;
625630
flowc->mnemval[7].val = cpu_to_be32(ep->emss);
626-
if (nparams == 9) {
631+
flowc->mnemval[8].mnemonic = FW_FLOWC_MNEM_RCV_SCALE;
632+
flowc->mnemval[8].val = cpu_to_be32(ep->snd_wscale);
633+
if (nparams == 10) {
627634
u16 pri;
628-
629635
pri = (vlan & VLAN_PRIO_MASK) >> VLAN_PRIO_SHIFT;
630-
flowc->mnemval[8].mnemonic = FW_FLOWC_MNEM_SCHEDCLASS;
631-
flowc->mnemval[8].val = cpu_to_be32(pri);
632-
} else {
633-
/* Pad WR to 16 byte boundary */
634-
flowc->mnemval[8].mnemonic = 0;
635-
flowc->mnemval[8].val = 0;
636-
}
637-
for (i = 0; i < 9; i++) {
638-
flowc->mnemval[i].r4[0] = 0;
639-
flowc->mnemval[i].r4[1] = 0;
640-
flowc->mnemval[i].r4[2] = 0;
636+
flowc->mnemval[9].mnemonic = FW_FLOWC_MNEM_SCHEDCLASS;
637+
flowc->mnemval[9].val = cpu_to_be32(pri);
641638
}
642639

643640
set_wr_txq(skb, CPL_PRIORITY_DATA, ep->txq_idx);
@@ -1176,6 +1173,7 @@ static int act_establish(struct c4iw_dev *dev, struct sk_buff *skb)
11761173
{
11771174
struct c4iw_ep *ep;
11781175
struct cpl_act_establish *req = cplhdr(skb);
1176+
unsigned short tcp_opt = ntohs(req->tcp_opt);
11791177
unsigned int tid = GET_TID(req);
11801178
unsigned int atid = TID_TID_G(ntohl(req->tos_atid));
11811179
struct tid_info *t = dev->rdev.lldi.tids;
@@ -1196,8 +1194,9 @@ static int act_establish(struct c4iw_dev *dev, struct sk_buff *skb)
11961194

11971195
ep->snd_seq = be32_to_cpu(req->snd_isn);
11981196
ep->rcv_seq = be32_to_cpu(req->rcv_isn);
1197+
ep->snd_wscale = TCPOPT_SND_WSCALE_G(tcp_opt);
11991198

1200-
set_emss(ep, ntohs(req->tcp_opt));
1199+
set_emss(ep, tcp_opt);
12011200

12021201
/* dealloc the atid */
12031202
remove_handle(ep->com.dev, &ep->com.dev->atid_idr, atid);
@@ -2629,16 +2628,17 @@ static int pass_establish(struct c4iw_dev *dev, struct sk_buff *skb)
26292628
struct cpl_pass_establish *req = cplhdr(skb);
26302629
unsigned int tid = GET_TID(req);
26312630
int ret;
2631+
u16 tcp_opt = ntohs(req->tcp_opt);
26322632

26332633
ep = get_ep_from_tid(dev, tid);
26342634
pr_debug("ep %p tid %u\n", ep, ep->hwtid);
26352635
ep->snd_seq = be32_to_cpu(req->snd_isn);
26362636
ep->rcv_seq = be32_to_cpu(req->rcv_isn);
2637+
ep->snd_wscale = TCPOPT_SND_WSCALE_G(tcp_opt);
26372638

2638-
pr_debug("ep %p hwtid %u tcp_opt 0x%02x\n", ep, tid,
2639-
ntohs(req->tcp_opt));
2639+
pr_debug("ep %p hwtid %u tcp_opt 0x%02x\n", ep, tid, tcp_opt);
26402640

2641-
set_emss(ep, ntohs(req->tcp_opt));
2641+
set_emss(ep, tcp_opt);
26422642

26432643
dst_confirm(ep->dst);
26442644
mutex_lock(&ep->com.mutex);

drivers/infiniband/hw/cxgb4/iw_cxgb4.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -910,7 +910,10 @@ enum conn_pre_alloc_buffers {
910910
CN_MAX_CON_BUF
911911
};
912912

913-
#define FLOWC_LEN 80
913+
enum {
914+
FLOWC_LEN = offsetof(struct fw_flowc_wr, mnemval[FW_FLOWC_MNEM_MAX])
915+
};
916+
914917
union cpl_wr_size {
915918
struct cpl_abort_req abrt_req;
916919
struct cpl_abort_rpl abrt_rpl;
@@ -977,6 +980,7 @@ struct c4iw_ep {
977980
unsigned int retry_count;
978981
int snd_win;
979982
int rcv_win;
983+
u32 snd_wscale;
980984
struct c4iw_ep_stats stats;
981985
};
982986

0 commit comments

Comments
 (0)