@@ -59,12 +59,13 @@ static void
59
59
ice_repr_get_stats64 (struct net_device * netdev , struct rtnl_link_stats64 * stats )
60
60
{
61
61
struct ice_netdev_priv * np = netdev_priv (netdev );
62
+ struct ice_repr * repr = np -> repr ;
62
63
struct ice_eth_stats * eth_stats ;
63
64
struct ice_vsi * vsi ;
64
65
65
- if (ice_is_vf_disabled ( np -> repr -> vf ))
66
+ if (repr -> ops . ready ( repr ))
66
67
return ;
67
- vsi = np -> repr -> src_vsi ;
68
+ vsi = repr -> src_vsi ;
68
69
69
70
ice_update_vsi_stats (vsi );
70
71
eth_stats = & vsi -> eth_stats ;
@@ -93,7 +94,7 @@ struct ice_repr *ice_netdev_to_repr(const struct net_device *netdev)
93
94
}
94
95
95
96
/**
96
- * ice_repr_open - Enable port representor's network interface
97
+ * ice_repr_vf_open - Enable port representor's network interface
97
98
* @netdev: network interface device structure
98
99
*
99
100
* The open entry point is called when a port representor's network
@@ -102,7 +103,7 @@ struct ice_repr *ice_netdev_to_repr(const struct net_device *netdev)
102
103
*
103
104
* Returns 0 on success
104
105
*/
105
- static int ice_repr_open (struct net_device * netdev )
106
+ static int ice_repr_vf_open (struct net_device * netdev )
106
107
{
107
108
struct ice_repr * repr = ice_netdev_to_repr (netdev );
108
109
struct ice_vf * vf ;
@@ -118,8 +119,16 @@ static int ice_repr_open(struct net_device *netdev)
118
119
return 0 ;
119
120
}
120
121
122
+ static int ice_repr_sf_open (struct net_device * netdev )
123
+ {
124
+ netif_carrier_on (netdev );
125
+ netif_tx_start_all_queues (netdev );
126
+
127
+ return 0 ;
128
+ }
129
+
121
130
/**
122
- * ice_repr_stop - Disable port representor's network interface
131
+ * ice_repr_vf_stop - Disable port representor's network interface
123
132
* @netdev: network interface device structure
124
133
*
125
134
* The stop entry point is called when a port representor's network
@@ -128,7 +137,7 @@ static int ice_repr_open(struct net_device *netdev)
128
137
*
129
138
* Returns 0 on success
130
139
*/
131
- static int ice_repr_stop (struct net_device * netdev )
140
+ static int ice_repr_vf_stop (struct net_device * netdev )
132
141
{
133
142
struct ice_repr * repr = ice_netdev_to_repr (netdev );
134
143
struct ice_vf * vf ;
@@ -144,6 +153,14 @@ static int ice_repr_stop(struct net_device *netdev)
144
153
return 0 ;
145
154
}
146
155
156
+ static int ice_repr_sf_stop (struct net_device * netdev )
157
+ {
158
+ netif_carrier_off (netdev );
159
+ netif_tx_stop_all_queues (netdev );
160
+
161
+ return 0 ;
162
+ }
163
+
147
164
/**
148
165
* ice_repr_sp_stats64 - get slow path stats for port representor
149
166
* @dev: network interface device structure
@@ -245,10 +262,20 @@ ice_repr_setup_tc(struct net_device *netdev, enum tc_setup_type type,
245
262
}
246
263
}
247
264
248
- static const struct net_device_ops ice_repr_netdev_ops = {
265
+ static const struct net_device_ops ice_repr_vf_netdev_ops = {
266
+ .ndo_get_stats64 = ice_repr_get_stats64 ,
267
+ .ndo_open = ice_repr_vf_open ,
268
+ .ndo_stop = ice_repr_vf_stop ,
269
+ .ndo_start_xmit = ice_eswitch_port_start_xmit ,
270
+ .ndo_setup_tc = ice_repr_setup_tc ,
271
+ .ndo_has_offload_stats = ice_repr_ndo_has_offload_stats ,
272
+ .ndo_get_offload_stats = ice_repr_ndo_get_offload_stats ,
273
+ };
274
+
275
+ static const struct net_device_ops ice_repr_sf_netdev_ops = {
249
276
.ndo_get_stats64 = ice_repr_get_stats64 ,
250
- .ndo_open = ice_repr_open ,
251
- .ndo_stop = ice_repr_stop ,
277
+ .ndo_open = ice_repr_sf_open ,
278
+ .ndo_stop = ice_repr_sf_stop ,
252
279
.ndo_start_xmit = ice_eswitch_port_start_xmit ,
253
280
.ndo_setup_tc = ice_repr_setup_tc ,
254
281
.ndo_has_offload_stats = ice_repr_ndo_has_offload_stats ,
@@ -261,18 +288,20 @@ static const struct net_device_ops ice_repr_netdev_ops = {
261
288
*/
262
289
bool ice_is_port_repr_netdev (const struct net_device * netdev )
263
290
{
264
- return netdev && (netdev -> netdev_ops == & ice_repr_netdev_ops );
291
+ return netdev && (netdev -> netdev_ops == & ice_repr_vf_netdev_ops ||
292
+ netdev -> netdev_ops == & ice_repr_sf_netdev_ops );
265
293
}
266
294
267
295
/**
268
296
* ice_repr_reg_netdev - register port representor netdev
269
297
* @netdev: pointer to port representor netdev
298
+ * @ops: new ops for netdev
270
299
*/
271
300
static int
272
- ice_repr_reg_netdev (struct net_device * netdev )
301
+ ice_repr_reg_netdev (struct net_device * netdev , const struct net_device_ops * ops )
273
302
{
274
303
eth_hw_addr_random (netdev );
275
- netdev -> netdev_ops = & ice_repr_netdev_ops ;
304
+ netdev -> netdev_ops = ops ;
276
305
ice_set_ethtool_repr_ops (netdev );
277
306
278
307
netdev -> hw_features |= NETIF_F_HW_TC ;
@@ -386,7 +415,7 @@ static int ice_repr_add_vf(struct ice_repr *repr)
386
415
return err ;
387
416
388
417
SET_NETDEV_DEVLINK_PORT (repr -> netdev , & vf -> devlink_port );
389
- err = ice_repr_reg_netdev (repr -> netdev );
418
+ err = ice_repr_reg_netdev (repr -> netdev , & ice_repr_vf_netdev_ops );
390
419
if (err )
391
420
goto err_netdev ;
392
421
@@ -447,7 +476,7 @@ static int ice_repr_add_sf(struct ice_repr *repr)
447
476
return err ;
448
477
449
478
SET_NETDEV_DEVLINK_PORT (repr -> netdev , & sf -> devlink_port );
450
- err = ice_repr_reg_netdev (repr -> netdev );
479
+ err = ice_repr_reg_netdev (repr -> netdev , & ice_repr_sf_netdev_ops );
451
480
if (err )
452
481
goto err_netdev ;
453
482
0 commit comments