Skip to content

Commit f88d5d6

Browse files
committed
Merge tag 'mlx5-updates-2019-02-21' of git://git.kernel.org/pub/scm/linux/kernel/git/saeed/linux
Saeed Mahameed says: ==================== mlx5-updates-2019-02-21 This series adds some misc updates to mlx5 driver, 1) Eli Britstein, Introduces tunnel entropy control from PCMR register and fixes GRE key by controlling port tunnel entropy calculation. 2) Eran Ben Elisha, provides some mlx5 fixes to the latest tx devlink health reporting mechanism. 3) Huy Nguyen, Added the support for ndo bridge_setlink to allow VEPA/VEB E-Switch legacy mode configurations. ==================== Signed-off-by: David S. Miller <[email protected]>
2 parents b55874f + 4b89251 commit f88d5d6

File tree

13 files changed

+553
-42
lines changed

13 files changed

+553
-42
lines changed

drivers/net/ethernet/mellanox/mlx5/core/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ mlx5_core-$(CONFIG_MLX5_CORE_EN) += en_main.o en_common.o en_fs.o en_ethtool.o \
3030
mlx5_core-$(CONFIG_MLX5_EN_ARFS) += en_arfs.o
3131
mlx5_core-$(CONFIG_MLX5_EN_RXNFC) += en_fs_ethtool.o
3232
mlx5_core-$(CONFIG_MLX5_CORE_EN_DCB) += en_dcbnl.o en/port_buffer.o
33-
mlx5_core-$(CONFIG_MLX5_ESWITCH) += en_rep.o en_tc.o en/tc_tun.o
33+
mlx5_core-$(CONFIG_MLX5_ESWITCH) += en_rep.o en_tc.o en/tc_tun.o lib/port_tun.o
3434

3535
#
3636
# Core extra

drivers/net/ethernet/mellanox/mlx5/core/en/reporter_tx.c

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,18 @@ static int mlx5e_tx_reporter_err_cqe_recover(struct mlx5e_txqsq *sq)
113113
return 0;
114114
}
115115

116+
static int mlx5_tx_health_report(struct devlink_health_reporter *tx_reporter,
117+
char *err_str,
118+
struct mlx5e_tx_err_ctx *err_ctx)
119+
{
120+
if (IS_ERR_OR_NULL(tx_reporter)) {
121+
netdev_err(err_ctx->sq->channel->netdev, err_str);
122+
return err_ctx->recover(err_ctx->sq);
123+
}
124+
125+
return devlink_health_report(tx_reporter, err_str, err_ctx);
126+
}
127+
116128
void mlx5e_tx_reporter_err_cqe(struct mlx5e_txqsq *sq)
117129
{
118130
char err_str[MLX5E_TX_REPORTER_PER_SQ_MAX_LEN];
@@ -122,7 +134,7 @@ void mlx5e_tx_reporter_err_cqe(struct mlx5e_txqsq *sq)
122134
err_ctx.recover = mlx5e_tx_reporter_err_cqe_recover;
123135
sprintf(err_str, "ERR CQE on SQ: 0x%x", sq->sqn);
124136

125-
devlink_health_report(sq->channel->priv->tx_reporter, err_str,
137+
mlx5_tx_health_report(sq->channel->priv->tx_reporter, err_str,
126138
&err_ctx);
127139
}
128140

@@ -136,7 +148,7 @@ static int mlx5e_tx_reporter_timeout_recover(struct mlx5e_txqsq *sq)
136148
eq->core.eqn, eq->core.cons_index, eq->core.irqn);
137149

138150
eqe_count = mlx5_eq_poll_irq_disabled(eq);
139-
ret = eqe_count ? true : false;
151+
ret = eqe_count ? false : true;
140152
if (!eqe_count) {
141153
clear_bit(MLX5E_SQ_STATE_ENABLED, &sq->state);
142154
return ret;
@@ -160,7 +172,7 @@ int mlx5e_tx_reporter_timeout(struct mlx5e_txqsq *sq)
160172
sq->channel->ix, sq->sqn, sq->cq.mcq.cqn, sq->cc, sq->pc,
161173
jiffies_to_usecs(jiffies - sq->txq->trans_start));
162174

163-
return devlink_health_report(sq->channel->priv->tx_reporter, err_str,
175+
return mlx5_tx_health_report(sq->channel->priv->tx_reporter, err_str,
164176
&err_ctx);
165177
}
166178

@@ -281,11 +293,11 @@ int mlx5e_tx_reporter_create(struct mlx5e_priv *priv)
281293
devlink_health_reporter_create(devlink, &mlx5_tx_reporter_ops,
282294
MLX5_REPORTER_TX_GRACEFUL_PERIOD,
283295
true, priv);
284-
if (IS_ERR_OR_NULL(priv->tx_reporter))
296+
if (IS_ERR(priv->tx_reporter))
285297
netdev_warn(priv->netdev,
286298
"Failed to create tx reporter, err = %ld\n",
287299
PTR_ERR(priv->tx_reporter));
288-
return PTR_ERR_OR_ZERO(priv->tx_reporter);
300+
return IS_ERR_OR_NULL(priv->tx_reporter);
289301
}
290302

291303
void mlx5e_tx_reporter_destroy(struct mlx5e_priv *priv)

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

Lines changed: 59 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
#include <linux/mlx5/fs.h>
3636
#include <net/vxlan.h>
3737
#include <linux/bpf.h>
38+
#include <linux/if_bridge.h>
3839
#include <net/page_pool.h>
3940
#include "eswitch.h"
4041
#include "en.h"
@@ -4173,12 +4174,6 @@ static void mlx5e_tx_timeout(struct net_device *dev)
41734174
struct mlx5e_priv *priv = netdev_priv(dev);
41744175

41754176
netdev_err(dev, "TX timeout detected\n");
4176-
4177-
if (IS_ERR_OR_NULL(priv->tx_reporter)) {
4178-
netdev_err_once(priv->netdev, "tx timeout will not be handled, no valid tx reporter\n");
4179-
return;
4180-
}
4181-
41824177
queue_work(priv->wq, &priv->tx_timeout_work);
41834178
}
41844179

@@ -4311,6 +4306,61 @@ static int mlx5e_xdp(struct net_device *dev, struct netdev_bpf *xdp)
43114306
}
43124307
}
43134308

4309+
#ifdef CONFIG_MLX5_ESWITCH
4310+
static int mlx5e_bridge_getlink(struct sk_buff *skb, u32 pid, u32 seq,
4311+
struct net_device *dev, u32 filter_mask,
4312+
int nlflags)
4313+
{
4314+
struct mlx5e_priv *priv = netdev_priv(dev);
4315+
struct mlx5_core_dev *mdev = priv->mdev;
4316+
u8 mode, setting;
4317+
int err;
4318+
4319+
err = mlx5_eswitch_get_vepa(mdev->priv.eswitch, &setting);
4320+
if (err)
4321+
return err;
4322+
mode = setting ? BRIDGE_MODE_VEPA : BRIDGE_MODE_VEB;
4323+
return ndo_dflt_bridge_getlink(skb, pid, seq, dev,
4324+
mode,
4325+
0, 0, nlflags, filter_mask, NULL);
4326+
}
4327+
4328+
static int mlx5e_bridge_setlink(struct net_device *dev, struct nlmsghdr *nlh,
4329+
u16 flags, struct netlink_ext_ack *extack)
4330+
{
4331+
struct mlx5e_priv *priv = netdev_priv(dev);
4332+
struct mlx5_core_dev *mdev = priv->mdev;
4333+
struct nlattr *attr, *br_spec;
4334+
u16 mode = BRIDGE_MODE_UNDEF;
4335+
u8 setting;
4336+
int rem;
4337+
4338+
br_spec = nlmsg_find_attr(nlh, sizeof(struct ifinfomsg), IFLA_AF_SPEC);
4339+
if (!br_spec)
4340+
return -EINVAL;
4341+
4342+
nla_for_each_nested(attr, br_spec, rem) {
4343+
if (nla_type(attr) != IFLA_BRIDGE_MODE)
4344+
continue;
4345+
4346+
if (nla_len(attr) < sizeof(mode))
4347+
return -EINVAL;
4348+
4349+
mode = nla_get_u16(attr);
4350+
if (mode > BRIDGE_MODE_VEPA)
4351+
return -EINVAL;
4352+
4353+
break;
4354+
}
4355+
4356+
if (mode == BRIDGE_MODE_UNDEF)
4357+
return -EINVAL;
4358+
4359+
setting = (mode == BRIDGE_MODE_VEPA) ? 1 : 0;
4360+
return mlx5_eswitch_set_vepa(mdev->priv.eswitch, setting);
4361+
}
4362+
#endif
4363+
43144364
const struct net_device_ops mlx5e_netdev_ops = {
43154365
.ndo_open = mlx5e_open,
43164366
.ndo_stop = mlx5e_close,
@@ -4337,6 +4387,9 @@ const struct net_device_ops mlx5e_netdev_ops = {
43374387
.ndo_rx_flow_steer = mlx5e_rx_flow_steer,
43384388
#endif
43394389
#ifdef CONFIG_MLX5_ESWITCH
4390+
.ndo_bridge_setlink = mlx5e_bridge_setlink,
4391+
.ndo_bridge_getlink = mlx5e_bridge_getlink,
4392+
43404393
/* SRIOV E-Switch NDOs */
43414394
.ndo_set_vf_mac = mlx5e_set_vf_mac,
43424395
.ndo_set_vf_vlan = mlx5e_set_vf_vlan,

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

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@
4444
#include "en_tc.h"
4545
#include "en/tc_tun.h"
4646
#include "fs_core.h"
47+
#include "lib/port_tun.h"
4748

4849
#define MLX5E_REP_PARAMS_DEF_LOG_SQ_SIZE \
4950
max(0x7, MLX5E_PARAMS_MINIMUM_LOG_SQ_SIZE)
@@ -1044,14 +1045,23 @@ static void mlx5e_rep_neigh_entry_destroy(struct mlx5e_priv *priv,
10441045
int mlx5e_rep_encap_entry_attach(struct mlx5e_priv *priv,
10451046
struct mlx5e_encap_entry *e)
10461047
{
1048+
struct mlx5e_rep_priv *rpriv = priv->ppriv;
1049+
struct mlx5_rep_uplink_priv *uplink_priv = &rpriv->uplink_priv;
1050+
struct mlx5_tun_entropy *tun_entropy = &uplink_priv->tun_entropy;
10471051
struct mlx5e_neigh_hash_entry *nhe;
10481052
int err;
10491053

1054+
err = mlx5_tun_entropy_refcount_inc(tun_entropy, e->reformat_type);
1055+
if (err)
1056+
return err;
10501057
nhe = mlx5e_rep_neigh_entry_lookup(priv, &e->m_neigh);
10511058
if (!nhe) {
10521059
err = mlx5e_rep_neigh_entry_create(priv, e, &nhe);
1053-
if (err)
1060+
if (err) {
1061+
mlx5_tun_entropy_refcount_dec(tun_entropy,
1062+
e->reformat_type);
10541063
return err;
1064+
}
10551065
}
10561066
list_add(&e->encap_list, &nhe->encap_list);
10571067
return 0;
@@ -1060,13 +1070,17 @@ int mlx5e_rep_encap_entry_attach(struct mlx5e_priv *priv,
10601070
void mlx5e_rep_encap_entry_detach(struct mlx5e_priv *priv,
10611071
struct mlx5e_encap_entry *e)
10621072
{
1073+
struct mlx5e_rep_priv *rpriv = priv->ppriv;
1074+
struct mlx5_rep_uplink_priv *uplink_priv = &rpriv->uplink_priv;
1075+
struct mlx5_tun_entropy *tun_entropy = &uplink_priv->tun_entropy;
10631076
struct mlx5e_neigh_hash_entry *nhe;
10641077

10651078
list_del(&e->encap_list);
10661079
nhe = mlx5e_rep_neigh_entry_lookup(priv, &e->m_neigh);
10671080

10681081
if (list_empty(&nhe->encap_list))
10691082
mlx5e_rep_neigh_entry_destroy(priv, nhe);
1083+
mlx5_tun_entropy_refcount_dec(tun_entropy, e->reformat_type);
10701084
}
10711085

10721086
static int mlx5e_vf_rep_open(struct net_device *dev)
@@ -1564,6 +1578,8 @@ static int mlx5e_init_rep_tx(struct mlx5e_priv *priv)
15641578
if (err)
15651579
goto destroy_tises;
15661580

1581+
mlx5_init_port_tun_entropy(&uplink_priv->tun_entropy, priv->mdev);
1582+
15671583
/* init indirect block notifications */
15681584
INIT_LIST_HEAD(&uplink_priv->tc_indr_block_priv_list);
15691585
uplink_priv->netdevice_nb.notifier_call = mlx5e_nic_rep_netdevice_event;

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
#include <linux/rhashtable.h>
3838
#include "eswitch.h"
3939
#include "en.h"
40+
#include "lib/port_tun.h"
4041

4142
#ifdef CONFIG_MLX5_ESWITCH
4243
struct mlx5e_neigh_update_table {
@@ -71,6 +72,8 @@ struct mlx5_rep_uplink_priv {
7172
*/
7273
struct list_head tc_indr_block_priv_list;
7374
struct notifier_block netdevice_nb;
75+
76+
struct mlx5_tun_entropy tun_entropy;
7477
};
7578

7679
struct mlx5e_rep_priv {

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

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -508,9 +508,8 @@ bool mlx5e_poll_tx_cq(struct mlx5e_cq *cq, int napi_budget)
508508
&sq->state)) {
509509
mlx5e_dump_error_cqe(sq,
510510
(struct mlx5_err_cqe *)cqe);
511-
if (!IS_ERR_OR_NULL(cq->channel->priv->tx_reporter))
512-
queue_work(cq->channel->priv->wq,
513-
&sq->recover_work);
511+
queue_work(cq->channel->priv->wq,
512+
&sq->recover_work);
514513
}
515514
stats->cqe_err++;
516515
}

0 commit comments

Comments
 (0)