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. ====================
Unified · Split
| @@ -860,21 +860,13 @@ static int mlxsw_sp_port_mtu_set(struct mlxsw_sp_port *mlxsw_sp_port, u16 mtu) · 859 unmodified lines | |||
| 860 | return mlxsw_reg_write(mlxsw_sp->core, MLXSW_REG(pmtu), pmtu_pl); | 860 | return mlxsw_reg_write(mlxsw_sp->core, MLXSW_REG(pmtu), pmtu_pl); |
| 861 | } | 861 | } |
| 862 | 862 | ||
| 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 | |||
| 872 | static int mlxsw_sp_port_swid_set(struct mlxsw_sp_port *mlxsw_sp_port, u8 swid) | 863 | static int mlxsw_sp_port_swid_set(struct mlxsw_sp_port *mlxsw_sp_port, u8 swid) |
| 873 | { | 864 | { |
| 874 | struct mlxsw_sp *mlxsw_sp = mlxsw_sp_port->mlxsw_sp; | 865 | struct mlxsw_sp *mlxsw_sp = mlxsw_sp_port->mlxsw_sp; |
| 866 | char pspa_pl[MLXSW_REG_PSPA_LEN]; | ||
| 875 | 867 | ||
| 876 | return __mlxsw_sp_port_swid_set(mlxsw_sp, mlxsw_sp_port->local_port, | 868 | mlxsw_reg_pspa_pack(pspa_pl, swid, mlxsw_sp_port->local_port); |
| 877 | swid); | 869 | return mlxsw_reg_write(mlxsw_sp->core, MLXSW_REG(pspa), pspa_pl); |
| 878 | } | 870 | } |
| 879 | 871 | ||
| 880 | int mlxsw_sp_port_vp_mode_set(struct mlxsw_sp_port *mlxsw_sp_port, bool enable) | 872 | 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 | |||
| 975 | return 0; | 967 | return 0; |
| 976 | } | 968 | } |
| 977 | 969 | ||
| 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, |
| 979 | u8 module, u8 width, u8 lane) | 971 | u8 module, u8 width, u8 lane) |
| 980 | { | 972 | { |
| 973 | struct mlxsw_sp *mlxsw_sp = mlxsw_sp_port->mlxsw_sp; | ||
| 981 | char pmlp_pl[MLXSW_REG_PMLP_LEN]; | 974 | char pmlp_pl[MLXSW_REG_PMLP_LEN]; |
| 982 | int i; | 975 | int i; |
| 983 | 976 | ||
| 984 | mlxsw_reg_pmlp_pack(pmlp_pl, local_port); | 977 | mlxsw_reg_pmlp_pack(pmlp_pl, mlxsw_sp_port->local_port); |
| 985 | mlxsw_reg_pmlp_width_set(pmlp_pl, width); | 978 | mlxsw_reg_pmlp_width_set(pmlp_pl, width); |
| 986 | for (i = 0; i < width; i++) { | 979 | for (i = 0; i < width; i++) { |
| 987 | mlxsw_reg_pmlp_module_set(pmlp_pl, i, module); | 980 | 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 | |||
| 991 | return mlxsw_reg_write(mlxsw_sp->core, MLXSW_REG(pmlp), pmlp_pl); | 984 | return mlxsw_reg_write(mlxsw_sp->core, MLXSW_REG(pmlp), pmlp_pl); |
| 992 | } | 985 | } |
| 993 | 986 | ||
| 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) |
| 995 | { | 988 | { |
| 989 | struct mlxsw_sp *mlxsw_sp = mlxsw_sp_port->mlxsw_sp; | ||
| 996 | char pmlp_pl[MLXSW_REG_PMLP_LEN]; | 990 | char pmlp_pl[MLXSW_REG_PMLP_LEN]; |
| 997 | 991 | ||
| 998 | mlxsw_reg_pmlp_pack(pmlp_pl, local_port); | 992 | mlxsw_reg_pmlp_pack(pmlp_pl, mlxsw_sp_port->local_port); |
| 999 | mlxsw_reg_pmlp_width_set(pmlp_pl, 0); | 993 | mlxsw_reg_pmlp_width_set(pmlp_pl, 0); |
| 1000 | return mlxsw_reg_write(mlxsw_sp->core, MLXSW_REG(pmlp), pmlp_pl); | 994 | return mlxsw_reg_write(mlxsw_sp->core, MLXSW_REG(pmlp), pmlp_pl); |
| 1001 | } | 995 | } |
| @@ -2655,17 +2649,26 @@ static int mlxsw_sp_port_ets_init(struct mlxsw_sp_port *mlxsw_sp_port) · 1653 unmodified lines | |||
| 2655 | return 0; | 2649 | return 0; |
| 2656 | } | 2650 | } |
| 2657 | 2651 | ||
| 2658 | static int __mlxsw_sp_port_create(struct mlxsw_sp *mlxsw_sp, u8 local_port, | 2652 | static int mlxsw_sp_port_create(struct mlxsw_sp *mlxsw_sp, u8 local_port, |
| 2659 | bool split, u8 module, u8 width, u8 lane) | 2653 | bool split, u8 module, u8 width, u8 lane) |
| 2660 | { | 2654 | { |
| 2661 | struct mlxsw_sp_port_vlan *mlxsw_sp_port_vlan; | 2655 | struct mlxsw_sp_port_vlan *mlxsw_sp_port_vlan; |
| 2662 | struct mlxsw_sp_port *mlxsw_sp_port; | 2656 | struct mlxsw_sp_port *mlxsw_sp_port; |
| 2663 | struct net_device *dev; | 2657 | struct net_device *dev; |
| 2664 | int err; | 2658 | int err; |
| 2665 | 2659 | ||
| 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 | |||
| 2666 | dev = alloc_etherdev(sizeof(struct mlxsw_sp_port)); | 2667 | dev = alloc_etherdev(sizeof(struct mlxsw_sp_port)); |
| 2667 | if (!dev) | 2668 | if (!dev) { |
| 2668 | return -ENOMEM; | 2669 | err = -ENOMEM; |
| 2670 | goto err_alloc_etherdev; | ||
| 2671 | } | ||
| 2669 | SET_NETDEV_DEV(dev, mlxsw_sp->bus_info->dev); | 2672 | SET_NETDEV_DEV(dev, mlxsw_sp->bus_info->dev); |
| 2670 | mlxsw_sp_port = netdev_priv(dev); | 2673 | mlxsw_sp_port = netdev_priv(dev); |
| 2671 | mlxsw_sp_port->dev = dev; | 2674 | 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 | |||
| 2707 | dev->netdev_ops = &mlxsw_sp_port_netdev_ops; | 2710 | dev->netdev_ops = &mlxsw_sp_port_netdev_ops; |
| 2708 | dev->ethtool_ops = &mlxsw_sp_port_ethtool_ops; | 2711 | dev->ethtool_ops = &mlxsw_sp_port_ethtool_ops; |
| 2709 | 2712 | ||
| 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 | |||
| 2710 | err = mlxsw_sp_port_swid_set(mlxsw_sp_port, 0); | 2720 | err = mlxsw_sp_port_swid_set(mlxsw_sp_port, 0); |
| 2711 | if (err) { | 2721 | if (err) { |
| 2712 | dev_err(mlxsw_sp->bus_info->dev, "Port %d: Failed to set SWID\n", | 2722 | 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 | |||
| 2829 | err_dev_addr_init: | 2839 | err_dev_addr_init: |
| 2830 | mlxsw_sp_port_swid_set(mlxsw_sp_port, MLXSW_PORT_SWID_DISABLED_PORT); | 2840 | mlxsw_sp_port_swid_set(mlxsw_sp_port, MLXSW_PORT_SWID_DISABLED_PORT); |
| 2831 | err_port_swid_set: | 2841 | err_port_swid_set: |
| 2842 | mlxsw_sp_port_module_unmap(mlxsw_sp_port); | ||
| 2843 | err_port_module_map: | ||
| 2832 | kfree(mlxsw_sp_port->hw_stats.cache); | 2844 | kfree(mlxsw_sp_port->hw_stats.cache); |
| 2833 | err_alloc_hw_stats: | 2845 | err_alloc_hw_stats: |
| 2834 | kfree(mlxsw_sp_port->sample); | 2846 | kfree(mlxsw_sp_port->sample); |
| @@ -2836,32 +2848,12 @@ err_alloc_sample: · 1 unmodified line | |||
| 2836 | free_percpu(mlxsw_sp_port->pcpu_stats); | 2848 | free_percpu(mlxsw_sp_port->pcpu_stats); |
| 2837 | err_alloc_stats: | 2849 | err_alloc_stats: |
| 2838 | free_netdev(dev); | 2850 | free_netdev(dev); |
| 2839 | return err; | 2851 | err_alloc_etherdev: |
| 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: | ||
| 2860 | mlxsw_core_port_fini(mlxsw_sp->core, local_port); | 2852 | mlxsw_core_port_fini(mlxsw_sp->core, local_port); |
| 2861 | return err; | 2853 | return err; |
| 2862 | } | 2854 | } |
| 2863 | 2855 | ||
| 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) |
| 2865 | { | 2857 | { |
| 2866 | struct mlxsw_sp_port *mlxsw_sp_port = mlxsw_sp->ports[local_port]; | 2858 | struct mlxsw_sp_port *mlxsw_sp_port = mlxsw_sp->ports[local_port]; |
| 2867 | 2859 | ||
| @@ -2874,17 +2866,12 @@ static void __mlxsw_sp_port_remove(struct mlxsw_sp *mlxsw_sp, u8 local_port) · 6 unmodified lines | |||
| 2874 | mlxsw_sp_port_fids_fini(mlxsw_sp_port); | 2866 | mlxsw_sp_port_fids_fini(mlxsw_sp_port); |
| 2875 | mlxsw_sp_port_dcb_fini(mlxsw_sp_port); | 2867 | mlxsw_sp_port_dcb_fini(mlxsw_sp_port); |
| 2876 | mlxsw_sp_port_swid_set(mlxsw_sp_port, MLXSW_PORT_SWID_DISABLED_PORT); | 2868 | 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); |
| 2878 | kfree(mlxsw_sp_port->hw_stats.cache); | 2870 | kfree(mlxsw_sp_port->hw_stats.cache); |
| 2879 | kfree(mlxsw_sp_port->sample); | 2871 | kfree(mlxsw_sp_port->sample); |
| 2880 | free_percpu(mlxsw_sp_port->pcpu_stats); | 2872 | free_percpu(mlxsw_sp_port->pcpu_stats); |
| 2881 | WARN_ON_ONCE(!list_empty(&mlxsw_sp_port->vlans_list)); | 2873 | WARN_ON_ONCE(!list_empty(&mlxsw_sp_port->vlans_list)); |
| 2882 | free_netdev(mlxsw_sp_port->dev); | 2874 | 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); | ||
| 2888 | mlxsw_core_port_fini(mlxsw_sp->core, local_port); | 2875 | mlxsw_core_port_fini(mlxsw_sp->core, local_port); |
| 2889 | } | 2876 | } |
| 2890 | 2877 | ||
| @@ -2962,19 +2949,6 @@ static int mlxsw_sp_port_split_create(struct mlxsw_sp *mlxsw_sp, u8 base_port, · 71 unmodified lines | |||
| 2962 | u8 width = MLXSW_PORT_MODULE_MAX_WIDTH / count; | 2949 | u8 width = MLXSW_PORT_MODULE_MAX_WIDTH / count; |
| 2963 | int err, i; | 2950 | int err, i; |
| 2964 | 2951 | ||
| 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 | |||
| 2978 | for (i = 0; i < count; i++) { | 2952 | for (i = 0; i < count; i++) { |
| 2979 | err = mlxsw_sp_port_create(mlxsw_sp, base_port + i, true, | 2953 | err = mlxsw_sp_port_create(mlxsw_sp, base_port + i, true, |
| 2980 | module, width, i * width); | 2954 | module, width, i * width); |
| @@ -2988,15 +2962,6 @@ err_port_create: · 7 unmodified lines | |||
| 2988 | for (i--; i >= 0; i--) | 2962 | for (i--; i >= 0; i--) |
| 2989 | if (mlxsw_sp_port_created(mlxsw_sp, base_port + i)) | 2963 | if (mlxsw_sp_port_created(mlxsw_sp, base_port + i)) |
| 2990 | mlxsw_sp_port_remove(mlxsw_sp, base_port + i); | 2964 | 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); | ||
| 3000 | return err; | 2965 | return err; |
| 3001 | } | 2966 | } |
| 3002 | 2967 | ||
| @@ -3011,17 +2976,6 @@ static void mlxsw_sp_port_unsplit_create(struct mlxsw_sp *mlxsw_sp, · 8 unmodified lines | |||
| 3011 | */ | 2976 | */ |
| 3012 | count = count / 2; | 2977 | count = count / 2; |
| 3013 | 2978 | ||
| 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 | |||
| 3025 | for (i = 0; i < count; i++) { | 2979 | for (i = 0; i < count; i++) { |
| 3026 | local_port = base_port + i * 2; | 2980 | local_port = base_port + i * 2; |
| 3027 | module = mlxsw_sp->port_to_module[local_port]; | 2981 | module = mlxsw_sp->port_to_module[local_port]; |
| @@ -591,7 +591,7 @@ static int mlxsw_sp_lpm_tree_put(struct mlxsw_sp *mlxsw_sp, · 590 unmodified lines | |||
| 591 | return 0; | 591 | return 0; |
| 592 | } | 592 | } |
| 593 | 593 | ||
| 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 */ |
| 595 | 595 | ||
| 596 | static int mlxsw_sp_lpm_init(struct mlxsw_sp *mlxsw_sp) | 596 | static int mlxsw_sp_lpm_init(struct mlxsw_sp *mlxsw_sp) |
| 597 | { | 597 | { |