Skip to content

Commit ac8e4c6

Browse files
Hariprasad Sdledford
authored andcommitted
cxgb4/iw_cxgb4: TOS support
This series provides support for iWARP applications to specify a TOS value and have that map to a VLAN Priority for iw_cxgb4 iWARP connections. In iw_cxgb4, when allocating an L2T entry, pass the skb_priority based on the tos value in the cm_id. Also pass the correct tos value during connection setup so the passive side gets the client's desired tos. When sending the FLOWC work request to FW, if the egress device is in a vlan, then use the vlan priority bits as the scheduling class. This allows associating RDMA connections with scheduling classes to provide traffic shaping per flow. Signed-off-by: Steve Wise <[email protected]> Signed-off-by: Hariprasad Shenai <[email protected]> Signed-off-by: Doug Ledford <[email protected]>
1 parent 6812fae commit ac8e4c6

File tree

3 files changed

+37
-17
lines changed

3 files changed

+37
-17
lines changed

drivers/infiniband/hw/cxgb4/cm.c

Lines changed: 34 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -485,12 +485,19 @@ static void send_flowc(struct c4iw_ep *ep, struct sk_buff *skb)
485485
unsigned int flowclen = 80;
486486
struct fw_flowc_wr *flowc;
487487
int i;
488+
u16 vlan = ep->l2t->vlan;
489+
int nparams;
490+
491+
if (vlan == CPL_L2T_VLAN_NONE)
492+
nparams = 8;
493+
else
494+
nparams = 9;
488495

489496
skb = get_skb(skb, flowclen, GFP_KERNEL);
490497
flowc = (struct fw_flowc_wr *)__skb_put(skb, flowclen);
491498

492499
flowc->op_to_nparams = cpu_to_be32(FW_WR_OP_V(FW_FLOWC_WR) |
493-
FW_FLOWC_WR_NPARAMS_V(8));
500+
FW_FLOWC_WR_NPARAMS_V(nparams));
494501
flowc->flowid_len16 = cpu_to_be32(FW_WR_LEN16_V(DIV_ROUND_UP(flowclen,
495502
16)) | FW_WR_FLOWID_V(ep->hwtid));
496503

@@ -511,9 +518,17 @@ static void send_flowc(struct c4iw_ep *ep, struct sk_buff *skb)
511518
flowc->mnemval[6].val = cpu_to_be32(ep->snd_win);
512519
flowc->mnemval[7].mnemonic = FW_FLOWC_MNEM_MSS;
513520
flowc->mnemval[7].val = cpu_to_be32(ep->emss);
514-
/* Pad WR to 16 byte boundary */
515-
flowc->mnemval[8].mnemonic = 0;
516-
flowc->mnemval[8].val = 0;
521+
if (nparams == 9) {
522+
u16 pri;
523+
524+
pri = (vlan & VLAN_PRIO_MASK) >> VLAN_PRIO_SHIFT;
525+
flowc->mnemval[8].mnemonic = FW_FLOWC_MNEM_SCHEDCLASS;
526+
flowc->mnemval[8].val = cpu_to_be32(pri);
527+
} else {
528+
/* Pad WR to 16 byte boundary */
529+
flowc->mnemval[8].mnemonic = 0;
530+
flowc->mnemval[8].val = 0;
531+
}
517532
for (i = 0; i < 9; i++) {
518533
flowc->mnemval[i].r4[0] = 0;
519534
flowc->mnemval[i].r4[1] = 0;
@@ -710,7 +725,7 @@ static int send_connect(struct c4iw_ep *ep)
710725
L2T_IDX_V(ep->l2t->idx) |
711726
TX_CHAN_V(ep->tx_chan) |
712727
SMAC_SEL_V(ep->smac_idx) |
713-
DSCP_V(ep->tos) |
728+
DSCP_V(ep->tos >> 2) |
714729
ULP_MODE_V(ULP_MODE_TCPDDP) |
715730
RCV_BUFSIZ_V(win);
716731
opt2 = RX_CHANNEL_V(0) |
@@ -1864,7 +1879,7 @@ static void send_fw_act_open_req(struct c4iw_ep *ep, unsigned int atid)
18641879
L2T_IDX_V(ep->l2t->idx) |
18651880
TX_CHAN_V(ep->tx_chan) |
18661881
SMAC_SEL_V(ep->smac_idx) |
1867-
DSCP_V(ep->tos) |
1882+
DSCP_V(ep->tos >> 2) |
18681883
ULP_MODE_V(ULP_MODE_TCPDDP) |
18691884
RCV_BUFSIZ_V(win));
18701885
req->tcb.opt2 = (__force __be32) (PACE_V(1) |
@@ -1928,7 +1943,7 @@ static void set_tcp_window(struct c4iw_ep *ep, struct port_info *pi)
19281943

19291944
static int import_ep(struct c4iw_ep *ep, int iptype, __u8 *peer_ip,
19301945
struct dst_entry *dst, struct c4iw_dev *cdev,
1931-
bool clear_mpa_v1, enum chip_type adapter_type)
1946+
bool clear_mpa_v1, enum chip_type adapter_type, u8 tos)
19321947
{
19331948
struct neighbour *n;
19341949
int err, step;
@@ -1958,7 +1973,7 @@ static int import_ep(struct c4iw_ep *ep, int iptype, __u8 *peer_ip,
19581973
goto out;
19591974
}
19601975
ep->l2t = cxgb4_l2t_get(cdev->rdev.lldi.l2t,
1961-
n, pdev, 0);
1976+
n, pdev, rt_tos2priority(tos));
19621977
if (!ep->l2t)
19631978
goto out;
19641979
ep->mtu = pdev->mtu;
@@ -2041,7 +2056,7 @@ static int c4iw_reconnect(struct c4iw_ep *ep)
20412056
if (ep->com.cm_id->local_addr.ss_family == AF_INET) {
20422057
ep->dst = find_route(ep->com.dev, laddr->sin_addr.s_addr,
20432058
raddr->sin_addr.s_addr, laddr->sin_port,
2044-
raddr->sin_port, 0);
2059+
raddr->sin_port, ep->com.cm_id->tos);
20452060
iptype = 4;
20462061
ra = (__u8 *)&raddr->sin_addr;
20472062
} else {
@@ -2058,7 +2073,8 @@ static int c4iw_reconnect(struct c4iw_ep *ep)
20582073
goto fail3;
20592074
}
20602075
err = import_ep(ep, iptype, ra, ep->dst, ep->com.dev, false,
2061-
ep->com.dev->rdev.lldi.adapter_type);
2076+
ep->com.dev->rdev.lldi.adapter_type,
2077+
ep->com.cm_id->tos);
20622078
if (err) {
20632079
pr_err("%s - cannot alloc l2e.\n", __func__);
20642080
goto fail4;
@@ -2069,7 +2085,7 @@ static int c4iw_reconnect(struct c4iw_ep *ep)
20692085
ep->l2t->idx);
20702086

20712087
state_set(&ep->com, CONNECTING);
2072-
ep->tos = 0;
2088+
ep->tos = ep->com.cm_id->tos;
20732089

20742090
/* send connect request to rnic */
20752091
err = send_connect(ep);
@@ -2391,6 +2407,7 @@ static int pass_accept_req(struct c4iw_dev *dev, struct sk_buff *skb)
23912407
u16 peer_mss = ntohs(req->tcpopt.mss);
23922408
int iptype;
23932409
unsigned short hdrs;
2410+
u8 tos = PASS_OPEN_TOS_G(ntohl(req->tos_stid));
23942411

23952412
parent_ep = lookup_stid(t, stid);
23962413
if (!parent_ep) {
@@ -2414,7 +2431,7 @@ static int pass_accept_req(struct c4iw_dev *dev, struct sk_buff *skb)
24142431
ntohs(peer_port), peer_mss);
24152432
dst = find_route(dev, *(__be32 *)local_ip, *(__be32 *)peer_ip,
24162433
local_port, peer_port,
2417-
PASS_OPEN_TOS_G(ntohl(req->tos_stid)));
2434+
tos);
24182435
} else {
24192436
PDBG("%s parent ep %p hwtid %u laddr %pI6 raddr %pI6 lport %d rport %d peer_mss %d\n"
24202437
, __func__, parent_ep, hwtid,
@@ -2440,7 +2457,7 @@ static int pass_accept_req(struct c4iw_dev *dev, struct sk_buff *skb)
24402457
}
24412458

24422459
err = import_ep(child_ep, iptype, peer_ip, dst, dev, false,
2443-
parent_ep->com.dev->rdev.lldi.adapter_type);
2460+
parent_ep->com.dev->rdev.lldi.adapter_type, tos);
24442461
if (err) {
24452462
printk(KERN_ERR MOD "%s - failed to allocate l2t entry!\n",
24462463
__func__);
@@ -2508,7 +2525,7 @@ static int pass_accept_req(struct c4iw_dev *dev, struct sk_buff *skb)
25082525

25092526
c4iw_get_ep(&parent_ep->com);
25102527
child_ep->parent_ep = parent_ep;
2511-
child_ep->tos = PASS_OPEN_TOS_G(ntohl(req->tos_stid));
2528+
child_ep->tos = tos;
25122529
child_ep->dst = dst;
25132530
child_ep->hwtid = hwtid;
25142531

@@ -3202,7 +3219,7 @@ int c4iw_connect(struct iw_cm_id *cm_id, struct iw_cm_conn_param *conn_param)
32023219
ra, ntohs(raddr->sin_port));
32033220
ep->dst = find_route(dev, laddr->sin_addr.s_addr,
32043221
raddr->sin_addr.s_addr, laddr->sin_port,
3205-
raddr->sin_port, 0);
3222+
raddr->sin_port, cm_id->tos);
32063223
} else {
32073224
iptype = 6;
32083225
ra = (__u8 *)&raddr6->sin6_addr;
@@ -3233,7 +3250,7 @@ int c4iw_connect(struct iw_cm_id *cm_id, struct iw_cm_conn_param *conn_param)
32333250
}
32343251

32353252
err = import_ep(ep, iptype, ra, ep->dst, ep->com.dev, true,
3236-
ep->com.dev->rdev.lldi.adapter_type);
3253+
ep->com.dev->rdev.lldi.adapter_type, cm_id->tos);
32373254
if (err) {
32383255
printk(KERN_ERR MOD "%s - cannot alloc l2e.\n", __func__);
32393256
goto fail3;
@@ -3244,7 +3261,7 @@ int c4iw_connect(struct iw_cm_id *cm_id, struct iw_cm_conn_param *conn_param)
32443261
ep->l2t->idx);
32453262

32463263
state_set(&ep->com, CONNECTING);
3247-
ep->tos = 0;
3264+
ep->tos = cm_id->tos;
32483265

32493266
/* send connect request to rnic */
32503267
err = send_connect(ep);

drivers/net/ethernet/chelsio/cxgb4/t4_msg.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1021,6 +1021,8 @@ struct cpl_l2t_write_req {
10211021
#define L2T_W_NOREPLY_V(x) ((x) << L2T_W_NOREPLY_S)
10221022
#define L2T_W_NOREPLY_F L2T_W_NOREPLY_V(1U)
10231023

1024+
#define CPL_L2T_VLAN_NONE 0xfff
1025+
10241026
struct cpl_l2t_write_rpl {
10251027
union opcode_tid ot;
10261028
u8 status;

drivers/net/ethernet/chelsio/cxgb4/t4fw_api.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -561,6 +561,7 @@ enum fw_flowc_mnem {
561561
FW_FLOWC_MNEM_SNDBUF,
562562
FW_FLOWC_MNEM_MSS,
563563
FW_FLOWC_MNEM_TXDATAPLEN_MAX,
564+
FW_FLOWC_MNEM_SCHEDCLASS = 11,
564565
};
565566

566567
struct fw_flowc_mnemval {

0 commit comments

Comments
 (0)