net: hns: add support of pause frame ctrl for HNS V2
[deliverable/linux.git] / drivers / net / ethernet / hisilicon / hns / hns_dsaf_mac.c
index a38084a22bf28a527b051cc0351624aa50a28086..10c367d209556bbe7a3c602acdd6338c9b5e6e63 100644 (file)
@@ -439,9 +439,8 @@ int hns_mac_vm_config_bc_en(struct hns_mac_cb *mac_cb, u32 vmid, bool enable)
 
 void hns_mac_reset(struct hns_mac_cb *mac_cb)
 {
-       struct mac_driver *drv;
-
-       drv = hns_mac_get_drv(mac_cb);
+       struct mac_driver *drv = hns_mac_get_drv(mac_cb);
+       bool is_ver1 = AE_IS_VER1(mac_cb->dsaf_dev->dsaf_ver);
 
        drv->mac_init(drv);
 
@@ -456,7 +455,7 @@ void hns_mac_reset(struct hns_mac_cb *mac_cb)
 
        if (drv->mac_pausefrm_cfg) {
                if (mac_cb->mac_type == HNAE_PORT_DEBUG)
-                       drv->mac_pausefrm_cfg(drv, 0, 0);
+                       drv->mac_pausefrm_cfg(drv, !is_ver1, !is_ver1);
                else /* mac rx must disable, dsaf pfc close instead of it*/
                        drv->mac_pausefrm_cfg(drv, 0, 1);
        }
@@ -561,14 +560,6 @@ void hns_mac_get_pauseparam(struct hns_mac_cb *mac_cb, u32 *rx_en, u32 *tx_en)
                *rx_en = 0;
                *tx_en = 0;
        }
-
-       /* Due to the chip defect, the service mac's rx pause CAN'T be enabled.
-        * We set the rx pause frm always be true (1), because DSAF deals with
-        * the rx pause frm instead of service mac. After all, we still support
-        * rx pause frm.
-        */
-       if (mac_cb->mac_type == HNAE_PORT_SERVICE)
-               *rx_en = 1;
 }
 
 /**
@@ -602,20 +593,13 @@ int hns_mac_set_autoneg(struct hns_mac_cb *mac_cb, u8 enable)
 int hns_mac_set_pauseparam(struct hns_mac_cb *mac_cb, u32 rx_en, u32 tx_en)
 {
        struct mac_driver *mac_ctrl_drv = hns_mac_get_drv(mac_cb);
+       bool is_ver1 = AE_IS_VER1(mac_cb->dsaf_dev->dsaf_ver);
 
-       if (mac_cb->mac_type == HNAE_PORT_SERVICE) {
-               if (!rx_en) {
-                       dev_err(mac_cb->dev, "disable rx_pause is not allowed!");
+       if (mac_cb->mac_type == HNAE_PORT_DEBUG) {
+               if (is_ver1 && (tx_en || rx_en)) {
+                       dev_err(mac_cb->dev, "macv1 cann't enable tx/rx_pause!");
                        return -EINVAL;
                }
-       } else if (mac_cb->mac_type == HNAE_PORT_DEBUG) {
-               if (tx_en || rx_en) {
-                       dev_err(mac_cb->dev, "enable tx_pause or enable rx_pause are not allowed!");
-                       return -EINVAL;
-               }
-       } else {
-               dev_err(mac_cb->dev, "Unsupport this operation!");
-               return -EINVAL;
        }
 
        if (mac_ctrl_drv->mac_pausefrm_cfg)
This page took 0.029791 seconds and 5 git commands to generate.