@@ -1379,6 +1379,80 @@ static int bnxt_set_eeprom(struct net_device *dev,
1379
1379
eeprom -> len );
1380
1380
}
1381
1381
1382
+ static int bnxt_set_eee (struct net_device * dev , struct ethtool_eee * edata )
1383
+ {
1384
+ struct bnxt * bp = netdev_priv (dev );
1385
+ struct ethtool_eee * eee = & bp -> eee ;
1386
+ struct bnxt_link_info * link_info = & bp -> link_info ;
1387
+ u32 advertising =
1388
+ _bnxt_fw_to_ethtool_adv_spds (link_info -> advertising , 0 );
1389
+ int rc = 0 ;
1390
+
1391
+ if (BNXT_VF (bp ))
1392
+ return 0 ;
1393
+
1394
+ if (!(bp -> flags & BNXT_FLAG_EEE_CAP ))
1395
+ return - EOPNOTSUPP ;
1396
+
1397
+ if (!edata -> eee_enabled )
1398
+ goto eee_ok ;
1399
+
1400
+ if (!(link_info -> autoneg & BNXT_AUTONEG_SPEED )) {
1401
+ netdev_warn (dev , "EEE requires autoneg\n" );
1402
+ return - EINVAL ;
1403
+ }
1404
+ if (edata -> tx_lpi_enabled ) {
1405
+ if (bp -> lpi_tmr_hi && (edata -> tx_lpi_timer > bp -> lpi_tmr_hi ||
1406
+ edata -> tx_lpi_timer < bp -> lpi_tmr_lo )) {
1407
+ netdev_warn (dev , "Valid LPI timer range is %d and %d microsecs\n" ,
1408
+ bp -> lpi_tmr_lo , bp -> lpi_tmr_hi );
1409
+ return - EINVAL ;
1410
+ } else if (!bp -> lpi_tmr_hi ) {
1411
+ edata -> tx_lpi_timer = eee -> tx_lpi_timer ;
1412
+ }
1413
+ }
1414
+ if (!edata -> advertised ) {
1415
+ edata -> advertised = advertising & eee -> supported ;
1416
+ } else if (edata -> advertised & ~advertising ) {
1417
+ netdev_warn (dev , "EEE advertised %x must be a subset of autoneg advertised speeds %x\n" ,
1418
+ edata -> advertised , advertising );
1419
+ return - EINVAL ;
1420
+ }
1421
+
1422
+ eee -> advertised = edata -> advertised ;
1423
+ eee -> tx_lpi_enabled = edata -> tx_lpi_enabled ;
1424
+ eee -> tx_lpi_timer = edata -> tx_lpi_timer ;
1425
+ eee_ok :
1426
+ eee -> eee_enabled = edata -> eee_enabled ;
1427
+
1428
+ if (netif_running (dev ))
1429
+ rc = bnxt_hwrm_set_link_setting (bp , false, true);
1430
+
1431
+ return rc ;
1432
+ }
1433
+
1434
+ static int bnxt_get_eee (struct net_device * dev , struct ethtool_eee * edata )
1435
+ {
1436
+ struct bnxt * bp = netdev_priv (dev );
1437
+
1438
+ if (!(bp -> flags & BNXT_FLAG_EEE_CAP ))
1439
+ return - EOPNOTSUPP ;
1440
+
1441
+ * edata = bp -> eee ;
1442
+ if (!bp -> eee .eee_enabled ) {
1443
+ /* Preserve tx_lpi_timer so that the last value will be used
1444
+ * by default when it is re-enabled.
1445
+ */
1446
+ edata -> advertised = 0 ;
1447
+ edata -> tx_lpi_enabled = 0 ;
1448
+ }
1449
+
1450
+ if (!bp -> eee .eee_active )
1451
+ edata -> lp_advertised = 0 ;
1452
+
1453
+ return 0 ;
1454
+ }
1455
+
1382
1456
const struct ethtool_ops bnxt_ethtool_ops = {
1383
1457
.get_settings = bnxt_get_settings ,
1384
1458
.set_settings = bnxt_set_settings ,
@@ -1407,4 +1481,6 @@ const struct ethtool_ops bnxt_ethtool_ops = {
1407
1481
.get_eeprom = bnxt_get_eeprom ,
1408
1482
.set_eeprom = bnxt_set_eeprom ,
1409
1483
.get_link = bnxt_get_link ,
1484
+ .get_eee = bnxt_get_eee ,
1485
+ .set_eee = bnxt_set_eee ,
1410
1486
};
0 commit comments