@@ -2917,30 +2917,23 @@ static int mlxsw_sp_avail_rif_get(struct mlxsw_sp *mlxsw_sp)
2917
2917
return MLXSW_SP_INVALID_INDEX_RIF ;
2918
2918
}
2919
2919
2920
- static void mlxsw_sp_vport_rif_sp_attr_get (struct mlxsw_sp_port * mlxsw_sp_vport ,
2921
- bool * p_lagged , u16 * p_system_port )
2922
- {
2923
- u8 local_port = mlxsw_sp_vport -> local_port ;
2924
-
2925
- * p_lagged = mlxsw_sp_vport -> lagged ;
2926
- * p_system_port = * p_lagged ? mlxsw_sp_vport -> lag_id : local_port ;
2927
- }
2928
-
2929
- static int mlxsw_sp_vport_rif_sp_op (struct mlxsw_sp_port * mlxsw_sp_vport ,
2930
- u16 vr_id , struct net_device * l3_dev ,
2931
- u16 rif_index , bool create )
2920
+ static int
2921
+ mlxsw_sp_port_vlan_rif_sp_op (struct mlxsw_sp_port_vlan * mlxsw_sp_port_vlan ,
2922
+ u16 vr_id , struct net_device * l3_dev ,
2923
+ u16 rif_index , bool create )
2932
2924
{
2933
- struct mlxsw_sp * mlxsw_sp = mlxsw_sp_vport -> mlxsw_sp ;
2934
- bool lagged = mlxsw_sp_vport -> lagged ;
2925
+ struct mlxsw_sp_port * mlxsw_sp_port = mlxsw_sp_port_vlan -> mlxsw_sp_port ;
2926
+ struct mlxsw_sp * mlxsw_sp = mlxsw_sp_port -> mlxsw_sp ;
2927
+ bool lagged = mlxsw_sp_port -> lagged ;
2935
2928
char ritr_pl [MLXSW_REG_RITR_LEN ];
2936
2929
u16 system_port ;
2937
2930
2931
+ system_port = lagged ? mlxsw_sp_port -> lag_id :
2932
+ mlxsw_sp_port -> local_port ;
2938
2933
mlxsw_reg_ritr_pack (ritr_pl , create , MLXSW_REG_RITR_SP_IF , rif_index ,
2939
2934
vr_id , l3_dev -> mtu , l3_dev -> dev_addr );
2940
-
2941
- mlxsw_sp_vport_rif_sp_attr_get (mlxsw_sp_vport , & lagged , & system_port );
2942
2935
mlxsw_reg_ritr_sp_if_pack (ritr_pl , lagged , system_port ,
2943
- mlxsw_sp_vport_vid_get ( mlxsw_sp_vport ) );
2936
+ mlxsw_sp_port_vlan -> vid );
2944
2937
2945
2938
return mlxsw_reg_write (mlxsw_sp -> core , MLXSW_REG (ritr ), ritr_pl );
2946
2939
}
@@ -3009,10 +3002,11 @@ int mlxsw_sp_rif_dev_ifindex(const struct mlxsw_sp_rif *rif)
3009
3002
}
3010
3003
3011
3004
static struct mlxsw_sp_rif *
3012
- mlxsw_sp_vport_rif_sp_create (struct mlxsw_sp_port * mlxsw_sp_vport ,
3013
- struct net_device * l3_dev )
3005
+ mlxsw_sp_port_vlan_rif_sp_create (struct mlxsw_sp_port_vlan * mlxsw_sp_port_vlan ,
3006
+ struct net_device * l3_dev )
3014
3007
{
3015
- struct mlxsw_sp * mlxsw_sp = mlxsw_sp_vport -> mlxsw_sp ;
3008
+ struct mlxsw_sp_port * mlxsw_sp_port = mlxsw_sp_port_vlan -> mlxsw_sp_port ;
3009
+ struct mlxsw_sp * mlxsw_sp = mlxsw_sp_port -> mlxsw_sp ;
3016
3010
u32 tb_id = l3mdev_fib_table (l3_dev );
3017
3011
struct mlxsw_sp_vr * vr ;
3018
3012
struct mlxsw_sp_fid * f ;
@@ -3028,10 +3022,10 @@ mlxsw_sp_vport_rif_sp_create(struct mlxsw_sp_port *mlxsw_sp_vport,
3028
3022
if (IS_ERR (vr ))
3029
3023
return ERR_CAST (vr );
3030
3024
3031
- err = mlxsw_sp_vport_rif_sp_op ( mlxsw_sp_vport , vr -> id , l3_dev ,
3032
- rif_index , true);
3025
+ err = mlxsw_sp_port_vlan_rif_sp_op ( mlxsw_sp_port_vlan , vr -> id , l3_dev ,
3026
+ rif_index , true);
3033
3027
if (err )
3034
- goto err_vport_rif_sp_op ;
3028
+ goto err_port_vlan_rif_sp_op ;
3035
3029
3036
3030
fid = mlxsw_sp_rif_sp_to_fid (rif_index );
3037
3031
err = mlxsw_sp_rif_fdb_op (mlxsw_sp , l3_dev -> dev_addr , fid , true);
@@ -3055,7 +3049,7 @@ mlxsw_sp_vport_rif_sp_create(struct mlxsw_sp_port *mlxsw_sp_vport,
3055
3049
err = mlxsw_sp_rif_counter_alloc (mlxsw_sp , rif ,
3056
3050
MLXSW_SP_RIF_COUNTER_EGRESS );
3057
3051
if (err )
3058
- netdev_dbg (mlxsw_sp_vport -> dev ,
3052
+ netdev_dbg (mlxsw_sp_port -> dev ,
3059
3053
"Counter alloc Failed err=%d\n" , err );
3060
3054
}
3061
3055
@@ -3070,17 +3064,19 @@ mlxsw_sp_vport_rif_sp_create(struct mlxsw_sp_port *mlxsw_sp_vport,
3070
3064
err_rfid_alloc :
3071
3065
mlxsw_sp_rif_fdb_op (mlxsw_sp , l3_dev -> dev_addr , fid , false);
3072
3066
err_rif_fdb_op :
3073
- mlxsw_sp_vport_rif_sp_op ( mlxsw_sp_vport , vr -> id , l3_dev , rif_index ,
3074
- false);
3075
- err_vport_rif_sp_op :
3067
+ mlxsw_sp_port_vlan_rif_sp_op ( mlxsw_sp_port_vlan , vr -> id , l3_dev ,
3068
+ rif_index , false);
3069
+ err_port_vlan_rif_sp_op :
3076
3070
mlxsw_sp_vr_put (vr );
3077
3071
return ERR_PTR (err );
3078
3072
}
3079
3073
3080
- static void mlxsw_sp_vport_rif_sp_destroy (struct mlxsw_sp_port * mlxsw_sp_vport ,
3081
- struct mlxsw_sp_rif * rif )
3074
+ static void
3075
+ mlxsw_sp_port_vlan_rif_sp_destroy (struct mlxsw_sp_port_vlan * mlxsw_sp_port_vlan ,
3076
+ struct mlxsw_sp_rif * rif )
3082
3077
{
3083
- struct mlxsw_sp * mlxsw_sp = mlxsw_sp_vport -> mlxsw_sp ;
3078
+ struct mlxsw_sp_port * mlxsw_sp_port = mlxsw_sp_port_vlan -> mlxsw_sp_port ;
3079
+ struct mlxsw_sp * mlxsw_sp = mlxsw_sp_port -> mlxsw_sp ;
3084
3080
struct mlxsw_sp_vr * vr = & mlxsw_sp -> router -> vrs [rif -> vr_id ];
3085
3081
struct net_device * l3_dev = rif -> dev ;
3086
3082
struct mlxsw_sp_fid * f = rif -> f ;
@@ -3102,103 +3098,95 @@ static void mlxsw_sp_vport_rif_sp_destroy(struct mlxsw_sp_port *mlxsw_sp_vport,
3102
3098
3103
3099
mlxsw_sp_rif_fdb_op (mlxsw_sp , l3_dev -> dev_addr , fid , false);
3104
3100
3105
- mlxsw_sp_vport_rif_sp_op (mlxsw_sp_vport , vr -> id , l3_dev , rif_index ,
3106
- false);
3101
+ mlxsw_sp_port_vlan_rif_sp_op (mlxsw_sp_port_vlan , vr -> id , l3_dev ,
3102
+ rif_index , false);
3103
+
3107
3104
mlxsw_sp_vr_put (vr );
3108
3105
}
3109
3106
3110
- static int mlxsw_sp_vport_rif_sp_join (struct mlxsw_sp_port * mlxsw_sp_vport ,
3111
- struct net_device * l3_dev )
3107
+ static int
3108
+ mlxsw_sp_port_vlan_rif_sp_join (struct mlxsw_sp_port_vlan * mlxsw_sp_port_vlan ,
3109
+ struct net_device * l3_dev )
3112
3110
{
3113
- struct mlxsw_sp * mlxsw_sp = mlxsw_sp_vport -> mlxsw_sp ;
3114
- u16 vid = mlxsw_sp_vport_vid_get (mlxsw_sp_vport );
3115
- struct mlxsw_sp_port * mlxsw_sp_port ;
3111
+ struct mlxsw_sp_port * mlxsw_sp_port = mlxsw_sp_port_vlan -> mlxsw_sp_port ;
3112
+ u16 vid = mlxsw_sp_port_vlan -> vid ;
3116
3113
struct mlxsw_sp_rif * rif ;
3117
3114
int err ;
3118
3115
3119
- rif = mlxsw_sp_rif_find_by_dev (mlxsw_sp , l3_dev );
3116
+ rif = mlxsw_sp_rif_find_by_dev (mlxsw_sp_port -> mlxsw_sp , l3_dev );
3120
3117
if (!rif ) {
3121
- rif = mlxsw_sp_vport_rif_sp_create (mlxsw_sp_vport , l3_dev );
3118
+ rif = mlxsw_sp_port_vlan_rif_sp_create (mlxsw_sp_port_vlan ,
3119
+ l3_dev );
3122
3120
if (IS_ERR (rif ))
3123
3121
return PTR_ERR (rif );
3124
3122
}
3125
3123
3126
- err = mlxsw_sp_port_vid_learning_set (mlxsw_sp_vport , vid , false);
3124
+ err = mlxsw_sp_port_vid_learning_set (mlxsw_sp_port , vid , false);
3127
3125
if (err )
3128
3126
goto err_port_vid_learning_set ;
3129
3127
3130
- err = mlxsw_sp_port_vid_stp_set (mlxsw_sp_vport , vid ,
3128
+ err = mlxsw_sp_port_vid_stp_set (mlxsw_sp_port , vid ,
3131
3129
BR_STATE_FORWARDING );
3132
3130
if (err )
3133
3131
goto err_port_vid_stp_set ;
3134
3132
3135
- mlxsw_sp_port = mlxsw_sp_vport_port (mlxsw_sp_vport );
3136
3133
if (mlxsw_sp_port -> nr_port_vid_map ++ == 0 ) {
3137
3134
err = mlxsw_sp_port_vp_mode_trans (mlxsw_sp_port );
3138
3135
if (err )
3139
3136
goto err_port_vp_mode_trans ;
3140
3137
}
3141
3138
3142
- mlxsw_sp_vport_fid_set ( mlxsw_sp_vport , rif -> f ) ;
3139
+ mlxsw_sp_port_vlan -> fid = rif -> f ;
3143
3140
rif -> f -> ref_count ++ ;
3144
3141
3145
- netdev_dbg (mlxsw_sp_vport -> dev , "Joined FID=%d\n" , rif -> f -> fid );
3146
-
3147
3142
return 0 ;
3148
3143
3149
3144
err_port_vp_mode_trans :
3150
3145
mlxsw_sp_port -> nr_port_vid_map -- ;
3151
- mlxsw_sp_port_vid_stp_set (mlxsw_sp_vport , vid , BR_STATE_BLOCKING );
3146
+ mlxsw_sp_port_vid_stp_set (mlxsw_sp_port , vid , BR_STATE_BLOCKING );
3152
3147
err_port_vid_stp_set :
3153
- mlxsw_sp_port_vid_learning_set (mlxsw_sp_vport , vid , true);
3148
+ mlxsw_sp_port_vid_learning_set (mlxsw_sp_port , vid , true);
3154
3149
err_port_vid_learning_set :
3155
3150
if (rif -> f -> ref_count == 0 )
3156
- mlxsw_sp_vport_rif_sp_destroy ( mlxsw_sp_vport , rif );
3151
+ mlxsw_sp_port_vlan_rif_sp_destroy ( mlxsw_sp_port_vlan , rif );
3157
3152
return err ;
3158
3153
}
3159
3154
3160
3155
static void
3161
3156
mlxsw_sp_port_vlan_rif_sp_leave (struct mlxsw_sp_port_vlan * mlxsw_sp_port_vlan )
3162
3157
{
3163
3158
struct mlxsw_sp_port * mlxsw_sp_port = mlxsw_sp_port_vlan -> mlxsw_sp_port ;
3164
- struct mlxsw_sp_port * mlxsw_sp_vport ;
3159
+ struct mlxsw_sp_fid * fid = mlxsw_sp_port_vlan -> fid ;
3165
3160
u16 vid = mlxsw_sp_port_vlan -> vid ;
3166
- struct mlxsw_sp_fid * f ;
3167
3161
3168
- mlxsw_sp_vport = mlxsw_sp_port_vport_find (mlxsw_sp_port , vid );
3169
- f = mlxsw_sp_vport_fid_get (mlxsw_sp_vport );
3170
-
3171
- netdev_dbg (mlxsw_sp_vport -> dev , "Left FID=%d\n" , f -> fid );
3172
-
3173
- f -> ref_count -- ;
3174
- mlxsw_sp_vport_fid_set (mlxsw_sp_vport , NULL );
3162
+ fid -> ref_count -- ;
3163
+ mlxsw_sp_port_vlan -> fid = NULL ;
3175
3164
3176
3165
if (mlxsw_sp_port -> nr_port_vid_map == 1 )
3177
3166
mlxsw_sp_port_vlan_mode_trans (mlxsw_sp_port );
3178
3167
mlxsw_sp_port -> nr_port_vid_map -- ;
3179
- mlxsw_sp_port_vid_stp_set (mlxsw_sp_vport , vid , BR_STATE_BLOCKING );
3180
- mlxsw_sp_port_vid_learning_set (mlxsw_sp_vport , vid , true);
3168
+ mlxsw_sp_port_vid_stp_set (mlxsw_sp_port , vid , BR_STATE_BLOCKING );
3169
+ mlxsw_sp_port_vid_learning_set (mlxsw_sp_port , vid , true);
3181
3170
3182
- if (f -> ref_count == 0 )
3183
- mlxsw_sp_vport_rif_sp_destroy ( mlxsw_sp_vport , f -> rif );
3171
+ if (fid -> ref_count == 0 )
3172
+ mlxsw_sp_port_vlan_rif_sp_destroy ( mlxsw_sp_port_vlan , fid -> rif );
3184
3173
}
3185
3174
3186
- static int mlxsw_sp_inetaddr_vport_event (struct net_device * l3_dev ,
3187
- struct net_device * port_dev ,
3188
- unsigned long event , u16 vid )
3175
+ static int mlxsw_sp_inetaddr_port_vlan_event (struct net_device * l3_dev ,
3176
+ struct net_device * port_dev ,
3177
+ unsigned long event , u16 vid )
3189
3178
{
3190
3179
struct mlxsw_sp_port * mlxsw_sp_port = netdev_priv (port_dev );
3191
3180
struct mlxsw_sp_port_vlan * mlxsw_sp_port_vlan ;
3192
- struct mlxsw_sp_port * mlxsw_sp_vport ;
3193
3181
3194
- mlxsw_sp_vport = mlxsw_sp_port_vport_find (mlxsw_sp_port , vid );
3195
- if (WARN_ON (!mlxsw_sp_vport ))
3196
- return - EINVAL ;
3197
3182
mlxsw_sp_port_vlan = mlxsw_sp_port_vlan_find_by_vid (mlxsw_sp_port , vid );
3183
+ if (WARN_ON (!mlxsw_sp_port_vlan ))
3184
+ return - EINVAL ;
3198
3185
3199
3186
switch (event ) {
3200
3187
case NETDEV_UP :
3201
- return mlxsw_sp_vport_rif_sp_join (mlxsw_sp_vport , l3_dev );
3188
+ return mlxsw_sp_port_vlan_rif_sp_join (mlxsw_sp_port_vlan ,
3189
+ l3_dev );
3202
3190
case NETDEV_DOWN :
3203
3191
mlxsw_sp_port_vlan_rif_sp_leave (mlxsw_sp_port_vlan );
3204
3192
break ;
@@ -3215,7 +3203,7 @@ static int mlxsw_sp_inetaddr_port_event(struct net_device *port_dev,
3215
3203
netif_is_ovs_port (port_dev ))
3216
3204
return 0 ;
3217
3205
3218
- return mlxsw_sp_inetaddr_vport_event (port_dev , port_dev , event , 1 );
3206
+ return mlxsw_sp_inetaddr_port_vlan_event (port_dev , port_dev , event , 1 );
3219
3207
}
3220
3208
3221
3209
static int __mlxsw_sp_inetaddr_lag_event (struct net_device * l3_dev ,
@@ -3228,8 +3216,9 @@ static int __mlxsw_sp_inetaddr_lag_event(struct net_device *l3_dev,
3228
3216
3229
3217
netdev_for_each_lower_dev (lag_dev , port_dev , iter ) {
3230
3218
if (mlxsw_sp_port_dev_check (port_dev )) {
3231
- err = mlxsw_sp_inetaddr_vport_event (l3_dev , port_dev ,
3232
- event , vid );
3219
+ err = mlxsw_sp_inetaddr_port_vlan_event (l3_dev ,
3220
+ port_dev ,
3221
+ event , vid );
3233
3222
if (err )
3234
3223
return err ;
3235
3224
}
@@ -3444,8 +3433,8 @@ static int mlxsw_sp_inetaddr_vlan_event(struct net_device *vlan_dev,
3444
3433
u16 vid = vlan_dev_vlan_id (vlan_dev );
3445
3434
3446
3435
if (mlxsw_sp_port_dev_check (real_dev ))
3447
- return mlxsw_sp_inetaddr_vport_event (vlan_dev , real_dev , event ,
3448
- vid );
3436
+ return mlxsw_sp_inetaddr_port_vlan_event (vlan_dev , real_dev ,
3437
+ event , vid );
3449
3438
else if (netif_is_lag_master (real_dev ))
3450
3439
return __mlxsw_sp_inetaddr_lag_event (vlan_dev , real_dev , event ,
3451
3440
vid );
0 commit comments