Skip to content

Commit e400b79

Browse files
committed
Merge branch 'mlx4-misc-fixes'
Tariq Toukan says: ==================== mlx4 misc fixes This patchset contains several bug fixes from the team to the mlx4 Eth and Core drivers. Series generated against net commit: 6013386 'net: wan: slic_ds26522: fix spelling mistake: "configurated" -> "configured"' ==================== Signed-off-by: David S. Miller <davem@davemloft.net>
2 parents f0c16ba + 10b1c04 commit e400b79

File tree

7 files changed

+52
-33
lines changed

7 files changed

+52
-33
lines changed

drivers/infiniband/hw/mlx4/main.c

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1682,9 +1682,19 @@ static int __mlx4_ib_create_flow(struct ib_qp *qp, struct ib_flow_attr *flow_att
16821682
size += ret;
16831683
}
16841684

1685+
if (mlx4_is_master(mdev->dev) && flow_type == MLX4_FS_REGULAR &&
1686+
flow_attr->num_of_specs == 1) {
1687+
struct _rule_hw *rule_header = (struct _rule_hw *)(ctrl + 1);
1688+
enum ib_flow_spec_type header_spec =
1689+
((union ib_flow_spec *)(flow_attr + 1))->type;
1690+
1691+
if (header_spec == IB_FLOW_SPEC_ETH)
1692+
mlx4_handle_eth_header_mcast_prio(ctrl, rule_header);
1693+
}
1694+
16851695
ret = mlx4_cmd_imm(mdev->dev, mailbox->dma, reg_id, size >> 2, 0,
16861696
MLX4_QP_FLOW_STEERING_ATTACH, MLX4_CMD_TIME_CLASS_A,
1687-
MLX4_CMD_WRAPPED);
1697+
MLX4_CMD_NATIVE);
16881698
if (ret == -ENOMEM)
16891699
pr_err("mcg table is full. Fail to register network rule.\n");
16901700
else if (ret == -ENXIO)
@@ -1701,7 +1711,7 @@ static int __mlx4_ib_destroy_flow(struct mlx4_dev *dev, u64 reg_id)
17011711
int err;
17021712
err = mlx4_cmd(dev, reg_id, 0, 0,
17031713
MLX4_QP_FLOW_STEERING_DETACH, MLX4_CMD_TIME_CLASS_A,
1704-
MLX4_CMD_WRAPPED);
1714+
MLX4_CMD_NATIVE);
17051715
if (err)
17061716
pr_err("Fail to detach network rule. registration id = 0x%llx\n",
17071717
reg_id);

drivers/net/ethernet/mellanox/mlx4/en_clock.c

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -245,13 +245,9 @@ static u32 freq_to_shift(u16 freq)
245245
{
246246
u32 freq_khz = freq * 1000;
247247
u64 max_val_cycles = freq_khz * 1000 * MLX4_EN_WRAP_AROUND_SEC;
248-
u64 tmp_rounded =
249-
roundup_pow_of_two(max_val_cycles) > max_val_cycles ?
250-
roundup_pow_of_two(max_val_cycles) - 1 : UINT_MAX;
251-
u64 max_val_cycles_rounded = is_power_of_2(max_val_cycles + 1) ?
252-
max_val_cycles : tmp_rounded;
248+
u64 max_val_cycles_rounded = 1ULL << fls64(max_val_cycles - 1);
253249
/* calculate max possible multiplier in order to fit in 64bit */
254-
u64 max_mul = div_u64(0xffffffffffffffffULL, max_val_cycles_rounded);
250+
u64 max_mul = div64_u64(ULLONG_MAX, max_val_cycles_rounded);
255251

256252
/* This comes from the reverse of clocksource_khz2mult */
257253
return ilog2(div_u64(max_mul * freq_khz, 1000000));

drivers/net/ethernet/mellanox/mlx4/en_rx.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -445,8 +445,14 @@ int mlx4_en_activate_rx_rings(struct mlx4_en_priv *priv)
445445
ring->cqn = priv->rx_cq[ring_ind]->mcq.cqn;
446446

447447
ring->stride = stride;
448-
if (ring->stride <= TXBB_SIZE)
448+
if (ring->stride <= TXBB_SIZE) {
449+
/* Stamp first unused send wqe */
450+
__be32 *ptr = (__be32 *)ring->buf;
451+
__be32 stamp = cpu_to_be32(1 << STAMP_SHIFT);
452+
*ptr = stamp;
453+
/* Move pointer to start of rx section */
449454
ring->buf += TXBB_SIZE;
455+
}
450456

451457
ring->log_stride = ffs(ring->stride) - 1;
452458
ring->buf_size = ring->size * ring->stride;

drivers/net/ethernet/mellanox/mlx4/icm.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,8 +118,13 @@ static int mlx4_alloc_icm_coherent(struct device *dev, struct scatterlist *mem,
118118
if (!buf)
119119
return -ENOMEM;
120120

121+
if (offset_in_page(buf)) {
122+
dma_free_coherent(dev, PAGE_SIZE << order,
123+
buf, sg_dma_address(mem));
124+
return -ENOMEM;
125+
}
126+
121127
sg_set_buf(mem, buf, PAGE_SIZE << order);
122-
BUG_ON(mem->offset);
123128
sg_dma_len(mem) = PAGE_SIZE << order;
124129
return 0;
125130
}

drivers/net/ethernet/mellanox/mlx4/main.c

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@
4242
#include <linux/io-mapping.h>
4343
#include <linux/delay.h>
4444
#include <linux/kmod.h>
45+
#include <linux/etherdevice.h>
4546
#include <net/devlink.h>
4647

4748
#include <linux/mlx4/device.h>
@@ -782,6 +783,23 @@ int mlx4_is_slave_active(struct mlx4_dev *dev, int slave)
782783
}
783784
EXPORT_SYMBOL(mlx4_is_slave_active);
784785

786+
void mlx4_handle_eth_header_mcast_prio(struct mlx4_net_trans_rule_hw_ctrl *ctrl,
787+
struct _rule_hw *eth_header)
788+
{
789+
if (is_multicast_ether_addr(eth_header->eth.dst_mac) ||
790+
is_broadcast_ether_addr(eth_header->eth.dst_mac)) {
791+
struct mlx4_net_trans_rule_hw_eth *eth =
792+
(struct mlx4_net_trans_rule_hw_eth *)eth_header;
793+
struct _rule_hw *next_rule = (struct _rule_hw *)(eth + 1);
794+
bool last_rule = next_rule->size == 0 && next_rule->id == 0 &&
795+
next_rule->rsvd == 0;
796+
797+
if (last_rule)
798+
ctrl->prio = cpu_to_be16(MLX4_DOMAIN_NIC);
799+
}
800+
}
801+
EXPORT_SYMBOL(mlx4_handle_eth_header_mcast_prio);
802+
785803
static void slave_adjust_steering_mode(struct mlx4_dev *dev,
786804
struct mlx4_dev_cap *dev_cap,
787805
struct mlx4_init_hca_param *hca_param)

drivers/net/ethernet/mellanox/mlx4/resource_tracker.c

Lines changed: 5 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -4164,22 +4164,6 @@ static int validate_eth_header_mac(int slave, struct _rule_hw *eth_header,
41644164
return 0;
41654165
}
41664166

4167-
static void handle_eth_header_mcast_prio(struct mlx4_net_trans_rule_hw_ctrl *ctrl,
4168-
struct _rule_hw *eth_header)
4169-
{
4170-
if (is_multicast_ether_addr(eth_header->eth.dst_mac) ||
4171-
is_broadcast_ether_addr(eth_header->eth.dst_mac)) {
4172-
struct mlx4_net_trans_rule_hw_eth *eth =
4173-
(struct mlx4_net_trans_rule_hw_eth *)eth_header;
4174-
struct _rule_hw *next_rule = (struct _rule_hw *)(eth + 1);
4175-
bool last_rule = next_rule->size == 0 && next_rule->id == 0 &&
4176-
next_rule->rsvd == 0;
4177-
4178-
if (last_rule)
4179-
ctrl->prio = cpu_to_be16(MLX4_DOMAIN_NIC);
4180-
}
4181-
}
4182-
41834167
/*
41844168
* In case of missing eth header, append eth header with a MAC address
41854169
* assigned to the VF.
@@ -4363,10 +4347,7 @@ int mlx4_QP_FLOW_STEERING_ATTACH_wrapper(struct mlx4_dev *dev, int slave,
43634347
header_id = map_hw_to_sw_id(be16_to_cpu(rule_header->id));
43644348

43654349
if (header_id == MLX4_NET_TRANS_RULE_ID_ETH)
4366-
handle_eth_header_mcast_prio(ctrl, rule_header);
4367-
4368-
if (slave == dev->caps.function)
4369-
goto execute;
4350+
mlx4_handle_eth_header_mcast_prio(ctrl, rule_header);
43704351

43714352
switch (header_id) {
43724353
case MLX4_NET_TRANS_RULE_ID_ETH:
@@ -4394,7 +4375,6 @@ int mlx4_QP_FLOW_STEERING_ATTACH_wrapper(struct mlx4_dev *dev, int slave,
43944375
goto err_put_qp;
43954376
}
43964377

4397-
execute:
43984378
err = mlx4_cmd_imm(dev, inbox->dma, &vhcr->out_param,
43994379
vhcr->in_modifier, 0,
44004380
MLX4_QP_FLOW_STEERING_ATTACH, MLX4_CMD_TIME_CLASS_A,
@@ -4473,6 +4453,7 @@ int mlx4_QP_FLOW_STEERING_DETACH_wrapper(struct mlx4_dev *dev, int slave,
44734453
struct res_qp *rqp;
44744454
struct res_fs_rule *rrule;
44754455
u64 mirr_reg_id;
4456+
int qpn;
44764457

44774458
if (dev->caps.steering_mode !=
44784459
MLX4_STEERING_MODE_DEVICE_MANAGED)
@@ -4489,10 +4470,11 @@ int mlx4_QP_FLOW_STEERING_DETACH_wrapper(struct mlx4_dev *dev, int slave,
44894470
}
44904471
mirr_reg_id = rrule->mirr_rule_id;
44914472
kfree(rrule->mirr_mbox);
4473+
qpn = rrule->qpn;
44924474

44934475
/* Release the rule form busy state before removal */
44944476
put_res(dev, slave, vhcr->in_param, RES_FS_RULE);
4495-
err = get_res(dev, slave, rrule->qpn, RES_QP, &rqp);
4477+
err = get_res(dev, slave, qpn, RES_QP, &rqp);
44964478
if (err)
44974479
return err;
44984480

@@ -4517,7 +4499,7 @@ int mlx4_QP_FLOW_STEERING_DETACH_wrapper(struct mlx4_dev *dev, int slave,
45174499
if (!err)
45184500
atomic_dec(&rqp->ref_count);
45194501
out:
4520-
put_res(dev, slave, rrule->qpn, RES_QP);
4502+
put_res(dev, slave, qpn, RES_QP);
45214503
return err;
45224504
}
45234505

include/linux/mlx4/device.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1384,6 +1384,8 @@ int set_phv_bit(struct mlx4_dev *dev, u8 port, int new_val);
13841384
int get_phv_bit(struct mlx4_dev *dev, u8 port, int *phv);
13851385
int mlx4_get_is_vlan_offload_disabled(struct mlx4_dev *dev, u8 port,
13861386
bool *vlan_offload_disabled);
1387+
void mlx4_handle_eth_header_mcast_prio(struct mlx4_net_trans_rule_hw_ctrl *ctrl,
1388+
struct _rule_hw *eth_header);
13871389
int mlx4_find_cached_mac(struct mlx4_dev *dev, u8 port, u64 mac, int *idx);
13881390
int mlx4_find_cached_vlan(struct mlx4_dev *dev, u8 port, u16 vid, int *idx);
13891391
int mlx4_register_vlan(struct mlx4_dev *dev, u8 port, u16 vlan, int *index);

0 commit comments

Comments
 (0)