Skip to content

Commit 0ff4b7e

Browse files
committed
Merge branch 'vnic' into k.o/for-next
Signed-off-by: Doug Ledford <[email protected]>
2 parents 8206ceb + b209a36 commit 0ff4b7e

File tree

6 files changed

+103
-35
lines changed

6 files changed

+103
-35
lines changed

drivers/infiniband/ulp/opa_vnic/opa_vnic_encap.c

Lines changed: 40 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,7 @@ void opa_vnic_release_mac_tbl(struct opa_vnic_adapter *adapter)
139139
rcu_assign_pointer(adapter->mactbl, NULL);
140140
synchronize_rcu();
141141
opa_vnic_free_mac_tbl(mactbl);
142+
adapter->info.vport.mac_tbl_digest = 0;
142143
mutex_unlock(&adapter->mactbl_lock);
143144
}
144145

@@ -405,6 +406,42 @@ u8 opa_vnic_get_vl(struct opa_vnic_adapter *adapter, struct sk_buff *skb)
405406
return vl;
406407
}
407408

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+
408445
/* opa_vnic_calc_entropy - calculate the packet entropy */
409446
u8 opa_vnic_calc_entropy(struct opa_vnic_adapter *adapter, struct sk_buff *skb)
410447
{
@@ -447,7 +484,7 @@ void opa_vnic_encap_skb(struct opa_vnic_adapter *adapter, struct sk_buff *skb)
447484
{
448485
struct __opa_veswport_info *info = &adapter->info;
449486
struct opa_vnic_skb_mdata *mdata;
450-
u8 def_port, sc, entropy, *hdr;
487+
u8 def_port, sc, rc, entropy, *hdr;
451488
u16 len, l4_hdr;
452489
u32 dlid;
453490

@@ -458,6 +495,7 @@ void opa_vnic_encap_skb(struct opa_vnic_adapter *adapter, struct sk_buff *skb)
458495
len = opa_vnic_wire_length(skb);
459496
dlid = opa_vnic_get_dlid(adapter, skb, def_port);
460497
sc = opa_vnic_get_sc(info, skb);
498+
rc = opa_vnic_get_rc(info, skb);
461499
l4_hdr = info->vesw.vesw_id;
462500

463501
mdata = skb_push(skb, sizeof(*mdata));
@@ -470,6 +508,6 @@ void opa_vnic_encap_skb(struct opa_vnic_adapter *adapter, struct sk_buff *skb)
470508
}
471509

472510
opa_vnic_make_header(hdr, info->vport.encap_slid, dlid, len,
473-
info->vesw.pkey, entropy, sc, 0,
511+
info->vesw.pkey, entropy, sc, rc,
474512
OPA_VNIC_L4_ETHR, l4_hdr);
475513
}

drivers/infiniband/ulp/opa_vnic/opa_vnic_encap.h

Lines changed: 17 additions & 5 deletions
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,8 +122,8 @@
111122
* @pkey: partition key
112123
* @u_mcast_dlid: unknown multicast dlid
113124
* @u_ucast_dlid: array of unknown unicast dlids
114-
* @eth_mtu: MTUs for each vlan PCP
115-
* @eth_mtu_non_vlan: MTU for non vlan packets
125+
* @rc: routing control
126+
* @eth_mtu: Ethernet MTU
116127
*/
117128
struct opa_vesw_info {
118129
__be16 fabric_id;
@@ -128,9 +139,10 @@ struct opa_vesw_info {
128139
__be32 u_mcast_dlid;
129140
__be32 u_ucast_dlid[OPA_VESW_MAX_NUM_DEF_PORT];
130141

131-
u8 rsvd3[44];
132-
__be16 eth_mtu[OPA_VNIC_MAX_NUM_PCP];
133-
__be16 eth_mtu_non_vlan;
142+
__be32 rc;
143+
144+
u8 rsvd3[56];
145+
__be16 eth_mtu;
134146
u8 rsvd4[2];
135147
} __packed;
136148

drivers/infiniband/ulp/opa_vnic/opa_vnic_internal.h

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

92-
u8 rsvd3[44];
93-
u16 eth_mtu[OPA_VNIC_MAX_NUM_PCP];
94-
u16 eth_mtu_non_vlan;
92+
u32 rc;
93+
94+
u8 rsvd3[56];
95+
u16 eth_mtu;
9596
u8 rsvd4[2];
9697
} __packed;
9798

drivers/infiniband/ulp/opa_vnic/opa_vnic_netdev.c

Lines changed: 30 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,27 @@ static u16 opa_vnic_select_queue(struct net_device *netdev, struct sk_buff *skb,
112112
return rc;
113113
}
114114

115+
static void opa_vnic_update_state(struct opa_vnic_adapter *adapter, bool up)
116+
{
117+
struct __opa_veswport_info *info = &adapter->info;
118+
119+
mutex_lock(&adapter->lock);
120+
/* Operational state can only be DROP_ALL or FORWARDING */
121+
if ((info->vport.config_state == OPA_VNIC_STATE_FORWARDING) && up) {
122+
info->vport.oper_state = OPA_VNIC_STATE_FORWARDING;
123+
info->vport.eth_link_status = OPA_VNIC_ETH_LINK_UP;
124+
} else {
125+
info->vport.oper_state = OPA_VNIC_STATE_DROP_ALL;
126+
info->vport.eth_link_status = OPA_VNIC_ETH_LINK_DOWN;
127+
}
128+
129+
if (info->vport.config_state == OPA_VNIC_STATE_FORWARDING)
130+
netif_dormant_off(adapter->netdev);
131+
else
132+
netif_dormant_on(adapter->netdev);
133+
mutex_unlock(&adapter->lock);
134+
}
135+
115136
/* opa_vnic_process_vema_config - process vema configuration updates */
116137
void opa_vnic_process_vema_config(struct opa_vnic_adapter *adapter)
117138
{
@@ -130,7 +151,7 @@ void opa_vnic_process_vema_config(struct opa_vnic_adapter *adapter)
130151
memcpy(saddr.sa_data, info->vport.base_mac_addr,
131152
ARRAY_SIZE(info->vport.base_mac_addr));
132153
mutex_lock(&adapter->lock);
133-
eth_mac_addr(netdev, &saddr);
154+
eth_commit_mac_addr_change(netdev, &saddr);
134155
memcpy(adapter->vema_mac_addr,
135156
info->vport.base_mac_addr, ETH_ALEN);
136157
mutex_unlock(&adapter->lock);
@@ -140,7 +161,7 @@ void opa_vnic_process_vema_config(struct opa_vnic_adapter *adapter)
140161

141162
/* Handle MTU limit change */
142163
rtnl_lock();
143-
netdev->max_mtu = max_t(unsigned int, info->vesw.eth_mtu_non_vlan,
164+
netdev->max_mtu = max_t(unsigned int, info->vesw.eth_mtu,
144165
netdev->min_mtu);
145166
if (netdev->mtu > netdev->max_mtu)
146167
dev_set_mtu(netdev, netdev->max_mtu);
@@ -164,14 +185,8 @@ void opa_vnic_process_vema_config(struct opa_vnic_adapter *adapter)
164185
adapter->flow_tbl[i] = port_count ? port_num[i % port_count] :
165186
OPA_VNIC_INVALID_PORT;
166187

167-
/* Operational state can only be DROP_ALL or FORWARDING */
168-
if (info->vport.config_state == OPA_VNIC_STATE_FORWARDING) {
169-
info->vport.oper_state = OPA_VNIC_STATE_FORWARDING;
170-
netif_dormant_off(netdev);
171-
} else {
172-
info->vport.oper_state = OPA_VNIC_STATE_DROP_ALL;
173-
netif_dormant_on(netdev);
174-
}
188+
/* update state */
189+
opa_vnic_update_state(adapter, !!(netdev->flags & IFF_UP));
175190
}
176191

177192
/*
@@ -183,6 +198,7 @@ static inline void opa_vnic_set_pod_values(struct opa_vnic_adapter *adapter)
183198
adapter->info.vport.max_smac_ent = OPA_VNIC_MAX_SMAC_LIMIT;
184199
adapter->info.vport.config_state = OPA_VNIC_STATE_DROP_ALL;
185200
adapter->info.vport.eth_link_status = OPA_VNIC_ETH_LINK_DOWN;
201+
adapter->info.vesw.eth_mtu = ETH_DATA_LEN;
186202
}
187203

188204
/* opa_vnic_set_mac_addr - change mac address */
@@ -268,8 +284,8 @@ static int opa_netdev_open(struct net_device *netdev)
268284
return rc;
269285
}
270286

271-
/* Update eth link status and send trap */
272-
adapter->info.vport.eth_link_status = OPA_VNIC_ETH_LINK_UP;
287+
/* Update status and send trap */
288+
opa_vnic_update_state(adapter, true);
273289
opa_vnic_vema_report_event(adapter,
274290
OPA_VESWPORT_TRAP_ETH_LINK_STATUS_CHANGE);
275291
return 0;
@@ -287,8 +303,8 @@ static int opa_netdev_close(struct net_device *netdev)
287303
return rc;
288304
}
289305

290-
/* Update eth link status and send trap */
291-
adapter->info.vport.eth_link_status = OPA_VNIC_ETH_LINK_DOWN;
306+
/* Update status and send trap */
307+
opa_vnic_update_state(adapter, false);
292308
opa_vnic_vema_report_event(adapter,
293309
OPA_VESWPORT_TRAP_ETH_LINK_STATUS_CHANGE);
294310
return 0;

drivers/infiniband/ulp/opa_vnic/opa_vnic_vema.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,7 @@ static inline void vema_get_pod_values(struct opa_veswport_info *port_info)
186186
cpu_to_be16(OPA_VNIC_MAX_SMAC_LIMIT);
187187
port_info->vport.oper_state = OPA_VNIC_STATE_DROP_ALL;
188188
port_info->vport.config_state = OPA_VNIC_STATE_DROP_ALL;
189+
port_info->vesw.eth_mtu = cpu_to_be16(ETH_DATA_LEN);
189190
}
190191

191192
/**

drivers/infiniband/ulp/opa_vnic/opa_vnic_vema_iface.c

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -176,11 +176,10 @@ 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-
memcpy(info->rsvd3, src->rsvd3, ARRAY_SIZE(src->rsvd3));
180-
for (i = 0; i < OPA_VNIC_MAX_NUM_PCP; i++)
181-
info->eth_mtu[i] = cpu_to_be16(src->eth_mtu[i]);
179+
info->rc = cpu_to_be32(src->rc);
182180

183-
info->eth_mtu_non_vlan = cpu_to_be16(src->eth_mtu_non_vlan);
181+
memcpy(info->rsvd3, src->rsvd3, ARRAY_SIZE(src->rsvd3));
182+
info->eth_mtu = cpu_to_be16(src->eth_mtu);
184183
memcpy(info->rsvd4, src->rsvd4, ARRAY_SIZE(src->rsvd4));
185184
}
186185

@@ -211,11 +210,10 @@ void opa_vnic_set_vesw_info(struct opa_vnic_adapter *adapter,
211210
for (i = 0; i < OPA_VESW_MAX_NUM_DEF_PORT; i++)
212211
dst->u_ucast_dlid[i] = be32_to_cpu(info->u_ucast_dlid[i]);
213212

214-
memcpy(dst->rsvd3, info->rsvd3, ARRAY_SIZE(info->rsvd3));
215-
for (i = 0; i < OPA_VNIC_MAX_NUM_PCP; i++)
216-
dst->eth_mtu[i] = be16_to_cpu(info->eth_mtu[i]);
213+
dst->rc = be32_to_cpu(info->rc);
217214

218-
dst->eth_mtu_non_vlan = be16_to_cpu(info->eth_mtu_non_vlan);
215+
memcpy(dst->rsvd3, info->rsvd3, ARRAY_SIZE(info->rsvd3));
216+
dst->eth_mtu = be16_to_cpu(info->eth_mtu);
219217
memcpy(dst->rsvd4, info->rsvd4, ARRAY_SIZE(info->rsvd4));
220218
}
221219

@@ -348,7 +346,7 @@ void opa_vnic_query_mcast_macs(struct opa_vnic_adapter *adapter,
348346
void opa_vnic_query_ucast_macs(struct opa_vnic_adapter *adapter,
349347
struct opa_veswport_iface_macs *macs)
350348
{
351-
u16 start_idx, tot_macs, num_macs, idx = 0, count = 0;
349+
u16 start_idx, tot_macs, num_macs, idx = 0, count = 0, em_macs = 0;
352350
struct netdev_hw_addr *ha;
353351

354352
start_idx = be16_to_cpu(macs->start_idx);
@@ -359,8 +357,10 @@ void opa_vnic_query_ucast_macs(struct opa_vnic_adapter *adapter,
359357

360358
/* Do not include EM specified MAC address */
361359
if (!memcmp(adapter->info.vport.base_mac_addr, ha->addr,
362-
ARRAY_SIZE(adapter->info.vport.base_mac_addr)))
360+
ARRAY_SIZE(adapter->info.vport.base_mac_addr))) {
361+
em_macs++;
363362
continue;
363+
}
364364

365365
if (start_idx > idx++)
366366
continue;
@@ -383,7 +383,7 @@ void opa_vnic_query_ucast_macs(struct opa_vnic_adapter *adapter,
383383
}
384384

385385
tot_macs = netdev_hw_addr_list_count(&adapter->netdev->dev_addrs) +
386-
netdev_uc_count(adapter->netdev);
386+
netdev_uc_count(adapter->netdev) - em_macs;
387387
macs->tot_macs_in_lst = cpu_to_be16(tot_macs);
388388
macs->num_macs_in_msg = cpu_to_be16(count);
389389
macs->gen_count = cpu_to_be16(adapter->info.vport.uc_macs_gen_count);

0 commit comments

Comments
 (0)