@@ -165,61 +165,6 @@ void mlxsw_sp_flow_counter_free(struct mlxsw_sp *mlxsw_sp,
165
165
counter_index );
166
166
}
167
167
168
- void mlxsw_sp_txhdr_construct (struct sk_buff * skb ,
169
- const struct mlxsw_tx_info * tx_info )
170
- {
171
- char * txhdr = skb_push (skb , MLXSW_TXHDR_LEN );
172
-
173
- memset (txhdr , 0 , MLXSW_TXHDR_LEN );
174
-
175
- mlxsw_tx_hdr_version_set (txhdr , MLXSW_TXHDR_VERSION_1 );
176
- mlxsw_tx_hdr_ctl_set (txhdr , MLXSW_TXHDR_ETH_CTL );
177
- mlxsw_tx_hdr_proto_set (txhdr , MLXSW_TXHDR_PROTO_ETH );
178
- mlxsw_tx_hdr_swid_set (txhdr , 0 );
179
- mlxsw_tx_hdr_control_tclass_set (txhdr , 1 );
180
- mlxsw_tx_hdr_port_mid_set (txhdr , tx_info -> local_port );
181
- mlxsw_tx_hdr_type_set (txhdr , MLXSW_TXHDR_TYPE_CONTROL );
182
- }
183
-
184
- int
185
- mlxsw_sp_txhdr_ptp_data_construct (struct mlxsw_core * mlxsw_core ,
186
- struct mlxsw_sp_port * mlxsw_sp_port ,
187
- struct sk_buff * skb ,
188
- const struct mlxsw_tx_info * tx_info )
189
- {
190
- char * txhdr ;
191
- u16 max_fid ;
192
- int err ;
193
-
194
- if (skb_cow_head (skb , MLXSW_TXHDR_LEN )) {
195
- err = - ENOMEM ;
196
- goto err_skb_cow_head ;
197
- }
198
-
199
- if (!MLXSW_CORE_RES_VALID (mlxsw_core , FID )) {
200
- err = - EIO ;
201
- goto err_res_valid ;
202
- }
203
- max_fid = MLXSW_CORE_RES_GET (mlxsw_core , FID );
204
-
205
- txhdr = skb_push (skb , MLXSW_TXHDR_LEN );
206
- memset (txhdr , 0 , MLXSW_TXHDR_LEN );
207
-
208
- mlxsw_tx_hdr_version_set (txhdr , MLXSW_TXHDR_VERSION_1 );
209
- mlxsw_tx_hdr_proto_set (txhdr , MLXSW_TXHDR_PROTO_ETH );
210
- mlxsw_tx_hdr_rx_is_router_set (txhdr , true);
211
- mlxsw_tx_hdr_fid_valid_set (txhdr , true);
212
- mlxsw_tx_hdr_fid_set (txhdr , max_fid + tx_info -> local_port - 1 );
213
- mlxsw_tx_hdr_type_set (txhdr , MLXSW_TXHDR_TYPE_DATA );
214
- return 0 ;
215
-
216
- err_res_valid :
217
- err_skb_cow_head :
218
- this_cpu_inc (mlxsw_sp_port -> pcpu_stats -> tx_dropped );
219
- dev_kfree_skb_any (skb );
220
- return err ;
221
- }
222
-
223
168
static bool mlxsw_sp_skb_requires_ts (struct sk_buff * skb )
224
169
{
225
170
unsigned int type ;
@@ -242,46 +187,38 @@ static void mlxsw_sp_txhdr_info_data_init(struct mlxsw_core *mlxsw_core,
242
187
txhdr_info -> max_fid = max_fid ;
243
188
}
244
189
245
- static void
190
+ static struct sk_buff *
191
+ mlxsw_sp_vlan_tag_push (struct mlxsw_sp * mlxsw_sp , struct sk_buff * skb )
192
+ {
193
+ /* In some Spectrum ASICs, in order for PTP event packets to have their
194
+ * correction field correctly set on the egress port they must be
195
+ * transmitted as data packets. Such packets ingress the ASIC via the
196
+ * CPU port and must have a VLAN tag, as the CPU port is not configured
197
+ * with a PVID. Push the default VLAN (4095), which is configured as
198
+ * egress untagged on all the ports.
199
+ */
200
+ if (skb_vlan_tagged (skb ))
201
+ return skb ;
202
+
203
+ return vlan_insert_tag_set_proto (skb , htons (ETH_P_8021Q ),
204
+ MLXSW_SP_DEFAULT_VID );
205
+ }
206
+
207
+ static struct sk_buff *
246
208
mlxsw_sp_txhdr_preparations (struct mlxsw_sp * mlxsw_sp , struct sk_buff * skb ,
247
209
struct mlxsw_txhdr_info * txhdr_info )
248
210
{
249
211
if (likely (!mlxsw_sp_skb_requires_ts (skb )))
250
- return ;
212
+ return skb ;
251
213
252
214
if (!mlxsw_sp -> ptp_ops -> tx_as_data )
253
- return ;
215
+ return skb ;
254
216
255
217
/* Special handling for PTP events that require a time stamp and cannot
256
218
* be transmitted as regular control packets.
257
219
*/
258
220
mlxsw_sp_txhdr_info_data_init (mlxsw_sp -> core , skb , txhdr_info );
259
- }
260
-
261
- static int mlxsw_sp_txhdr_handle (struct mlxsw_core * mlxsw_core ,
262
- struct mlxsw_sp_port * mlxsw_sp_port ,
263
- struct sk_buff * skb ,
264
- const struct mlxsw_tx_info * tx_info )
265
- {
266
- struct mlxsw_sp * mlxsw_sp = mlxsw_core_driver_priv (mlxsw_core );
267
-
268
- /* In Spectrum-2 and Spectrum-3, PTP events that require a time stamp
269
- * need special handling and cannot be transmitted as regular control
270
- * packets.
271
- */
272
- if (unlikely (mlxsw_sp_skb_requires_ts (skb )))
273
- return mlxsw_sp -> ptp_ops -> txhdr_construct (mlxsw_core ,
274
- mlxsw_sp_port , skb ,
275
- tx_info );
276
-
277
- if (skb_cow_head (skb , MLXSW_TXHDR_LEN )) {
278
- this_cpu_inc (mlxsw_sp_port -> pcpu_stats -> tx_dropped );
279
- dev_kfree_skb_any (skb );
280
- return - ENOMEM ;
281
- }
282
-
283
- mlxsw_sp_txhdr_construct (skb , tx_info );
284
- return 0 ;
221
+ return mlxsw_sp_vlan_tag_push (mlxsw_sp , skb );
285
222
}
286
223
287
224
enum mlxsw_reg_spms_state mlxsw_sp_stp_spms_state (u8 state )
@@ -697,12 +634,11 @@ static netdev_tx_t mlxsw_sp_port_xmit(struct sk_buff *skb,
697
634
return NETDEV_TX_OK ;
698
635
}
699
636
700
- mlxsw_sp_txhdr_preparations (mlxsw_sp , skb , & txhdr_info );
701
-
702
- err = mlxsw_sp_txhdr_handle (mlxsw_sp -> core , mlxsw_sp_port , skb ,
703
- & txhdr_info .tx_info );
704
- if (err )
637
+ skb = mlxsw_sp_txhdr_preparations (mlxsw_sp , skb , & txhdr_info );
638
+ if (!skb ) {
639
+ this_cpu_inc (mlxsw_sp_port -> pcpu_stats -> tx_dropped );
705
640
return NETDEV_TX_OK ;
641
+ }
706
642
707
643
/* TX header is consumed by HW on the way so we shouldn't count its
708
644
* bytes as being sent.
@@ -2753,7 +2689,6 @@ static const struct mlxsw_sp_ptp_ops mlxsw_sp1_ptp_ops = {
2753
2689
.get_stats_count = mlxsw_sp1_get_stats_count ,
2754
2690
.get_stats_strings = mlxsw_sp1_get_stats_strings ,
2755
2691
.get_stats = mlxsw_sp1_get_stats ,
2756
- .txhdr_construct = mlxsw_sp_ptp_txhdr_construct ,
2757
2692
};
2758
2693
2759
2694
static const struct mlxsw_sp_ptp_ops mlxsw_sp2_ptp_ops = {
@@ -2772,7 +2707,6 @@ static const struct mlxsw_sp_ptp_ops mlxsw_sp2_ptp_ops = {
2772
2707
.get_stats_count = mlxsw_sp2_get_stats_count ,
2773
2708
.get_stats_strings = mlxsw_sp2_get_stats_strings ,
2774
2709
.get_stats = mlxsw_sp2_get_stats ,
2775
- .txhdr_construct = mlxsw_sp2_ptp_txhdr_construct ,
2776
2710
.tx_as_data = true,
2777
2711
};
2778
2712
@@ -2792,7 +2726,6 @@ static const struct mlxsw_sp_ptp_ops mlxsw_sp4_ptp_ops = {
2792
2726
.get_stats_count = mlxsw_sp2_get_stats_count ,
2793
2727
.get_stats_strings = mlxsw_sp2_get_stats_strings ,
2794
2728
.get_stats = mlxsw_sp2_get_stats ,
2795
- .txhdr_construct = mlxsw_sp_ptp_txhdr_construct ,
2796
2729
};
2797
2730
2798
2731
struct mlxsw_sp_sample_trigger_node {
@@ -3954,7 +3887,6 @@ static struct mlxsw_driver mlxsw_sp1_driver = {
3954
3887
.trap_policer_fini = mlxsw_sp_trap_policer_fini ,
3955
3888
.trap_policer_set = mlxsw_sp_trap_policer_set ,
3956
3889
.trap_policer_counter_get = mlxsw_sp_trap_policer_counter_get ,
3957
- .txhdr_construct = mlxsw_sp_txhdr_construct ,
3958
3890
.resources_register = mlxsw_sp1_resources_register ,
3959
3891
.kvd_sizes_get = mlxsw_sp_kvd_sizes_get ,
3960
3892
.ptp_transmitted = mlxsw_sp_ptp_transmitted ,
@@ -3992,7 +3924,6 @@ static struct mlxsw_driver mlxsw_sp2_driver = {
3992
3924
.trap_policer_fini = mlxsw_sp_trap_policer_fini ,
3993
3925
.trap_policer_set = mlxsw_sp_trap_policer_set ,
3994
3926
.trap_policer_counter_get = mlxsw_sp_trap_policer_counter_get ,
3995
- .txhdr_construct = mlxsw_sp_txhdr_construct ,
3996
3927
.resources_register = mlxsw_sp2_resources_register ,
3997
3928
.ptp_transmitted = mlxsw_sp_ptp_transmitted ,
3998
3929
.txhdr_len = MLXSW_TXHDR_LEN ,
@@ -4029,7 +3960,6 @@ static struct mlxsw_driver mlxsw_sp3_driver = {
4029
3960
.trap_policer_fini = mlxsw_sp_trap_policer_fini ,
4030
3961
.trap_policer_set = mlxsw_sp_trap_policer_set ,
4031
3962
.trap_policer_counter_get = mlxsw_sp_trap_policer_counter_get ,
4032
- .txhdr_construct = mlxsw_sp_txhdr_construct ,
4033
3963
.resources_register = mlxsw_sp2_resources_register ,
4034
3964
.ptp_transmitted = mlxsw_sp_ptp_transmitted ,
4035
3965
.txhdr_len = MLXSW_TXHDR_LEN ,
@@ -4064,7 +3994,6 @@ static struct mlxsw_driver mlxsw_sp4_driver = {
4064
3994
.trap_policer_fini = mlxsw_sp_trap_policer_fini ,
4065
3995
.trap_policer_set = mlxsw_sp_trap_policer_set ,
4066
3996
.trap_policer_counter_get = mlxsw_sp_trap_policer_counter_get ,
4067
- .txhdr_construct = mlxsw_sp_txhdr_construct ,
4068
3997
.resources_register = mlxsw_sp2_resources_register ,
4069
3998
.ptp_transmitted = mlxsw_sp_ptp_transmitted ,
4070
3999
.txhdr_len = MLXSW_TXHDR_LEN ,
0 commit comments