@@ -887,6 +887,26 @@ static void netdev_features_init(struct net_device *netdev)
887887 netdev -> features = netdev -> hw_features | NETIF_F_HW_VLAN_CTAG_FILTER ;
888888}
889889
890+ static void hinic_refresh_nic_cfg (struct hinic_dev * nic_dev )
891+ {
892+ struct hinic_nic_cfg * nic_cfg = & nic_dev -> hwdev -> func_to_io .nic_cfg ;
893+ struct hinic_pause_config pause_info = {0 };
894+ struct hinic_port_cap port_cap = {0 };
895+
896+ if (hinic_port_get_cap (nic_dev , & port_cap ))
897+ return ;
898+
899+ mutex_lock (& nic_cfg -> cfg_mutex );
900+ if (nic_cfg -> pause_set || !port_cap .autoneg_state ) {
901+ nic_cfg -> auto_neg = port_cap .autoneg_state ;
902+ pause_info .auto_neg = nic_cfg -> auto_neg ;
903+ pause_info .rx_pause = nic_cfg -> rx_pause ;
904+ pause_info .tx_pause = nic_cfg -> tx_pause ;
905+ hinic_set_hw_pause_info (nic_dev -> hwdev , & pause_info );
906+ }
907+ mutex_unlock (& nic_cfg -> cfg_mutex );
908+ }
909+
890910/**
891911 * link_status_event_handler - link event handler
892912 * @handle: nic device for the handler
@@ -918,6 +938,9 @@ static void link_status_event_handler(void *handle, void *buf_in, u16 in_size,
918938
919939 up (& nic_dev -> mgmt_lock );
920940
941+ if (!HINIC_IS_VF (nic_dev -> hwdev -> hwif ))
942+ hinic_refresh_nic_cfg (nic_dev );
943+
921944 netif_info (nic_dev , drv , nic_dev -> netdev , "HINIC_Link is UP\n" );
922945 } else {
923946 down (& nic_dev -> mgmt_lock );
@@ -948,28 +971,54 @@ static int set_features(struct hinic_dev *nic_dev,
948971{
949972 netdev_features_t changed = force_change ? ~0 : pre_features ^ features ;
950973 u32 csum_en = HINIC_RX_CSUM_OFFLOAD_EN ;
974+ netdev_features_t failed_features = 0 ;
975+ int ret = 0 ;
951976 int err = 0 ;
952977
953- if (changed & NETIF_F_TSO )
954- err = hinic_port_set_tso (nic_dev , (features & NETIF_F_TSO ) ?
978+ if (changed & NETIF_F_TSO ) {
979+ ret = hinic_port_set_tso (nic_dev , (features & NETIF_F_TSO ) ?
955980 HINIC_TSO_ENABLE : HINIC_TSO_DISABLE );
981+ if (ret ) {
982+ err = ret ;
983+ failed_features |= NETIF_F_TSO ;
984+ }
985+ }
956986
957- if (changed & NETIF_F_RXCSUM )
958- err = hinic_set_rx_csum_offload (nic_dev , csum_en );
987+ if (changed & NETIF_F_RXCSUM ) {
988+ ret = hinic_set_rx_csum_offload (nic_dev , csum_en );
989+ if (ret ) {
990+ err = ret ;
991+ failed_features |= NETIF_F_RXCSUM ;
992+ }
993+ }
959994
960995 if (changed & NETIF_F_LRO ) {
961- err = hinic_set_rx_lro_state (nic_dev ,
996+ ret = hinic_set_rx_lro_state (nic_dev ,
962997 !!(features & NETIF_F_LRO ),
963998 HINIC_LRO_RX_TIMER_DEFAULT ,
964999 HINIC_LRO_MAX_WQE_NUM_DEFAULT );
1000+ if (ret ) {
1001+ err = ret ;
1002+ failed_features |= NETIF_F_LRO ;
1003+ }
9651004 }
9661005
967- if (changed & NETIF_F_HW_VLAN_CTAG_RX )
968- err = hinic_set_rx_vlan_offload (nic_dev ,
1006+ if (changed & NETIF_F_HW_VLAN_CTAG_RX ) {
1007+ ret = hinic_set_rx_vlan_offload (nic_dev ,
9691008 !!(features &
9701009 NETIF_F_HW_VLAN_CTAG_RX ));
1010+ if (ret ) {
1011+ err = ret ;
1012+ failed_features |= NETIF_F_HW_VLAN_CTAG_RX ;
1013+ }
1014+ }
9711015
972- return err ;
1016+ if (err ) {
1017+ nic_dev -> netdev -> features = features ^ failed_features ;
1018+ return - EIO ;
1019+ }
1020+
1021+ return 0 ;
9731022}
9741023
9751024/**
@@ -1008,8 +1057,6 @@ static int nic_dev_init(struct pci_dev *pdev)
10081057 goto err_alloc_etherdev ;
10091058 }
10101059
1011- hinic_set_ethtool_ops (netdev );
1012-
10131060 if (!HINIC_IS_VF (hwdev -> hwif ))
10141061 netdev -> netdev_ops = & hinic_netdev_ops ;
10151062 else
@@ -1032,6 +1079,8 @@ static int nic_dev_init(struct pci_dev *pdev)
10321079 nic_dev -> sriov_info .pdev = pdev ;
10331080 nic_dev -> max_qps = num_qps ;
10341081
1082+ hinic_set_ethtool_ops (netdev );
1083+
10351084 sema_init (& nic_dev -> mgmt_lock , 1 );
10361085
10371086 tx_stats = & nic_dev -> tx_stats ;
@@ -1100,6 +1149,11 @@ static int nic_dev_init(struct pci_dev *pdev)
11001149 if (err )
11011150 goto err_set_features ;
11021151
1152+ /* enable pause and disable pfc by default */
1153+ err = hinic_dcb_set_pfc (nic_dev -> hwdev , 0 , 0 );
1154+ if (err )
1155+ goto err_set_pfc ;
1156+
11031157 SET_NETDEV_DEV (netdev , & pdev -> dev );
11041158
11051159 err = register_netdev (netdev );
@@ -1111,6 +1165,7 @@ static int nic_dev_init(struct pci_dev *pdev)
11111165 return 0 ;
11121166
11131167err_reg_netdev :
1168+ err_set_pfc :
11141169err_set_features :
11151170 hinic_hwdev_cb_unregister (nic_dev -> hwdev ,
11161171 HINIC_MGMT_MSG_CMD_LINK_STATUS );
0 commit comments