@@ -18,6 +18,11 @@ struct hns3_sfp_type {
18
18
u8 ext_type ;
19
19
};
20
20
21
+ struct hns3_pflag_desc {
22
+ char name [ETH_GSTRING_LEN ];
23
+ void (* handler )(struct net_device * netdev , bool enable );
24
+ };
25
+
21
26
/* tqp related stats */
22
27
#define HNS3_TQP_STAT (_string , _member ) { \
23
28
.stats_string = _string, \
@@ -60,6 +65,8 @@ static const struct hns3_stats hns3_rxq_stats[] = {
60
65
HNS3_TQP_STAT ("non_reuse_pg" , non_reuse_pg ),
61
66
};
62
67
68
+ #define HNS3_PRIV_FLAGS_LEN ARRAY_SIZE(hns3_priv_flags)
69
+
63
70
#define HNS3_RXQ_STATS_COUNT ARRAY_SIZE(hns3_rxq_stats)
64
71
65
72
#define HNS3_TQP_STATS_COUNT (HNS3_TXQ_STATS_COUNT + HNS3_RXQ_STATS_COUNT)
@@ -395,6 +402,23 @@ static void hns3_self_test(struct net_device *ndev,
395
402
netif_dbg (h , drv , ndev , "self test end\n" );
396
403
}
397
404
405
+ static void hns3_update_limit_promisc_mode (struct net_device * netdev ,
406
+ bool enable )
407
+ {
408
+ struct hnae3_handle * handle = hns3_get_handle (netdev );
409
+
410
+ if (enable )
411
+ set_bit (HNAE3_PFLAG_LIMIT_PROMISC , & handle -> priv_flags );
412
+ else
413
+ clear_bit (HNAE3_PFLAG_LIMIT_PROMISC , & handle -> priv_flags );
414
+
415
+ hns3_request_update_promisc_mode (handle );
416
+ }
417
+
418
+ static const struct hns3_pflag_desc hns3_priv_flags [HNAE3_PFLAG_MAX ] = {
419
+ { "limit_promisc" , hns3_update_limit_promisc_mode }
420
+ };
421
+
398
422
static int hns3_get_sset_count (struct net_device * netdev , int stringset )
399
423
{
400
424
struct hnae3_handle * h = hns3_get_handle (netdev );
@@ -411,6 +435,9 @@ static int hns3_get_sset_count(struct net_device *netdev, int stringset)
411
435
case ETH_SS_TEST :
412
436
return ops -> get_sset_count (h , stringset );
413
437
438
+ case ETH_SS_PRIV_FLAGS :
439
+ return HNAE3_PFLAG_MAX ;
440
+
414
441
default :
415
442
return - EOPNOTSUPP ;
416
443
}
@@ -464,6 +491,7 @@ static void hns3_get_strings(struct net_device *netdev, u32 stringset, u8 *data)
464
491
struct hnae3_handle * h = hns3_get_handle (netdev );
465
492
const struct hnae3_ae_ops * ops = h -> ae_algo -> ops ;
466
493
char * buff = (char * )data ;
494
+ int i ;
467
495
468
496
if (!ops -> get_strings )
469
497
return ;
@@ -476,6 +504,13 @@ static void hns3_get_strings(struct net_device *netdev, u32 stringset, u8 *data)
476
504
case ETH_SS_TEST :
477
505
ops -> get_strings (h , stringset , data );
478
506
break ;
507
+ case ETH_SS_PRIV_FLAGS :
508
+ for (i = 0 ; i < HNS3_PRIV_FLAGS_LEN ; i ++ ) {
509
+ snprintf (buff , ETH_GSTRING_LEN , "%s" ,
510
+ hns3_priv_flags [i ].name );
511
+ buff += ETH_GSTRING_LEN ;
512
+ }
513
+ break ;
479
514
default :
480
515
break ;
481
516
}
@@ -1517,6 +1552,53 @@ static int hns3_get_module_eeprom(struct net_device *netdev,
1517
1552
return ops -> get_module_eeprom (handle , ee -> offset , ee -> len , data );
1518
1553
}
1519
1554
1555
+ static u32 hns3_get_priv_flags (struct net_device * netdev )
1556
+ {
1557
+ struct hnae3_handle * handle = hns3_get_handle (netdev );
1558
+
1559
+ return handle -> priv_flags ;
1560
+ }
1561
+
1562
+ static int hns3_check_priv_flags (struct hnae3_handle * h , u32 changed )
1563
+ {
1564
+ u32 i ;
1565
+
1566
+ for (i = 0 ; i < HNAE3_PFLAG_MAX ; i ++ )
1567
+ if ((changed & BIT (i )) && !test_bit (i , & h -> supported_pflags )) {
1568
+ netdev_err (h -> netdev , "%s is unsupported\n" ,
1569
+ hns3_priv_flags [i ].name );
1570
+ return - EOPNOTSUPP ;
1571
+ }
1572
+
1573
+ return 0 ;
1574
+ }
1575
+
1576
+ static int hns3_set_priv_flags (struct net_device * netdev , u32 pflags )
1577
+ {
1578
+ struct hnae3_handle * handle = hns3_get_handle (netdev );
1579
+ u32 changed = pflags ^ handle -> priv_flags ;
1580
+ int ret ;
1581
+ u32 i ;
1582
+
1583
+ ret = hns3_check_priv_flags (handle , changed );
1584
+ if (ret )
1585
+ return ret ;
1586
+
1587
+ for (i = 0 ; i < HNAE3_PFLAG_MAX ; i ++ ) {
1588
+ if (changed & BIT (i )) {
1589
+ bool enable = !(handle -> priv_flags & BIT (i ));
1590
+
1591
+ if (enable )
1592
+ handle -> priv_flags |= BIT (i );
1593
+ else
1594
+ handle -> priv_flags &= ~BIT (i );
1595
+ hns3_priv_flags [i ].handler (netdev , enable );
1596
+ }
1597
+ }
1598
+
1599
+ return 0 ;
1600
+ }
1601
+
1520
1602
#define HNS3_ETHTOOL_COALESCE (ETHTOOL_COALESCE_USECS | \
1521
1603
ETHTOOL_COALESCE_USE_ADAPTIVE | \
1522
1604
ETHTOOL_COALESCE_RX_USECS_HIGH | \
@@ -1547,6 +1629,8 @@ static const struct ethtool_ops hns3vf_ethtool_ops = {
1547
1629
.get_link = hns3_get_link ,
1548
1630
.get_msglevel = hns3_get_msglevel ,
1549
1631
.set_msglevel = hns3_set_msglevel ,
1632
+ .get_priv_flags = hns3_get_priv_flags ,
1633
+ .set_priv_flags = hns3_set_priv_flags ,
1550
1634
};
1551
1635
1552
1636
static const struct ethtool_ops hns3_ethtool_ops = {
@@ -1583,6 +1667,8 @@ static const struct ethtool_ops hns3_ethtool_ops = {
1583
1667
.set_fecparam = hns3_set_fecparam ,
1584
1668
.get_module_info = hns3_get_module_info ,
1585
1669
.get_module_eeprom = hns3_get_module_eeprom ,
1670
+ .get_priv_flags = hns3_get_priv_flags ,
1671
+ .set_priv_flags = hns3_set_priv_flags ,
1586
1672
};
1587
1673
1588
1674
void hns3_ethtool_set_ops (struct net_device * netdev )
0 commit comments