History

Merge branch 'mlxsw-Remove-compatibility-with-old-firmware'

Jiri Pirko says: ==================== mlxsw: Remove compatibility with old firmware Up until recently we couldn't enforce a minimal firmware version, which forced us to be compatible with old firmware versions. This patchset removes this code and simplifies the driver. ====================

David S. Miller committed 9 years ago

Commit cb7f8fc2 parents 4cd31af 2e915e02 files · +35 −81Browse files

Unified · Split

2 files
  1. drivers/net/ethernet/mellanox/mlxsw/spectrum.c +34 −80
  2. drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c +1 −1
drivers/net/ethernet/mellanox/mlxsw/spectrum.c+34−80
@@ -860,21 +860,13 @@ static int mlxsw_sp_port_mtu_set(struct mlxsw_sp_port *mlxsw_sp_port, u16 mtu) · 859 unmodified lines
860860 return mlxsw_reg_write(mlxsw_sp->core, MLXSW_REG(pmtu), pmtu_pl);
861861 }
862862
863−static int __mlxsw_sp_port_swid_set(struct mlxsw_sp *mlxsw_sp, u8 local_port,
864− u8 swid)
865−{
866− char pspa_pl[MLXSW_REG_PSPA_LEN];
867−
868− mlxsw_reg_pspa_pack(pspa_pl, swid, local_port);
869− return mlxsw_reg_write(mlxsw_sp->core, MLXSW_REG(pspa), pspa_pl);
870−}
871−
872863 static int mlxsw_sp_port_swid_set(struct mlxsw_sp_port *mlxsw_sp_port, u8 swid)
873864 {
874865 struct mlxsw_sp *mlxsw_sp = mlxsw_sp_port->mlxsw_sp;
866+ char pspa_pl[MLXSW_REG_PSPA_LEN];
875867
876− return __mlxsw_sp_port_swid_set(mlxsw_sp, mlxsw_sp_port->local_port,
877− swid);
868+ mlxsw_reg_pspa_pack(pspa_pl, swid, mlxsw_sp_port->local_port);
869+ return mlxsw_reg_write(mlxsw_sp->core, MLXSW_REG(pspa), pspa_pl);
878870 }
879871
880872 int mlxsw_sp_port_vp_mode_set(struct mlxsw_sp_port *mlxsw_sp_port, bool enable)
@@ -975,13 +967,14 @@ static int mlxsw_sp_port_module_info_get(struct mlxsw_sp *mlxsw_sp, · 94 unmodified lines
975967 return 0;
976968 }
977969
978−static int mlxsw_sp_port_module_map(struct mlxsw_sp *mlxsw_sp, u8 local_port,
970+static int mlxsw_sp_port_module_map(struct mlxsw_sp_port *mlxsw_sp_port,
979971 u8 module, u8 width, u8 lane)
980972 {
973+ struct mlxsw_sp *mlxsw_sp = mlxsw_sp_port->mlxsw_sp;
981974 char pmlp_pl[MLXSW_REG_PMLP_LEN];
982975 int i;
983976
984− mlxsw_reg_pmlp_pack(pmlp_pl, local_port);
977+ mlxsw_reg_pmlp_pack(pmlp_pl, mlxsw_sp_port->local_port);
985978 mlxsw_reg_pmlp_width_set(pmlp_pl, width);
986979 for (i = 0; i < width; i++) {
987980 mlxsw_reg_pmlp_module_set(pmlp_pl, i, module);
@@ -991,11 +984,12 @@ static int mlxsw_sp_port_module_map(struct mlxsw_sp *mlxsw_sp, u8 local_port, · 3 unmodified lines
991984 return mlxsw_reg_write(mlxsw_sp->core, MLXSW_REG(pmlp), pmlp_pl);
992985 }
993986
994−static int mlxsw_sp_port_module_unmap(struct mlxsw_sp *mlxsw_sp, u8 local_port)
987+static int mlxsw_sp_port_module_unmap(struct mlxsw_sp_port *mlxsw_sp_port)
995988 {
989+ struct mlxsw_sp *mlxsw_sp = mlxsw_sp_port->mlxsw_sp;
996990 char pmlp_pl[MLXSW_REG_PMLP_LEN];
997991
998− mlxsw_reg_pmlp_pack(pmlp_pl, local_port);
992+ mlxsw_reg_pmlp_pack(pmlp_pl, mlxsw_sp_port->local_port);
999993 mlxsw_reg_pmlp_width_set(pmlp_pl, 0);
1000994 return mlxsw_reg_write(mlxsw_sp->core, MLXSW_REG(pmlp), pmlp_pl);
1001995 }
@@ -2655,17 +2649,26 @@ static int mlxsw_sp_port_ets_init(struct mlxsw_sp_port *mlxsw_sp_port) · 1653 unmodified lines
26552649 return 0;
26562650 }
26572651
2658−static int __mlxsw_sp_port_create(struct mlxsw_sp *mlxsw_sp, u8 local_port,
2659− bool split, u8 module, u8 width, u8 lane)
2652+static int mlxsw_sp_port_create(struct mlxsw_sp *mlxsw_sp, u8 local_port,
2653+ bool split, u8 module, u8 width, u8 lane)
26602654 {
26612655 struct mlxsw_sp_port_vlan *mlxsw_sp_port_vlan;
26622656 struct mlxsw_sp_port *mlxsw_sp_port;
26632657 struct net_device *dev;
26642658 int err;
26652659
2660+ err = mlxsw_core_port_init(mlxsw_sp->core, local_port);
2661+ if (err) {
2662+ dev_err(mlxsw_sp->bus_info->dev, "Port %d: Failed to init core port\n",
2663+ local_port);
2664+ return err;
2665+ }
2666+
26662667 dev = alloc_etherdev(sizeof(struct mlxsw_sp_port));
2667− if (!dev)
2668− return -ENOMEM;
2668+ if (!dev) {
2669+ err = -ENOMEM;
2670+ goto err_alloc_etherdev;
2671+ }
26692672 SET_NETDEV_DEV(dev, mlxsw_sp->bus_info->dev);
26702673 mlxsw_sp_port = netdev_priv(dev);
26712674 mlxsw_sp_port->dev = dev;
@@ -2707,6 +2710,13 @@ static int __mlxsw_sp_port_create(struct mlxsw_sp *mlxsw_sp, u8 local_port, · 35 unmodified lines
27072710 dev->netdev_ops = &mlxsw_sp_port_netdev_ops;
27082711 dev->ethtool_ops = &mlxsw_sp_port_ethtool_ops;
27092712
2713+ err = mlxsw_sp_port_module_map(mlxsw_sp_port, module, width, lane);
2714+ if (err) {
2715+ dev_err(mlxsw_sp->bus_info->dev, "Port %d: Failed to map module\n",
2716+ mlxsw_sp_port->local_port);
2717+ goto err_port_module_map;
2718+ }
2719+
27102720 err = mlxsw_sp_port_swid_set(mlxsw_sp_port, 0);
27112721 if (err) {
27122722 dev_err(mlxsw_sp->bus_info->dev, "Port %d: Failed to set SWID\n",
@@ -2829,6 +2839,8 @@ err_port_system_port_mapping_set: · 116 unmodified lines
28292839 err_dev_addr_init:
28302840 mlxsw_sp_port_swid_set(mlxsw_sp_port, MLXSW_PORT_SWID_DISABLED_PORT);
28312841 err_port_swid_set:
2842+ mlxsw_sp_port_module_unmap(mlxsw_sp_port);
2843+err_port_module_map:
28322844 kfree(mlxsw_sp_port->hw_stats.cache);
28332845 err_alloc_hw_stats:
28342846 kfree(mlxsw_sp_port->sample);
@@ -2836,32 +2848,12 @@ err_alloc_sample: · 1 unmodified line
28362848 free_percpu(mlxsw_sp_port->pcpu_stats);
28372849 err_alloc_stats:
28382850 free_netdev(dev);
2839− return err;
2840−}
2841−
2842−static int mlxsw_sp_port_create(struct mlxsw_sp *mlxsw_sp, u8 local_port,
2843− bool split, u8 module, u8 width, u8 lane)
2844−{
2845− int err;
2846−
2847− err = mlxsw_core_port_init(mlxsw_sp->core, local_port);
2848− if (err) {
2849− dev_err(mlxsw_sp->bus_info->dev, "Port %d: Failed to init core port\n",
2850− local_port);
2851− return err;
2852− }
2853− err = __mlxsw_sp_port_create(mlxsw_sp, local_port, split,
2854− module, width, lane);
2855− if (err)
2856− goto err_port_create;
2857− return 0;
2858−
2859−err_port_create:
2851+err_alloc_etherdev:
28602852 mlxsw_core_port_fini(mlxsw_sp->core, local_port);
28612853 return err;
28622854 }
28632855
2864−static void __mlxsw_sp_port_remove(struct mlxsw_sp *mlxsw_sp, u8 local_port)
2856+static void mlxsw_sp_port_remove(struct mlxsw_sp *mlxsw_sp, u8 local_port)
28652857 {
28662858 struct mlxsw_sp_port *mlxsw_sp_port = mlxsw_sp->ports[local_port];
28672859
@@ -2874,17 +2866,12 @@ static void __mlxsw_sp_port_remove(struct mlxsw_sp *mlxsw_sp, u8 local_port) · 6 unmodified lines
28742866 mlxsw_sp_port_fids_fini(mlxsw_sp_port);
28752867 mlxsw_sp_port_dcb_fini(mlxsw_sp_port);
28762868 mlxsw_sp_port_swid_set(mlxsw_sp_port, MLXSW_PORT_SWID_DISABLED_PORT);
2877− mlxsw_sp_port_module_unmap(mlxsw_sp, mlxsw_sp_port->local_port);
2869+ mlxsw_sp_port_module_unmap(mlxsw_sp_port);
28782870 kfree(mlxsw_sp_port->hw_stats.cache);
28792871 kfree(mlxsw_sp_port->sample);
28802872 free_percpu(mlxsw_sp_port->pcpu_stats);
28812873 WARN_ON_ONCE(!list_empty(&mlxsw_sp_port->vlans_list));
28822874 free_netdev(mlxsw_sp_port->dev);
2883−}
2884−
2885−static void mlxsw_sp_port_remove(struct mlxsw_sp *mlxsw_sp, u8 local_port)
2886−{
2887− __mlxsw_sp_port_remove(mlxsw_sp, local_port);
28882875 mlxsw_core_port_fini(mlxsw_sp->core, local_port);
28892876 }
28902877
@@ -2962,19 +2949,6 @@ static int mlxsw_sp_port_split_create(struct mlxsw_sp *mlxsw_sp, u8 base_port, · 71 unmodified lines
29622949 u8 width = MLXSW_PORT_MODULE_MAX_WIDTH / count;
29632950 int err, i;
29642951
2965− for (i = 0; i < count; i++) {
2966− err = mlxsw_sp_port_module_map(mlxsw_sp, base_port + i, module,
2967− width, i * width);
2968− if (err)
2969− goto err_port_module_map;
2970− }
2971−
2972− for (i = 0; i < count; i++) {
2973− err = __mlxsw_sp_port_swid_set(mlxsw_sp, base_port + i, 0);
2974− if (err)
2975− goto err_port_swid_set;
2976− }
2977−
29782952 for (i = 0; i < count; i++) {
29792953 err = mlxsw_sp_port_create(mlxsw_sp, base_port + i, true,
29802954 module, width, i * width);
@@ -2988,15 +2962,6 @@ err_port_create: · 7 unmodified lines
29882962 for (i--; i >= 0; i--)
29892963 if (mlxsw_sp_port_created(mlxsw_sp, base_port + i))
29902964 mlxsw_sp_port_remove(mlxsw_sp, base_port + i);
2991− i = count;
2992−err_port_swid_set:
2993− for (i--; i >= 0; i--)
2994− __mlxsw_sp_port_swid_set(mlxsw_sp, base_port + i,
2995− MLXSW_PORT_SWID_DISABLED_PORT);
2996− i = count;
2997−err_port_module_map:
2998− for (i--; i >= 0; i--)
2999− mlxsw_sp_port_module_unmap(mlxsw_sp, base_port + i);
30002965 return err;
30012966 }
30022967
@@ -3011,17 +2976,6 @@ static void mlxsw_sp_port_unsplit_create(struct mlxsw_sp *mlxsw_sp, · 8 unmodified lines
30112976 */
30122977 count = count / 2;
30132978
3014− for (i = 0; i < count; i++) {
3015− local_port = base_port + i * 2;
3016− module = mlxsw_sp->port_to_module[local_port];
3017−
3018− mlxsw_sp_port_module_map(mlxsw_sp, local_port, module, width,
3019− 0);
3020− }
3021−
3022− for (i = 0; i < count; i++)
3023− __mlxsw_sp_port_swid_set(mlxsw_sp, base_port + i * 2, 0);
3024−
30252979 for (i = 0; i < count; i++) {
30262980 local_port = base_port + i * 2;
30272981 module = mlxsw_sp->port_to_module[local_port];
drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c+1−1
@@ -591,7 +591,7 @@ static int mlxsw_sp_lpm_tree_put(struct mlxsw_sp *mlxsw_sp, · 590 unmodified lines
591591 return 0;
592592 }
593593
594−#define MLXSW_SP_LPM_TREE_MIN 2 /* trees 0 and 1 are reserved */
594+#define MLXSW_SP_LPM_TREE_MIN 1 /* tree 0 is reserved */
595595
596596 static int mlxsw_sp_lpm_init(struct mlxsw_sp *mlxsw_sp)
597597 {