提交 25456e5c 编写于 作者: H Huang, Xiong 提交者: David S. Miller

atl1c: refine start/enable code for MAC module

merge TXQ/RXQ/MAC start/enable code to one function as they
are started/enabled at the same time, just like stop/disable them
in the function of atl1c_stop_mac.
Signed-off-by: Nxiong <xiong@qca.qualcomm.com>
Tested-by: NLiu David <dwliu@qca.qualcomm.com>
Signed-off-by: NDavid S. Miller <davem@davemloft.net>
上级 319d013a
...@@ -53,11 +53,9 @@ MODULE_LICENSE("GPL"); ...@@ -53,11 +53,9 @@ MODULE_LICENSE("GPL");
MODULE_VERSION(ATL1C_DRV_VERSION); MODULE_VERSION(ATL1C_DRV_VERSION);
static int atl1c_stop_mac(struct atl1c_hw *hw); static int atl1c_stop_mac(struct atl1c_hw *hw);
static void atl1c_enable_rx_ctrl(struct atl1c_hw *hw);
static void atl1c_enable_tx_ctrl(struct atl1c_hw *hw);
static void atl1c_disable_l0s_l1(struct atl1c_hw *hw); static void atl1c_disable_l0s_l1(struct atl1c_hw *hw);
static void atl1c_set_aspm(struct atl1c_hw *hw, u16 link_speed); static void atl1c_set_aspm(struct atl1c_hw *hw, u16 link_speed);
static void atl1c_setup_mac_ctrl(struct atl1c_adapter *adapter); static void atl1c_start_mac(struct atl1c_adapter *adapter);
static void atl1c_clean_rx_irq(struct atl1c_adapter *adapter, static void atl1c_clean_rx_irq(struct atl1c_adapter *adapter,
int *work_done, int work_to_do); int *work_done, int work_to_do);
static int atl1c_up(struct atl1c_adapter *adapter); static int atl1c_up(struct atl1c_adapter *adapter);
...@@ -276,9 +274,7 @@ static void atl1c_check_link_status(struct atl1c_adapter *adapter) ...@@ -276,9 +274,7 @@ static void atl1c_check_link_status(struct atl1c_adapter *adapter)
adapter->link_speed = speed; adapter->link_speed = speed;
adapter->link_duplex = duplex; adapter->link_duplex = duplex;
atl1c_set_aspm(hw, speed); atl1c_set_aspm(hw, speed);
atl1c_enable_tx_ctrl(hw); atl1c_start_mac(adapter);
atl1c_enable_rx_ctrl(hw);
atl1c_setup_mac_ctrl(adapter);
if (netif_msg_link(adapter)) if (netif_msg_link(adapter))
dev_info(&pdev->dev, dev_info(&pdev->dev,
"%s: %s NIC Link is Up<%d Mbps %s>\n", "%s: %s NIC Link is Up<%d Mbps %s>\n",
...@@ -1132,22 +1128,36 @@ static int atl1c_stop_mac(struct atl1c_hw *hw) ...@@ -1132,22 +1128,36 @@ static int atl1c_stop_mac(struct atl1c_hw *hw)
IDLE_STATUS_TXMAC_BUSY | IDLE_STATUS_RXMAC_BUSY); IDLE_STATUS_TXMAC_BUSY | IDLE_STATUS_RXMAC_BUSY);
} }
static void atl1c_enable_rx_ctrl(struct atl1c_hw *hw) static void atl1c_start_mac(struct atl1c_adapter *adapter)
{ {
u32 data; struct atl1c_hw *hw = &adapter->hw;
u32 mac, txq, rxq;
AT_READ_REG(hw, REG_RXQ_CTRL, &data);
data |= RXQ_CTRL_EN; hw->mac_duplex = adapter->link_duplex == FULL_DUPLEX ? true : false;
AT_WRITE_REG(hw, REG_RXQ_CTRL, data); hw->mac_speed = adapter->link_speed == SPEED_1000 ?
} atl1c_mac_speed_1000 : atl1c_mac_speed_10_100;
static void atl1c_enable_tx_ctrl(struct atl1c_hw *hw) AT_READ_REG(hw, REG_TXQ_CTRL, &txq);
{ AT_READ_REG(hw, REG_RXQ_CTRL, &rxq);
u32 data; AT_READ_REG(hw, REG_MAC_CTRL, &mac);
txq |= TXQ_CTRL_EN;
rxq |= RXQ_CTRL_EN;
mac |= MAC_CTRL_TX_EN | MAC_CTRL_TX_FLOW |
MAC_CTRL_RX_EN | MAC_CTRL_RX_FLOW |
MAC_CTRL_ADD_CRC | MAC_CTRL_PAD |
MAC_CTRL_BC_EN | MAC_CTRL_SINGLE_PAUSE_EN |
MAC_CTRL_HASH_ALG_CRC32;
if (hw->mac_duplex)
mac |= MAC_CTRL_DUPLX;
else
mac &= ~MAC_CTRL_DUPLX;
mac = FIELD_SETX(mac, MAC_CTRL_SPEED, hw->mac_speed);
mac = FIELD_SETX(mac, MAC_CTRL_PRMLEN, hw->preamble_len);
AT_READ_REG(hw, REG_TXQ_CTRL, &data); AT_WRITE_REG(hw, REG_TXQ_CTRL, txq);
data |= TXQ_CTRL_EN; AT_WRITE_REG(hw, REG_RXQ_CTRL, rxq);
AT_WRITE_REG(hw, REG_TXQ_CTRL, data); AT_WRITE_REG(hw, REG_MAC_CTRL, mac);
} }
/* /*
...@@ -1296,49 +1306,6 @@ static void atl1c_set_aspm(struct atl1c_hw *hw, u16 link_speed) ...@@ -1296,49 +1306,6 @@ static void atl1c_set_aspm(struct atl1c_hw *hw, u16 link_speed)
return; return;
} }
static void atl1c_setup_mac_ctrl(struct atl1c_adapter *adapter)
{
struct atl1c_hw *hw = &adapter->hw;
struct net_device *netdev = adapter->netdev;
u32 mac_ctrl_data;
mac_ctrl_data = MAC_CTRL_TX_EN | MAC_CTRL_RX_EN;
mac_ctrl_data |= (MAC_CTRL_TX_FLOW | MAC_CTRL_RX_FLOW);
if (adapter->link_duplex == FULL_DUPLEX) {
hw->mac_duplex = true;
mac_ctrl_data |= MAC_CTRL_DUPLX;
}
if (adapter->link_speed == SPEED_1000)
hw->mac_speed = atl1c_mac_speed_1000;
else
hw->mac_speed = atl1c_mac_speed_10_100;
mac_ctrl_data |= (hw->mac_speed & MAC_CTRL_SPEED_MASK) <<
MAC_CTRL_SPEED_SHIFT;
mac_ctrl_data |= (MAC_CTRL_ADD_CRC | MAC_CTRL_PAD);
mac_ctrl_data |= ((hw->preamble_len & MAC_CTRL_PRMLEN_MASK) <<
MAC_CTRL_PRMLEN_SHIFT);
__atl1c_vlan_mode(netdev->features, &mac_ctrl_data);
mac_ctrl_data |= MAC_CTRL_BC_EN;
if (netdev->flags & IFF_PROMISC)
mac_ctrl_data |= MAC_CTRL_PROMIS_EN;
if (netdev->flags & IFF_ALLMULTI)
mac_ctrl_data |= MAC_CTRL_MC_ALL_EN;
mac_ctrl_data |= MAC_CTRL_SINGLE_PAUSE_EN;
if (hw->nic_type == athr_l1d || hw->nic_type == athr_l2c_b2 ||
hw->nic_type == athr_l1d_2) {
mac_ctrl_data |= MAC_CTRL_SPEED_MODE_SW;
mac_ctrl_data |= MAC_CTRL_HASH_ALG_CRC32;
}
AT_WRITE_REG(hw, REG_MAC_CTRL, mac_ctrl_data);
}
/* /*
* atl1c_configure - Configure Transmit&Receive Unit after Reset * atl1c_configure - Configure Transmit&Receive Unit after Reset
* @adapter: board private structure * @adapter: board private structure
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册