Skip to content

Commit efad54a

Browse files
committed
Merge branch 'mlx5-fixes'
Saeed Mahameed says: ==================== Mellanox mlx5 fixes 2017-03-21 This series contains some mlx5 core and ethernet driver fixes. For -stable: net/mlx5e: Count LRO packets correctly (for kernel >= 4.2) net/mlx5e: Count GSO packets correctly (for kernel >= 4.2) net/mlx5: Increase number of max QPs in default profile (for kernel >= 4.0) net/mlx5e: Avoid supporting udp tunnel port ndo for VF reps (for kernel >= 4.10) net/mlx5e: Use the proper UAPI values when offloading TC vlan actions (for kernel >= v4.9) net/mlx5: E-Switch, Don't allow changing inline mode when flows are configured (for kernel >= 4.10) net/mlx5e: Change the TC offload rule add/del code path to be per NIC or E-Switch (for kernel >= 4.10) net/mlx5: Add missing entries for set/query rate limit commands (for kernel >= 4.8) ==================== Signed-off-by: David S. Miller <[email protected]>
2 parents bf601fe + 8ab7e2a commit efad54a

File tree

10 files changed

+94
-37
lines changed

10 files changed

+94
-37
lines changed

drivers/net/ethernet/mellanox/mlx5/core/cmd.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -361,6 +361,8 @@ static int mlx5_internal_err_ret_value(struct mlx5_core_dev *dev, u16 op,
361361
case MLX5_CMD_OP_QUERY_VPORT_COUNTER:
362362
case MLX5_CMD_OP_ALLOC_Q_COUNTER:
363363
case MLX5_CMD_OP_QUERY_Q_COUNTER:
364+
case MLX5_CMD_OP_SET_RATE_LIMIT:
365+
case MLX5_CMD_OP_QUERY_RATE_LIMIT:
364366
case MLX5_CMD_OP_ALLOC_PD:
365367
case MLX5_CMD_OP_ALLOC_UAR:
366368
case MLX5_CMD_OP_CONFIG_INT_MODERATION:
@@ -497,6 +499,8 @@ const char *mlx5_command_str(int command)
497499
MLX5_COMMAND_STR_CASE(ALLOC_Q_COUNTER);
498500
MLX5_COMMAND_STR_CASE(DEALLOC_Q_COUNTER);
499501
MLX5_COMMAND_STR_CASE(QUERY_Q_COUNTER);
502+
MLX5_COMMAND_STR_CASE(SET_RATE_LIMIT);
503+
MLX5_COMMAND_STR_CASE(QUERY_RATE_LIMIT);
500504
MLX5_COMMAND_STR_CASE(ALLOC_PD);
501505
MLX5_COMMAND_STR_CASE(DEALLOC_PD);
502506
MLX5_COMMAND_STR_CASE(ALLOC_UAR);

drivers/net/ethernet/mellanox/mlx5/core/en.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -928,10 +928,6 @@ void mlx5e_destroy_netdev(struct mlx5_core_dev *mdev, struct mlx5e_priv *priv);
928928
int mlx5e_attach_netdev(struct mlx5_core_dev *mdev, struct net_device *netdev);
929929
void mlx5e_detach_netdev(struct mlx5_core_dev *mdev, struct net_device *netdev);
930930
u32 mlx5e_choose_lro_timeout(struct mlx5_core_dev *mdev, u32 wanted_timeout);
931-
void mlx5e_add_vxlan_port(struct net_device *netdev,
932-
struct udp_tunnel_info *ti);
933-
void mlx5e_del_vxlan_port(struct net_device *netdev,
934-
struct udp_tunnel_info *ti);
935931

936932
int mlx5e_get_offload_stats(int attr_id, const struct net_device *dev,
937933
void *sp);

drivers/net/ethernet/mellanox/mlx5/core/en_main.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3100,8 +3100,8 @@ static int mlx5e_get_vf_stats(struct net_device *dev,
31003100
vf_stats);
31013101
}
31023102

3103-
void mlx5e_add_vxlan_port(struct net_device *netdev,
3104-
struct udp_tunnel_info *ti)
3103+
static void mlx5e_add_vxlan_port(struct net_device *netdev,
3104+
struct udp_tunnel_info *ti)
31053105
{
31063106
struct mlx5e_priv *priv = netdev_priv(netdev);
31073107

@@ -3114,8 +3114,8 @@ void mlx5e_add_vxlan_port(struct net_device *netdev,
31143114
mlx5e_vxlan_queue_work(priv, ti->sa_family, be16_to_cpu(ti->port), 1);
31153115
}
31163116

3117-
void mlx5e_del_vxlan_port(struct net_device *netdev,
3118-
struct udp_tunnel_info *ti)
3117+
static void mlx5e_del_vxlan_port(struct net_device *netdev,
3118+
struct udp_tunnel_info *ti)
31193119
{
31203120
struct mlx5e_priv *priv = netdev_priv(netdev);
31213121

drivers/net/ethernet/mellanox/mlx5/core/en_rep.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -393,8 +393,6 @@ static const struct net_device_ops mlx5e_netdev_ops_rep = {
393393
.ndo_get_phys_port_name = mlx5e_rep_get_phys_port_name,
394394
.ndo_setup_tc = mlx5e_rep_ndo_setup_tc,
395395
.ndo_get_stats64 = mlx5e_rep_get_stats,
396-
.ndo_udp_tunnel_add = mlx5e_add_vxlan_port,
397-
.ndo_udp_tunnel_del = mlx5e_del_vxlan_port,
398396
.ndo_has_offload_stats = mlx5e_has_offload_stats,
399397
.ndo_get_offload_stats = mlx5e_get_offload_stats,
400398
};

drivers/net/ethernet/mellanox/mlx5/core/en_rx.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -601,6 +601,10 @@ static inline void mlx5e_build_rx_skb(struct mlx5_cqe64 *cqe,
601601
if (lro_num_seg > 1) {
602602
mlx5e_lro_update_hdr(skb, cqe, cqe_bcnt);
603603
skb_shinfo(skb)->gso_size = DIV_ROUND_UP(cqe_bcnt, lro_num_seg);
604+
/* Subtract one since we already counted this as one
605+
* "regular" packet in mlx5e_complete_rx_cqe()
606+
*/
607+
rq->stats.packets += lro_num_seg - 1;
604608
rq->stats.lro_packets++;
605609
rq->stats.lro_bytes += cqe_bcnt;
606610
}

drivers/net/ethernet/mellanox/mlx5/core/en_tc.c

Lines changed: 50 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,23 @@ mlx5e_tc_add_nic_flow(struct mlx5e_priv *priv,
133133
return rule;
134134
}
135135

136+
static void mlx5e_tc_del_nic_flow(struct mlx5e_priv *priv,
137+
struct mlx5e_tc_flow *flow)
138+
{
139+
struct mlx5_fc *counter = NULL;
140+
141+
if (!IS_ERR(flow->rule)) {
142+
counter = mlx5_flow_rule_counter(flow->rule);
143+
mlx5_del_flow_rules(flow->rule);
144+
mlx5_fc_destroy(priv->mdev, counter);
145+
}
146+
147+
if (!mlx5e_tc_num_filters(priv) && (priv->fs.tc.t)) {
148+
mlx5_destroy_flow_table(priv->fs.tc.t);
149+
priv->fs.tc.t = NULL;
150+
}
151+
}
152+
136153
static struct mlx5_flow_handle *
137154
mlx5e_tc_add_fdb_flow(struct mlx5e_priv *priv,
138155
struct mlx5_flow_spec *spec,
@@ -149,7 +166,24 @@ mlx5e_tc_add_fdb_flow(struct mlx5e_priv *priv,
149166
}
150167

151168
static void mlx5e_detach_encap(struct mlx5e_priv *priv,
152-
struct mlx5e_tc_flow *flow) {
169+
struct mlx5e_tc_flow *flow);
170+
171+
static void mlx5e_tc_del_fdb_flow(struct mlx5e_priv *priv,
172+
struct mlx5e_tc_flow *flow)
173+
{
174+
struct mlx5_eswitch *esw = priv->mdev->priv.eswitch;
175+
176+
mlx5_eswitch_del_offloaded_rule(esw, flow->rule, flow->attr);
177+
178+
mlx5_eswitch_del_vlan_action(esw, flow->attr);
179+
180+
if (flow->attr->action & MLX5_FLOW_CONTEXT_ACTION_ENCAP)
181+
mlx5e_detach_encap(priv, flow);
182+
}
183+
184+
static void mlx5e_detach_encap(struct mlx5e_priv *priv,
185+
struct mlx5e_tc_flow *flow)
186+
{
153187
struct list_head *next = flow->encap.next;
154188

155189
list_del(&flow->encap);
@@ -173,25 +207,10 @@ static void mlx5e_detach_encap(struct mlx5e_priv *priv,
173207
static void mlx5e_tc_del_flow(struct mlx5e_priv *priv,
174208
struct mlx5e_tc_flow *flow)
175209
{
176-
struct mlx5_eswitch *esw = priv->mdev->priv.eswitch;
177-
struct mlx5_fc *counter = NULL;
178-
179-
if (!IS_ERR(flow->rule)) {
180-
counter = mlx5_flow_rule_counter(flow->rule);
181-
mlx5_del_flow_rules(flow->rule);
182-
mlx5_fc_destroy(priv->mdev, counter);
183-
}
184-
185-
if (flow->flags & MLX5E_TC_FLOW_ESWITCH) {
186-
mlx5_eswitch_del_vlan_action(esw, flow->attr);
187-
if (flow->attr->action & MLX5_FLOW_CONTEXT_ACTION_ENCAP)
188-
mlx5e_detach_encap(priv, flow);
189-
}
190-
191-
if (!mlx5e_tc_num_filters(priv) && (priv->fs.tc.t)) {
192-
mlx5_destroy_flow_table(priv->fs.tc.t);
193-
priv->fs.tc.t = NULL;
194-
}
210+
if (flow->flags & MLX5E_TC_FLOW_ESWITCH)
211+
mlx5e_tc_del_fdb_flow(priv, flow);
212+
else
213+
mlx5e_tc_del_nic_flow(priv, flow);
195214
}
196215

197216
static void parse_vxlan_attr(struct mlx5_flow_spec *spec,
@@ -248,12 +267,15 @@ static int parse_tunnel_attr(struct mlx5e_priv *priv,
248267
skb_flow_dissector_target(f->dissector,
249268
FLOW_DISSECTOR_KEY_ENC_PORTS,
250269
f->mask);
270+
struct mlx5_eswitch *esw = priv->mdev->priv.eswitch;
271+
struct net_device *up_dev = mlx5_eswitch_get_uplink_netdev(esw);
272+
struct mlx5e_priv *up_priv = netdev_priv(up_dev);
251273

252274
/* Full udp dst port must be given */
253275
if (memchr_inv(&mask->dst, 0xff, sizeof(mask->dst)))
254276
goto vxlan_match_offload_err;
255277

256-
if (mlx5e_vxlan_lookup_port(priv, be16_to_cpu(key->dst)) &&
278+
if (mlx5e_vxlan_lookup_port(up_priv, be16_to_cpu(key->dst)) &&
257279
MLX5_CAP_ESW(priv->mdev, vxlan_encap_decap))
258280
parse_vxlan_attr(spec, f);
259281
else {
@@ -976,6 +998,8 @@ static int mlx5e_attach_encap(struct mlx5e_priv *priv,
976998
struct mlx5_esw_flow_attr *attr)
977999
{
9781000
struct mlx5_eswitch *esw = priv->mdev->priv.eswitch;
1001+
struct net_device *up_dev = mlx5_eswitch_get_uplink_netdev(esw);
1002+
struct mlx5e_priv *up_priv = netdev_priv(up_dev);
9791003
unsigned short family = ip_tunnel_info_af(tun_info);
9801004
struct ip_tunnel_key *key = &tun_info->key;
9811005
struct mlx5_encap_entry *e;
@@ -996,7 +1020,7 @@ static int mlx5e_attach_encap(struct mlx5e_priv *priv,
9961020
return -EOPNOTSUPP;
9971021
}
9981022

999-
if (mlx5e_vxlan_lookup_port(priv, be16_to_cpu(key->tp_dst)) &&
1023+
if (mlx5e_vxlan_lookup_port(up_priv, be16_to_cpu(key->tp_dst)) &&
10001024
MLX5_CAP_ESW(priv->mdev, vxlan_encap_decap)) {
10011025
tunnel_type = MLX5_HEADER_TYPE_VXLAN;
10021026
} else {
@@ -1112,14 +1136,16 @@ static int parse_tc_fdb_actions(struct mlx5e_priv *priv, struct tcf_exts *exts,
11121136
}
11131137

11141138
if (is_tcf_vlan(a)) {
1115-
if (tcf_vlan_action(a) == VLAN_F_POP) {
1139+
if (tcf_vlan_action(a) == TCA_VLAN_ACT_POP) {
11161140
attr->action |= MLX5_FLOW_CONTEXT_ACTION_VLAN_POP;
1117-
} else if (tcf_vlan_action(a) == VLAN_F_PUSH) {
1141+
} else if (tcf_vlan_action(a) == TCA_VLAN_ACT_PUSH) {
11181142
if (tcf_vlan_push_proto(a) != htons(ETH_P_8021Q))
11191143
return -EOPNOTSUPP;
11201144

11211145
attr->action |= MLX5_FLOW_CONTEXT_ACTION_VLAN_PUSH;
11221146
attr->vlan = tcf_vlan_push_vid(a);
1147+
} else { /* action is TCA_VLAN_ACT_MODIFY */
1148+
return -EOPNOTSUPP;
11231149
}
11241150
continue;
11251151
}

drivers/net/ethernet/mellanox/mlx5/core/en_tx.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -274,15 +274,18 @@ static netdev_tx_t mlx5e_sq_xmit(struct mlx5e_sq *sq, struct sk_buff *skb)
274274
sq->stats.tso_bytes += skb->len - ihs;
275275
}
276276

277+
sq->stats.packets += skb_shinfo(skb)->gso_segs;
277278
num_bytes = skb->len + (skb_shinfo(skb)->gso_segs - 1) * ihs;
278279
} else {
279280
bf = sq->bf_budget &&
280281
!skb->xmit_more &&
281282
!skb_shinfo(skb)->nr_frags;
282283
ihs = mlx5e_get_inline_hdr_size(sq, skb, bf);
284+
sq->stats.packets++;
283285
num_bytes = max_t(unsigned int, skb->len, ETH_ZLEN);
284286
}
285287

288+
sq->stats.bytes += num_bytes;
286289
wi->num_bytes = num_bytes;
287290

288291
ds_cnt = sizeof(*wqe) / MLX5_SEND_WQE_DS;
@@ -381,8 +384,6 @@ static netdev_tx_t mlx5e_sq_xmit(struct mlx5e_sq *sq, struct sk_buff *skb)
381384
if (bf)
382385
sq->bf_budget--;
383386

384-
sq->stats.packets++;
385-
sq->stats.bytes += num_bytes;
386387
return NETDEV_TX_OK;
387388

388389
dma_unmap_wqe_err:

drivers/net/ethernet/mellanox/mlx5/core/eswitch.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,7 @@ struct mlx5_esw_offload {
209209
struct mlx5_eswitch_rep *vport_reps;
210210
DECLARE_HASHTABLE(encap_tbl, 8);
211211
u8 inline_mode;
212+
u64 num_flows;
212213
};
213214

214215
struct mlx5_eswitch {
@@ -271,6 +272,11 @@ struct mlx5_flow_handle *
271272
mlx5_eswitch_add_offloaded_rule(struct mlx5_eswitch *esw,
272273
struct mlx5_flow_spec *spec,
273274
struct mlx5_esw_flow_attr *attr);
275+
void
276+
mlx5_eswitch_del_offloaded_rule(struct mlx5_eswitch *esw,
277+
struct mlx5_flow_handle *rule,
278+
struct mlx5_esw_flow_attr *attr);
279+
274280
struct mlx5_flow_handle *
275281
mlx5_eswitch_create_vport_rx_rule(struct mlx5_eswitch *esw, int vport, u32 tirn);
276282

drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,10 +93,27 @@ mlx5_eswitch_add_offloaded_rule(struct mlx5_eswitch *esw,
9393
spec, &flow_act, dest, i);
9494
if (IS_ERR(rule))
9595
mlx5_fc_destroy(esw->dev, counter);
96+
else
97+
esw->offloads.num_flows++;
9698

9799
return rule;
98100
}
99101

102+
void
103+
mlx5_eswitch_del_offloaded_rule(struct mlx5_eswitch *esw,
104+
struct mlx5_flow_handle *rule,
105+
struct mlx5_esw_flow_attr *attr)
106+
{
107+
struct mlx5_fc *counter = NULL;
108+
109+
if (!IS_ERR(rule)) {
110+
counter = mlx5_flow_rule_counter(rule);
111+
mlx5_del_flow_rules(rule);
112+
mlx5_fc_destroy(esw->dev, counter);
113+
esw->offloads.num_flows--;
114+
}
115+
}
116+
100117
static int esw_set_global_vlan_pop(struct mlx5_eswitch *esw, u8 val)
101118
{
102119
struct mlx5_eswitch_rep *rep;
@@ -908,6 +925,11 @@ int mlx5_devlink_eswitch_inline_mode_set(struct devlink *devlink, u8 mode)
908925
MLX5_CAP_INLINE_MODE_VPORT_CONTEXT)
909926
return -EOPNOTSUPP;
910927

928+
if (esw->offloads.num_flows > 0) {
929+
esw_warn(dev, "Can't set inline mode when flows are configured\n");
930+
return -EOPNOTSUPP;
931+
}
932+
911933
err = esw_inline_mode_from_devlink(mode, &mlx5_mode);
912934
if (err)
913935
goto out;

drivers/net/ethernet/mellanox/mlx5/core/main.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ static struct mlx5_profile profile[] = {
8787
[2] = {
8888
.mask = MLX5_PROF_MASK_QP_SIZE |
8989
MLX5_PROF_MASK_MR_CACHE,
90-
.log_max_qp = 17,
90+
.log_max_qp = 18,
9191
.mr_cache[0] = {
9292
.size = 500,
9393
.limit = 250

0 commit comments

Comments
 (0)