Skip to content

Commit b209a36

Browse files
nvishwa1dledford
authored andcommitted
IB/opa_vnic: Add routing control information
Add protocol specific routing control information in the encapsulation header as per the configuration. Reviewed-by: Sudeep Dutt <[email protected]> Signed-off-by: Niranjana Vishwanathapura <[email protected]> Signed-off-by: Scott Franco <[email protected]> Signed-off-by: Dennis Dalessandro <[email protected]> Signed-off-by: Doug Ledford <[email protected]>
1 parent e82b7c3 commit b209a36

File tree

4 files changed

+61
-4
lines changed

4 files changed

+61
-4
lines changed

drivers/infiniband/ulp/opa_vnic/opa_vnic_encap.c

Lines changed: 39 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -406,6 +406,42 @@ u8 opa_vnic_get_vl(struct opa_vnic_adapter *adapter, struct sk_buff *skb)
406406
return vl;
407407
}
408408

409+
/* opa_vnic_get_rc - return the routing control */
410+
static u8 opa_vnic_get_rc(struct __opa_veswport_info *info,
411+
struct sk_buff *skb)
412+
{
413+
u8 proto, rout_ctrl;
414+
415+
switch (vlan_get_protocol(skb)) {
416+
case htons(ETH_P_IPV6):
417+
proto = ipv6_hdr(skb)->nexthdr;
418+
if (proto == IPPROTO_TCP)
419+
rout_ctrl = OPA_VNIC_ENCAP_RC_EXT(info->vesw.rc,
420+
IPV6_TCP);
421+
else if (proto == IPPROTO_UDP)
422+
rout_ctrl = OPA_VNIC_ENCAP_RC_EXT(info->vesw.rc,
423+
IPV6_UDP);
424+
else
425+
rout_ctrl = OPA_VNIC_ENCAP_RC_EXT(info->vesw.rc, IPV6);
426+
break;
427+
case htons(ETH_P_IP):
428+
proto = ip_hdr(skb)->protocol;
429+
if (proto == IPPROTO_TCP)
430+
rout_ctrl = OPA_VNIC_ENCAP_RC_EXT(info->vesw.rc,
431+
IPV4_TCP);
432+
else if (proto == IPPROTO_UDP)
433+
rout_ctrl = OPA_VNIC_ENCAP_RC_EXT(info->vesw.rc,
434+
IPV4_UDP);
435+
else
436+
rout_ctrl = OPA_VNIC_ENCAP_RC_EXT(info->vesw.rc, IPV4);
437+
break;
438+
default:
439+
rout_ctrl = OPA_VNIC_ENCAP_RC_EXT(info->vesw.rc, DEFAULT);
440+
}
441+
442+
return rout_ctrl;
443+
}
444+
409445
/* opa_vnic_calc_entropy - calculate the packet entropy */
410446
u8 opa_vnic_calc_entropy(struct opa_vnic_adapter *adapter, struct sk_buff *skb)
411447
{
@@ -448,7 +484,7 @@ void opa_vnic_encap_skb(struct opa_vnic_adapter *adapter, struct sk_buff *skb)
448484
{
449485
struct __opa_veswport_info *info = &adapter->info;
450486
struct opa_vnic_skb_mdata *mdata;
451-
u8 def_port, sc, entropy, *hdr;
487+
u8 def_port, sc, rc, entropy, *hdr;
452488
u16 len, l4_hdr;
453489
u32 dlid;
454490

@@ -459,6 +495,7 @@ void opa_vnic_encap_skb(struct opa_vnic_adapter *adapter, struct sk_buff *skb)
459495
len = opa_vnic_wire_length(skb);
460496
dlid = opa_vnic_get_dlid(adapter, skb, def_port);
461497
sc = opa_vnic_get_sc(info, skb);
498+
rc = opa_vnic_get_rc(info, skb);
462499
l4_hdr = info->vesw.vesw_id;
463500

464501
mdata = skb_push(skb, sizeof(*mdata));
@@ -471,6 +508,6 @@ void opa_vnic_encap_skb(struct opa_vnic_adapter *adapter, struct sk_buff *skb)
471508
}
472509

473510
opa_vnic_make_header(hdr, info->vport.encap_slid, dlid, len,
474-
info->vesw.pkey, entropy, sc, 0,
511+
info->vesw.pkey, entropy, sc, rc,
475512
OPA_VNIC_L4_ETHR, l4_hdr);
476513
}

drivers/infiniband/ulp/opa_vnic/opa_vnic_encap.h

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,17 @@
103103
#define OPA_VNIC_ETH_LINK_UP 1
104104
#define OPA_VNIC_ETH_LINK_DOWN 2
105105

106+
/* routing control */
107+
#define OPA_VNIC_ENCAP_RC_DEFAULT 0
108+
#define OPA_VNIC_ENCAP_RC_IPV4 4
109+
#define OPA_VNIC_ENCAP_RC_IPV4_UDP 8
110+
#define OPA_VNIC_ENCAP_RC_IPV4_TCP 12
111+
#define OPA_VNIC_ENCAP_RC_IPV6 16
112+
#define OPA_VNIC_ENCAP_RC_IPV6_TCP 20
113+
#define OPA_VNIC_ENCAP_RC_IPV6_UDP 24
114+
115+
#define OPA_VNIC_ENCAP_RC_EXT(w, b) (((w) >> OPA_VNIC_ENCAP_RC_ ## b) & 0x7)
116+
106117
/**
107118
* struct opa_vesw_info - OPA vnic switch information
108119
* @fabric_id: 10-bit fabric id
@@ -111,6 +122,7 @@
111122
* @pkey: partition key
112123
* @u_mcast_dlid: unknown multicast dlid
113124
* @u_ucast_dlid: array of unknown unicast dlids
125+
* @rc: routing control
114126
* @eth_mtu: Ethernet MTU
115127
*/
116128
struct opa_vesw_info {
@@ -127,7 +139,9 @@ struct opa_vesw_info {
127139
__be32 u_mcast_dlid;
128140
__be32 u_ucast_dlid[OPA_VESW_MAX_NUM_DEF_PORT];
129141

130-
u8 rsvd3[60];
142+
__be32 rc;
143+
144+
u8 rsvd3[56];
131145
__be16 eth_mtu;
132146
u8 rsvd4[2];
133147
} __packed;

drivers/infiniband/ulp/opa_vnic/opa_vnic_internal.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,9 @@ struct __opa_vesw_info {
8989
u32 u_mcast_dlid;
9090
u32 u_ucast_dlid[OPA_VESW_MAX_NUM_DEF_PORT];
9191

92-
u8 rsvd3[60];
92+
u32 rc;
93+
94+
u8 rsvd3[56];
9395
u16 eth_mtu;
9496
u8 rsvd4[2];
9597
} __packed;

drivers/infiniband/ulp/opa_vnic/opa_vnic_vema_iface.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,8 @@ void opa_vnic_get_vesw_info(struct opa_vnic_adapter *adapter,
176176
for (i = 0; i < OPA_VESW_MAX_NUM_DEF_PORT; i++)
177177
info->u_ucast_dlid[i] = cpu_to_be32(src->u_ucast_dlid[i]);
178178

179+
info->rc = cpu_to_be32(src->rc);
180+
179181
memcpy(info->rsvd3, src->rsvd3, ARRAY_SIZE(src->rsvd3));
180182
info->eth_mtu = cpu_to_be16(src->eth_mtu);
181183
memcpy(info->rsvd4, src->rsvd4, ARRAY_SIZE(src->rsvd4));
@@ -208,6 +210,8 @@ void opa_vnic_set_vesw_info(struct opa_vnic_adapter *adapter,
208210
for (i = 0; i < OPA_VESW_MAX_NUM_DEF_PORT; i++)
209211
dst->u_ucast_dlid[i] = be32_to_cpu(info->u_ucast_dlid[i]);
210212

213+
dst->rc = be32_to_cpu(info->rc);
214+
211215
memcpy(dst->rsvd3, info->rsvd3, ARRAY_SIZE(info->rsvd3));
212216
dst->eth_mtu = be16_to_cpu(info->eth_mtu);
213217
memcpy(dst->rsvd4, info->rsvd4, ARRAY_SIZE(info->rsvd4));

0 commit comments

Comments
 (0)