Skip to content

Commit 4be9993

Browse files
committed
Merge branch 'mlx4-misc-improvements'
Tariq Toukan says: ==================== mlx4 misc improvements This patchset contains several improvements and cleanups from the team to the mlx4 Eth and core drivers. Series generated against net-next commit: 4e8f2fc Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net Thanks, Tariq. v3: * Patch 6/9: forgot to actually update the commit message in v2, now it is. v2: * Patch 1/9: used EOPNOTSUPP and not ENOTSUPP. * Patch 3/9: dropped, to be submitted separately in the future. * Patch 6/9: updated commit message. ==================== Signed-off-by: David S. Miller <[email protected]>
2 parents 30357d7 + 1f8176f commit 4be9993

File tree

10 files changed

+228
-63
lines changed

10 files changed

+228
-63
lines changed

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

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -902,6 +902,7 @@ mlx4_en_set_link_ksettings(struct net_device *dev,
902902
struct mlx4_en_priv *priv = netdev_priv(dev);
903903
struct mlx4_ptys_reg ptys_reg;
904904
__be32 proto_admin;
905+
u8 cur_autoneg;
905906
int ret;
906907

907908
u32 ptys_adv = ethtool2ptys_link_modes(
@@ -931,18 +932,31 @@ mlx4_en_set_link_ksettings(struct net_device *dev,
931932
return 0;
932933
}
933934

934-
proto_admin = link_ksettings->base.autoneg == AUTONEG_ENABLE ?
935-
cpu_to_be32(ptys_adv) :
936-
speed_set_ptys_admin(priv, speed,
937-
ptys_reg.eth_proto_cap);
935+
cur_autoneg = ptys_reg.flags & MLX4_PTYS_AN_DISABLE_ADMIN ?
936+
AUTONEG_DISABLE : AUTONEG_ENABLE;
937+
938+
if (link_ksettings->base.autoneg == AUTONEG_DISABLE) {
939+
proto_admin = speed_set_ptys_admin(priv, speed,
940+
ptys_reg.eth_proto_cap);
941+
if ((be32_to_cpu(proto_admin) &
942+
(MLX4_PROT_MASK(MLX4_1000BASE_CX_SGMII) |
943+
MLX4_PROT_MASK(MLX4_1000BASE_KX))) &&
944+
(ptys_reg.flags & MLX4_PTYS_AN_DISABLE_CAP))
945+
ptys_reg.flags |= MLX4_PTYS_AN_DISABLE_ADMIN;
946+
} else {
947+
proto_admin = cpu_to_be32(ptys_adv);
948+
ptys_reg.flags &= ~MLX4_PTYS_AN_DISABLE_ADMIN;
949+
}
938950

939951
proto_admin &= ptys_reg.eth_proto_cap;
940952
if (!proto_admin) {
941953
en_warn(priv, "Not supported link mode(s) requested, check supported link modes.\n");
942954
return -EINVAL; /* nothing to change due to bad input */
943955
}
944956

945-
if (proto_admin == ptys_reg.eth_proto_admin)
957+
if ((proto_admin == ptys_reg.eth_proto_admin) &&
958+
((ptys_reg.flags & MLX4_PTYS_AN_DISABLE_CAP) &&
959+
(link_ksettings->base.autoneg == cur_autoneg)))
946960
return 0; /* Nothing to change */
947961

948962
en_dbg(DRV, priv, "mlx4_ACCESS_PTYS_REG SET: ptys_reg.eth_proto_admin = 0x%x\n",
@@ -1788,7 +1802,7 @@ static int mlx4_en_set_channels(struct net_device *dev,
17881802
netif_set_real_num_tx_queues(dev, priv->tx_ring_num[TX]);
17891803
netif_set_real_num_rx_queues(dev, priv->rx_ring_num);
17901804

1791-
if (dev->num_tc)
1805+
if (netdev_get_num_tc(dev))
17921806
mlx4_en_setup_tc(dev, MLX4_EN_NUM_UP);
17931807

17941808
en_warn(priv, "Using %d TX rings\n", priv->tx_ring_num[TX]);
@@ -1980,7 +1994,7 @@ static int mlx4_en_get_module_info(struct net_device *dev,
19801994
modinfo->eeprom_len = ETH_MODULE_SFF_8472_LEN;
19811995
break;
19821996
default:
1983-
return -ENOSYS;
1997+
return -EINVAL;
19841998
}
19851999

19862000
return 0;

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1695,6 +1695,14 @@ int mlx4_en_start_port(struct net_device *dev)
16951695
priv->port, err);
16961696
goto tx_err;
16971697
}
1698+
1699+
err = mlx4_SET_PORT_user_mtu(mdev->dev, priv->port, dev->mtu);
1700+
if (err) {
1701+
en_err(priv, "Failed to pass user MTU(%d) to Firmware for port %d, with error %d\n",
1702+
dev->mtu, priv->port, err);
1703+
goto tx_err;
1704+
}
1705+
16981706
/* Set default qp number */
16991707
err = mlx4_SET_PORT_qpn_calc(mdev->dev, priv->port, priv->base_qpn, 0);
17001708
if (err) {

drivers/net/ethernet/mellanox/mlx4/en_port.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@
3535
#define _MLX4_EN_PORT_H_
3636

3737

38-
#define SET_PORT_GEN_ALL_VALID 0x7
3938
#define SET_PORT_PROMISC_SHIFT 31
4039
#define SET_PORT_MC_PROMISC_SHIFT 30
4140

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -710,7 +710,7 @@ u16 mlx4_en_select_queue(struct net_device *dev, struct sk_buff *skb,
710710
u16 rings_p_up = priv->num_tx_rings_p_up;
711711
u8 up = 0;
712712

713-
if (dev->num_tc)
713+
if (netdev_get_num_tc(dev))
714714
return skb_tx_hash(dev, skb);
715715

716716
if (skb_vlan_tag_present(skb))

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -672,7 +672,7 @@ int mlx4_QUERY_FUNC_CAP(struct mlx4_dev *dev, u8 gen_or_port,
672672
MLX4_GET(field, outbox, QUERY_FUNC_CAP_PHYS_PORT_OFFSET);
673673
func_cap->physical_port = field;
674674
if (func_cap->physical_port != gen_or_port) {
675-
err = -ENOSYS;
675+
err = -EINVAL;
676676
goto out;
677677
}
678678

@@ -1875,7 +1875,7 @@ int mlx4_INIT_HCA(struct mlx4_dev *dev, struct mlx4_init_hca_param *param)
18751875
*((u8 *) mailbox->buf + INIT_HCA_VERSION_OFFSET) = INIT_HCA_VERSION;
18761876

18771877
*((u8 *) mailbox->buf + INIT_HCA_CACHELINE_SZ_OFFSET) =
1878-
(ilog2(cache_line_size()) - 4) << 5;
1878+
((ilog2(cache_line_size()) - 4) << 5) | (1 << 4);
18791879

18801880
#if defined(__LITTLE_ENDIAN)
18811881
*(inbox + INIT_HCA_FLAGS_OFFSET / 4) &= ~cpu_to_be32(1 << 1);
@@ -2983,7 +2983,7 @@ static int mlx4_SET_PORT_phv_bit(struct mlx4_dev *dev, u8 port, u8 phv_bit)
29832983
return PTR_ERR(mailbox);
29842984
context = mailbox->buf;
29852985

2986-
context->v_ignore_fcs |= SET_PORT_GEN_PHV_VALID;
2986+
context->flags2 |= SET_PORT_GEN_PHV_VALID;
29872987
if (phv_bit)
29882988
context->phv_en |= SET_PORT_GEN_PHV_EN;
29892989

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -838,7 +838,7 @@ static int mlx4_slave_cap(struct mlx4_dev *dev)
838838
*/
839839
if (hca_param.global_caps) {
840840
mlx4_err(dev, "Unknown hca global capabilities\n");
841-
return -ENOSYS;
841+
return -EINVAL;
842842
}
843843

844844
mlx4_log_num_mgm_entry_size = hca_param.log_mc_entry_sz;
@@ -896,7 +896,7 @@ static int mlx4_slave_cap(struct mlx4_dev *dev)
896896
PF_CONTEXT_BEHAVIOUR_MASK) {
897897
mlx4_err(dev, "Unknown pf context behaviour %x known flags %x\n",
898898
func_cap.pf_context_behaviour, PF_CONTEXT_BEHAVIOUR_MASK);
899-
return -ENOSYS;
899+
return -EINVAL;
900900
}
901901

902902
dev->caps.num_ports = func_cap.num_ports;
@@ -3492,7 +3492,7 @@ static int mlx4_load_one(struct pci_dev *pdev, int pci_dev_data,
34923492
mlx4_enable_msi_x(dev);
34933493
if ((mlx4_is_mfunc(dev)) &&
34943494
!(dev->flags & MLX4_FLAG_MSI_X)) {
3495-
err = -ENOSYS;
3495+
err = -EOPNOTSUPP;
34963496
mlx4_err(dev, "INTx is not supported in multi-function mode, aborting\n");
34973497
goto err_free_eq;
34983498
}

drivers/net/ethernet/mellanox/mlx4/mlx4.h

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -487,6 +487,7 @@ struct mlx4_slave_state {
487487
bool vst_qinq_supported;
488488
u8 function;
489489
dma_addr_t vhcr_dma;
490+
u16 user_mtu[MLX4_MAX_PORTS + 1];
490491
u16 mtu[MLX4_MAX_PORTS + 1];
491492
__be32 ib_cap_mask[MLX4_MAX_PORTS + 1];
492493
struct mlx4_slave_eqe eq[MLX4_MFUNC_MAX_EQES];
@@ -590,6 +591,7 @@ struct mlx4_mfunc_master_ctx {
590591
struct mlx4_master_qp0_state qp0_state[MLX4_MAX_PORTS + 1];
591592
int init_port_ref[MLX4_MAX_PORTS + 1];
592593
u16 max_mtu[MLX4_MAX_PORTS + 1];
594+
u16 max_user_mtu[MLX4_MAX_PORTS + 1];
593595
u8 pptx;
594596
u8 pprx;
595597
int disable_mcast_ref[MLX4_MAX_PORTS + 1];
@@ -774,7 +776,9 @@ struct mlx4_vlan_table {
774776
int max;
775777
};
776778

777-
#define SET_PORT_GEN_ALL_VALID 0x7
779+
#define SET_PORT_GEN_ALL_VALID (MLX4_FLAG_V_MTU_MASK | \
780+
MLX4_FLAG_V_PPRX_MASK | \
781+
MLX4_FLAG_V_PPTX_MASK)
778782
#define SET_PORT_PROMISC_SHIFT 31
779783
#define SET_PORT_MC_PROMISC_SHIFT 30
780784

@@ -787,7 +791,7 @@ enum {
787791

788792
struct mlx4_set_port_general_context {
789793
u16 reserved1;
790-
u8 v_ignore_fcs;
794+
u8 flags2;
791795
u8 flags;
792796
union {
793797
u8 ignore_fcs;
@@ -803,7 +807,8 @@ struct mlx4_set_port_general_context {
803807
u16 reserved4;
804808
u32 reserved5;
805809
u8 phv_en;
806-
u8 reserved6[3];
810+
u8 reserved6[5];
811+
__be16 user_mtu;
807812
};
808813

809814
struct mlx4_set_port_rqp_calc_context {

0 commit comments

Comments
 (0)