@@ -187,6 +187,19 @@ static netdev_tx_t octep_vf_start_xmit(struct sk_buff *skb,
187
187
return NETDEV_TX_OK ;
188
188
}
189
189
190
+ int octep_vf_get_link_info (struct octep_vf_device * oct )
191
+ {
192
+ int ret , size ;
193
+
194
+ ret = octep_vf_mbox_bulk_read (oct , OCTEP_PFVF_MBOX_CMD_GET_LINK_INFO ,
195
+ (u8 * )& oct -> link_info , & size );
196
+ if (ret ) {
197
+ dev_err (& oct -> pdev -> dev , "Get VF link info failed via VF Mbox\n" );
198
+ return ret ;
199
+ }
200
+ return 0 ;
201
+ }
202
+
190
203
/**
191
204
* octep_vf_tx_timeout_task - work queue task to Handle Tx queue timeout.
192
205
*
@@ -225,11 +238,84 @@ static void octep_vf_tx_timeout(struct net_device *netdev, unsigned int txqueue)
225
238
queue_work (octep_vf_wq , & oct -> tx_timeout_task );
226
239
}
227
240
241
+ static int octep_vf_set_mac (struct net_device * netdev , void * p )
242
+ {
243
+ struct octep_vf_device * oct = netdev_priv (netdev );
244
+ struct sockaddr * addr = (struct sockaddr * )p ;
245
+ int err ;
246
+
247
+ if (!is_valid_ether_addr (addr -> sa_data ))
248
+ return - EADDRNOTAVAIL ;
249
+
250
+ err = octep_vf_mbox_set_mac_addr (oct , addr -> sa_data );
251
+ if (err )
252
+ return err ;
253
+
254
+ memcpy (oct -> mac_addr , addr -> sa_data , ETH_ALEN );
255
+ eth_hw_addr_set (netdev , addr -> sa_data );
256
+
257
+ return 0 ;
258
+ }
259
+
260
+ static int octep_vf_change_mtu (struct net_device * netdev , int new_mtu )
261
+ {
262
+ struct octep_vf_device * oct = netdev_priv (netdev );
263
+ struct octep_vf_iface_link_info * link_info ;
264
+ int err ;
265
+
266
+ link_info = & oct -> link_info ;
267
+ if (link_info -> mtu == new_mtu )
268
+ return 0 ;
269
+
270
+ err = octep_vf_mbox_set_mtu (oct , new_mtu );
271
+ if (!err ) {
272
+ oct -> link_info .mtu = new_mtu ;
273
+ netdev -> mtu = new_mtu ;
274
+ }
275
+ return err ;
276
+ }
277
+
278
+ static int octep_vf_set_features (struct net_device * netdev ,
279
+ netdev_features_t features )
280
+ {
281
+ struct octep_vf_device * oct = netdev_priv (netdev );
282
+ u16 rx_offloads = 0 , tx_offloads = 0 ;
283
+ int err ;
284
+
285
+ /* We only support features received from firmware */
286
+ if ((features & netdev -> hw_features ) != features )
287
+ return - EINVAL ;
288
+
289
+ if (features & NETIF_F_TSO )
290
+ tx_offloads |= OCTEP_VF_TX_OFFLOAD_TSO ;
291
+
292
+ if (features & NETIF_F_TSO6 )
293
+ tx_offloads |= OCTEP_VF_TX_OFFLOAD_TSO ;
294
+
295
+ if (features & NETIF_F_IP_CSUM )
296
+ tx_offloads |= OCTEP_VF_TX_OFFLOAD_CKSUM ;
297
+
298
+ if (features & NETIF_F_IPV6_CSUM )
299
+ tx_offloads |= OCTEP_VF_TX_OFFLOAD_CKSUM ;
300
+
301
+ if (features & NETIF_F_RXCSUM )
302
+ rx_offloads |= OCTEP_VF_RX_OFFLOAD_CKSUM ;
303
+
304
+ err = octep_vf_mbox_set_offloads (oct , tx_offloads , rx_offloads );
305
+ if (!err )
306
+ netdev -> features = features ;
307
+
308
+ return err ;
309
+ }
310
+
228
311
static const struct net_device_ops octep_vf_netdev_ops = {
229
312
.ndo_open = octep_vf_open ,
230
313
.ndo_stop = octep_vf_stop ,
231
314
.ndo_start_xmit = octep_vf_start_xmit ,
232
315
.ndo_tx_timeout = octep_vf_tx_timeout ,
316
+ .ndo_set_mac_address = octep_vf_set_mac ,
317
+ .ndo_change_mtu = octep_vf_change_mtu ,
318
+ .ndo_set_features = octep_vf_set_features ,
233
319
};
234
320
235
321
static const char * octep_vf_devid_to_str (struct octep_vf_device * oct )
@@ -411,11 +497,28 @@ static int octep_vf_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
411
497
goto err_mbox_version ;
412
498
}
413
499
500
+ if (octep_vf_mbox_get_fw_info (octep_vf_dev )) {
501
+ dev_err (& pdev -> dev , "unable to get fw info\n" );
502
+ err = - EINVAL ;
503
+ goto err_mbox_version ;
504
+ }
505
+
414
506
netdev -> hw_features = NETIF_F_SG ;
507
+ if (OCTEP_VF_TX_IP_CSUM (octep_vf_dev -> fw_info .tx_ol_flags ))
508
+ netdev -> hw_features |= (NETIF_F_IP_CSUM | NETIF_F_IPV6_CSUM );
509
+
510
+ if (OCTEP_VF_RX_IP_CSUM (octep_vf_dev -> fw_info .rx_ol_flags ))
511
+ netdev -> hw_features |= NETIF_F_RXCSUM ;
512
+
415
513
netdev -> min_mtu = OCTEP_VF_MIN_MTU ;
416
514
netdev -> max_mtu = OCTEP_VF_MAX_MTU ;
417
515
netdev -> mtu = OCTEP_VF_DEFAULT_MTU ;
418
516
517
+ if (OCTEP_VF_TX_TSO (octep_vf_dev -> fw_info .tx_ol_flags )) {
518
+ netdev -> hw_features |= NETIF_F_TSO ;
519
+ netif_set_tso_max_size (netdev , netdev -> max_mtu );
520
+ }
521
+
419
522
netdev -> features |= netdev -> hw_features ;
420
523
octep_vf_get_mac_addr (octep_vf_dev , octep_vf_dev -> mac_addr );
421
524
eth_hw_addr_set (netdev , octep_vf_dev -> mac_addr );
0 commit comments