Skip to content

Commit 4300c7e

Browse files
committed
Merge tag 'mlx5-cleanup-2020-05-29' of git://git.kernel.org/pub/scm/linux/kernel/git/saeed/linux
Saeed Mahameed says: ==================== mlx5-cleanup-2020-05-29 Accumulated cleanup patches and sparse warning fixes for mlx5 driver. 1) sync with mlx5-next branch 2) Eli Cohen declares mpls_entry_encode() helper in mpls.h as suggested by Jakub Kicinski and David Ahern, and use it in mlx5 3) Jesper Fixes xdp data_meta setup in mlx5 4) Many sparse and build warnings cleanup ==================== Signed-off-by: David S. Miller <[email protected]>
2 parents da4e15e + eb24387 commit 4300c7e

File tree

28 files changed

+240
-197
lines changed

28 files changed

+240
-197
lines changed

drivers/infiniband/hw/mlx5/flow.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -404,7 +404,10 @@ static bool mlx5_ib_modify_header_supported(struct mlx5_ib_dev *dev)
404404
{
405405
return MLX5_CAP_FLOWTABLE_NIC_RX(dev->mdev,
406406
max_modify_header_actions) ||
407-
MLX5_CAP_FLOWTABLE_NIC_TX(dev->mdev, max_modify_header_actions);
407+
MLX5_CAP_FLOWTABLE_NIC_TX(dev->mdev,
408+
max_modify_header_actions) ||
409+
MLX5_CAP_FLOWTABLE_RDMA_TX(dev->mdev,
410+
max_modify_header_actions);
408411
}
409412

410413
static int UVERBS_HANDLER(MLX5_IB_METHOD_FLOW_ACTION_CREATE_MODIFY_HEADER)(

drivers/infiniband/hw/mlx5/main.c

Lines changed: 10 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -3698,12 +3698,13 @@ static struct mlx5_ib_flow_handler *_create_flow_rule(struct mlx5_ib_dev *dev,
36983698
if (!dest_num)
36993699
rule_dst = NULL;
37003700
} else {
3701+
if (flow_attr->flags & IB_FLOW_ATTR_FLAGS_DONT_TRAP)
3702+
flow_act.action |=
3703+
MLX5_FLOW_CONTEXT_ACTION_FWD_NEXT_PRIO;
37013704
if (is_egress)
37023705
flow_act.action |= MLX5_FLOW_CONTEXT_ACTION_ALLOW;
3703-
else
3704-
flow_act.action |=
3705-
dest_num ? MLX5_FLOW_CONTEXT_ACTION_FWD_DEST :
3706-
MLX5_FLOW_CONTEXT_ACTION_FWD_NEXT_PRIO;
3706+
else if (dest_num)
3707+
flow_act.action |= MLX5_FLOW_CONTEXT_ACTION_FWD_DEST;
37073708
}
37083709

37093710
if ((spec->flow_context.flags & FLOW_CONTEXT_HAS_TAG) &&
@@ -3747,30 +3748,6 @@ static struct mlx5_ib_flow_handler *create_flow_rule(struct mlx5_ib_dev *dev,
37473748
return _create_flow_rule(dev, ft_prio, flow_attr, dst, 0, NULL);
37483749
}
37493750

3750-
static struct mlx5_ib_flow_handler *create_dont_trap_rule(struct mlx5_ib_dev *dev,
3751-
struct mlx5_ib_flow_prio *ft_prio,
3752-
struct ib_flow_attr *flow_attr,
3753-
struct mlx5_flow_destination *dst)
3754-
{
3755-
struct mlx5_ib_flow_handler *handler_dst = NULL;
3756-
struct mlx5_ib_flow_handler *handler = NULL;
3757-
3758-
handler = create_flow_rule(dev, ft_prio, flow_attr, NULL);
3759-
if (!IS_ERR(handler)) {
3760-
handler_dst = create_flow_rule(dev, ft_prio,
3761-
flow_attr, dst);
3762-
if (IS_ERR(handler_dst)) {
3763-
mlx5_del_flow_rules(handler->rule);
3764-
ft_prio->refcount--;
3765-
kfree(handler);
3766-
handler = handler_dst;
3767-
} else {
3768-
list_add(&handler_dst->list, &handler->list);
3769-
}
3770-
}
3771-
3772-
return handler;
3773-
}
37743751
enum {
37753752
LEFTOVERS_MC,
37763753
LEFTOVERS_UC,
@@ -3974,15 +3951,11 @@ static struct ib_flow *mlx5_ib_create_flow(struct ib_qp *qp,
39743951
}
39753952

39763953
if (flow_attr->type == IB_FLOW_ATTR_NORMAL) {
3977-
if (flow_attr->flags & IB_FLOW_ATTR_FLAGS_DONT_TRAP) {
3978-
handler = create_dont_trap_rule(dev, ft_prio,
3979-
flow_attr, dst);
3980-
} else {
3981-
underlay_qpn = (mqp->flags & MLX5_IB_QP_UNDERLAY) ?
3982-
mqp->underlay_qpn : 0;
3983-
handler = _create_flow_rule(dev, ft_prio, flow_attr,
3984-
dst, underlay_qpn, ucmd);
3985-
}
3954+
underlay_qpn = (mqp->flags & IB_QP_CREATE_SOURCE_QPN) ?
3955+
mqp->underlay_qpn :
3956+
0;
3957+
handler = _create_flow_rule(dev, ft_prio, flow_attr, dst,
3958+
underlay_qpn, ucmd);
39863959
} else if (flow_attr->type == IB_FLOW_ATTR_ALL_DEFAULT ||
39873960
flow_attr->type == IB_FLOW_ATTR_MC_DEFAULT) {
39883961
handler = create_leftovers_rule(dev, ft_prio, flow_attr,

drivers/net/ethernet/mellanox/mlx5/core/Kconfig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ config MLX5_CLS_ACT
8484
default y
8585
help
8686
mlx5 ConnectX offloads support for TC classifier action (NET_CLS_ACT),
87-
works in both native NIC mdoe and Switchdev SRIOV mode.
87+
works in both native NIC mode and Switchdev SRIOV mode.
8888
Actions get attached to a Hardware offloaded classifiers and are
8989
invoked after a successful classification. Actions are used to
9090
overwrite the classification result, instantly drop or redirect and/or

drivers/net/ethernet/mellanox/mlx5/core/accel/tls.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,8 @@ void mlx5_accel_tls_del_flow(struct mlx5_core_dev *mdev, u32 swid,
5656
mlx5_fpga_tls_del_flow(mdev, swid, GFP_KERNEL, direction_sx);
5757
}
5858

59-
int mlx5_accel_tls_resync_rx(struct mlx5_core_dev *mdev, u32 handle, u32 seq,
60-
u64 rcd_sn)
59+
int mlx5_accel_tls_resync_rx(struct mlx5_core_dev *mdev, __be32 handle,
60+
u32 seq, __be64 rcd_sn)
6161
{
6262
return mlx5_fpga_tls_resync_rx(mdev, handle, seq, rcd_sn);
6363
}

drivers/net/ethernet/mellanox/mlx5/core/accel/tls.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -109,8 +109,8 @@ int mlx5_accel_tls_add_flow(struct mlx5_core_dev *mdev, void *flow,
109109
bool direction_sx);
110110
void mlx5_accel_tls_del_flow(struct mlx5_core_dev *mdev, u32 swid,
111111
bool direction_sx);
112-
int mlx5_accel_tls_resync_rx(struct mlx5_core_dev *mdev, u32 handle, u32 seq,
113-
u64 rcd_sn);
112+
int mlx5_accel_tls_resync_rx(struct mlx5_core_dev *mdev, __be32 handle,
113+
u32 seq, __be64 rcd_sn);
114114
bool mlx5_accel_is_tls_device(struct mlx5_core_dev *mdev);
115115
u32 mlx5_accel_tls_device_caps(struct mlx5_core_dev *mdev);
116116
int mlx5_accel_tls_init(struct mlx5_core_dev *mdev);
@@ -125,8 +125,8 @@ mlx5_accel_tls_add_flow(struct mlx5_core_dev *mdev, void *flow,
125125
bool direction_sx) { return -ENOTSUPP; }
126126
static inline void mlx5_accel_tls_del_flow(struct mlx5_core_dev *mdev, u32 swid,
127127
bool direction_sx) { }
128-
static inline int mlx5_accel_tls_resync_rx(struct mlx5_core_dev *mdev, u32 handle,
129-
u32 seq, u64 rcd_sn) { return 0; }
128+
static inline int mlx5_accel_tls_resync_rx(struct mlx5_core_dev *mdev, __be32 handle,
129+
u32 seq, __be64 rcd_sn) { return 0; }
130130
static inline bool mlx5_accel_is_tls_device(struct mlx5_core_dev *mdev)
131131
{
132132
return mlx5_accel_is_ktls_device(mdev);

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

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1072,7 +1072,7 @@ static int mlx5_cmd_invoke(struct mlx5_core_dev *dev, struct mlx5_cmd_msg *in,
10721072

10731073
ds = ent->ts2 - ent->ts1;
10741074
op = MLX5_GET(mbox_in, in->first.data, opcode);
1075-
if (op < ARRAY_SIZE(cmd->stats)) {
1075+
if (op < MLX5_CMD_OP_MAX) {
10761076
stats = &cmd->stats[op];
10771077
spin_lock_irq(&stats->lock);
10781078
stats->sum += ds;
@@ -1551,7 +1551,7 @@ static void mlx5_cmd_comp_handler(struct mlx5_core_dev *dev, u64 vec, bool force
15511551

15521552
if (ent->callback) {
15531553
ds = ent->ts2 - ent->ts1;
1554-
if (ent->op < ARRAY_SIZE(cmd->stats)) {
1554+
if (ent->op < MLX5_CMD_OP_MAX) {
15551555
stats = &cmd->stats[ent->op];
15561556
spin_lock_irqsave(&stats->lock, flags);
15571557
stats->sum += ds;
@@ -1936,6 +1936,11 @@ static void free_cmd_page(struct mlx5_core_dev *dev, struct mlx5_cmd *cmd)
19361936
cmd->alloc_dma);
19371937
}
19381938

1939+
static u16 cmdif_rev(struct mlx5_core_dev *dev)
1940+
{
1941+
return ioread32be(&dev->iseg->cmdif_rev_fw_sub) >> 16;
1942+
}
1943+
19391944
int mlx5_cmd_init(struct mlx5_core_dev *dev)
19401945
{
19411946
int size = sizeof(struct mlx5_cmd_prot_block);
@@ -1955,10 +1960,16 @@ int mlx5_cmd_init(struct mlx5_core_dev *dev)
19551960
return -EINVAL;
19561961
}
19571962

1958-
cmd->pool = dma_pool_create("mlx5_cmd", dev->device, size, align, 0);
1959-
if (!cmd->pool)
1963+
cmd->stats = kvzalloc(MLX5_CMD_OP_MAX * sizeof(*cmd->stats), GFP_KERNEL);
1964+
if (!cmd->stats)
19601965
return -ENOMEM;
19611966

1967+
cmd->pool = dma_pool_create("mlx5_cmd", dev->device, size, align, 0);
1968+
if (!cmd->pool) {
1969+
err = -ENOMEM;
1970+
goto dma_pool_err;
1971+
}
1972+
19621973
err = alloc_cmd_page(dev, cmd);
19631974
if (err)
19641975
goto err_free_pool;
@@ -1994,7 +2005,7 @@ int mlx5_cmd_init(struct mlx5_core_dev *dev)
19942005

19952006
spin_lock_init(&cmd->alloc_lock);
19962007
spin_lock_init(&cmd->token_lock);
1997-
for (i = 0; i < ARRAY_SIZE(cmd->stats); i++)
2008+
for (i = 0; i < MLX5_CMD_OP_MAX; i++)
19982009
spin_lock_init(&cmd->stats[i].lock);
19992010

20002011
sema_init(&cmd->sem, cmd->max_reg_cmds);
@@ -2041,7 +2052,8 @@ int mlx5_cmd_init(struct mlx5_core_dev *dev)
20412052

20422053
err_free_pool:
20432054
dma_pool_destroy(cmd->pool);
2044-
2055+
dma_pool_err:
2056+
kvfree(cmd->stats);
20452057
return err;
20462058
}
20472059
EXPORT_SYMBOL(mlx5_cmd_init);
@@ -2055,6 +2067,7 @@ void mlx5_cmd_cleanup(struct mlx5_core_dev *dev)
20552067
destroy_msg_cache(dev);
20562068
free_cmd_page(dev, cmd);
20572069
dma_pool_destroy(cmd->pool);
2070+
kvfree(cmd->stats);
20582071
}
20592072
EXPORT_SYMBOL(mlx5_cmd_cleanup);
20602073

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

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ void mlx5_cmdif_debugfs_init(struct mlx5_core_dev *dev)
171171
cmd = &dev->priv.cmdif_debugfs;
172172
*cmd = debugfs_create_dir("commands", dev->priv.dbg_root);
173173

174-
for (i = 0; i < ARRAY_SIZE(dev->cmd.stats); i++) {
174+
for (i = 0; i < MLX5_CMD_OP_MAX; i++) {
175175
stats = &dev->cmd.stats[i];
176176
namep = mlx5_command_str(i);
177177
if (strcmp(namep, "unknown command opcode")) {
@@ -202,18 +202,23 @@ void mlx5_cq_debugfs_cleanup(struct mlx5_core_dev *dev)
202202
static u64 qp_read_field(struct mlx5_core_dev *dev, struct mlx5_core_qp *qp,
203203
int index, int *is_str)
204204
{
205-
u32 out[MLX5_ST_SZ_BYTES(query_qp_out)] = {};
205+
int outlen = MLX5_ST_SZ_BYTES(query_qp_out);
206206
u32 in[MLX5_ST_SZ_DW(query_qp_in)] = {};
207207
u64 param = 0;
208+
u32 *out;
208209
int state;
209210
u32 *qpc;
210211
int err;
211212

213+
out = kzalloc(outlen, GFP_KERNEL);
214+
if (!out)
215+
return 0;
216+
212217
MLX5_SET(query_qp_in, in, opcode, MLX5_CMD_OP_QUERY_QP);
213218
MLX5_SET(query_qp_in, in, qpn, qp->qpn);
214219
err = mlx5_cmd_exec_inout(dev, query_qp, in, out);
215220
if (err)
216-
return 0;
221+
goto out;
217222

218223
*is_str = 0;
219224

@@ -269,7 +274,8 @@ static u64 qp_read_field(struct mlx5_core_dev *dev, struct mlx5_core_qp *qp,
269274
param = MLX5_GET(qpc, qpc, remote_qpn);
270275
break;
271276
}
272-
277+
out:
278+
kfree(out);
273279
return param;
274280
}
275281

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

Lines changed: 3 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -25,35 +25,21 @@ static int init_encap_attr(struct net_device *tunnel_dev,
2525
return 0;
2626
}
2727

28-
static inline __be32 mpls_label_id_field(__be32 label, u8 tos, u8 ttl)
29-
{
30-
u32 res;
31-
32-
/* mpls label is 32 bits long and construction as follows:
33-
* 20 bits label
34-
* 3 bits tos
35-
* 1 bit bottom of stack. Since we support only one label, this bit is
36-
* always set.
37-
* 8 bits TTL
38-
*/
39-
res = be32_to_cpu(label) << 12 | 1 << 8 | (tos & 7) << 9 | ttl;
40-
return cpu_to_be32(res);
41-
}
42-
4328
static int generate_ip_tun_hdr(char buf[],
4429
__u8 *ip_proto,
4530
struct mlx5e_encap_entry *r)
4631
{
4732
const struct ip_tunnel_key *tun_key = &r->tun_info->key;
48-
__be32 tun_id = tunnel_id_to_key32(tun_key->tun_id);
4933
struct udphdr *udp = (struct udphdr *)(buf);
5034
struct mpls_shim_hdr *mpls;
35+
u32 tun_id;
5136

37+
tun_id = be32_to_cpu(tunnel_id_to_key32(tun_key->tun_id));
5238
mpls = (struct mpls_shim_hdr *)(udp + 1);
5339
*ip_proto = IPPROTO_UDP;
5440

5541
udp->dest = tun_key->tp_dst;
56-
mpls->label_stack_entry = mpls_label_id_field(tun_id, tun_key->tos, tun_key->ttl);
42+
*mpls = mpls_entry_encode(tun_id, tun_key->ttl, tun_key->tos, true);
5743

5844
return 0;
5945
}

drivers/net/ethernet/mellanox/mlx5/core/en_accel/tls.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ static int mlx5e_tls_resync(struct net_device *netdev, struct sock *sk,
167167
struct tls_context *tls_ctx = tls_get_ctx(sk);
168168
struct mlx5e_priv *priv = netdev_priv(netdev);
169169
struct mlx5e_tls_offload_context_rx *rx_ctx;
170-
u64 rcd_sn = *(u64 *)rcd_sn_data;
170+
__be64 rcd_sn = *(__be64 *)rcd_sn_data;
171171

172172
if (WARN_ON_ONCE(direction != TLS_OFFLOAD_CTX_DIR_RX))
173173
return -EINVAL;

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -985,7 +985,7 @@ static int mlx5e_dcbnl_setbuffer(struct net_device *dev,
985985
return err;
986986
}
987987

988-
const struct dcbnl_rtnl_ops mlx5e_dcbnl_ops = {
988+
static const struct dcbnl_rtnl_ops mlx5e_dcbnl_ops = {
989989
.ieee_getets = mlx5e_dcbnl_ieee_getets,
990990
.ieee_setets = mlx5e_dcbnl_ieee_setets,
991991
.ieee_getmaxrate = mlx5e_dcbnl_ieee_getmaxrate,

0 commit comments

Comments
 (0)