diff options
author | Matt Carlson <mcarlson@broadcom.com> | 2009-09-01 08:53:31 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2009-09-02 03:43:28 -0400 |
commit | 2d31ecaf10c4ae03d49aed516481b2839b0220f6 (patch) | |
tree | c30ad4887a0dcc6f26856b329401169d6221421f /drivers/net/tg3.c | |
parent | fd2ce37f8e4a570ce90b141a2e7c476c5b399836 (diff) |
tg3: Create tg3_rings_reset()
This patch moves most of the chip ring setup logic into a separate
function. This will make it easier to verify the multi ring setup
changes.
Signed-off-by: Matt Carlson <mcarlson@broadcom.com>
Reviewed-by: Benjamin Li <benli@broadcom.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/tg3.c')
-rw-r--r-- | drivers/net/tg3.c | 140 |
1 files changed, 81 insertions, 59 deletions
diff --git a/drivers/net/tg3.c b/drivers/net/tg3.c index ff65ae8b592e..14cead69c4cc 100644 --- a/drivers/net/tg3.c +++ b/drivers/net/tg3.c | |||
@@ -6818,6 +6818,76 @@ static void __tg3_set_coalesce(struct tg3 *tp, struct ethtool_coalesce *ec) | |||
6818 | } | 6818 | } |
6819 | 6819 | ||
6820 | /* tp->lock is held. */ | 6820 | /* tp->lock is held. */ |
6821 | static void tg3_rings_reset(struct tg3 *tp) | ||
6822 | { | ||
6823 | int i; | ||
6824 | u32 txrcb, rxrcb, limit; | ||
6825 | struct tg3_napi *tnapi = &tp->napi[0]; | ||
6826 | |||
6827 | /* Disable all transmit rings but the first. */ | ||
6828 | if (!(tp->tg3_flags2 & TG3_FLG2_5705_PLUS)) | ||
6829 | limit = NIC_SRAM_SEND_RCB + TG3_BDINFO_SIZE * 16; | ||
6830 | else | ||
6831 | limit = NIC_SRAM_SEND_RCB + TG3_BDINFO_SIZE; | ||
6832 | |||
6833 | for (txrcb = NIC_SRAM_SEND_RCB + TG3_BDINFO_SIZE; | ||
6834 | txrcb < limit; txrcb += TG3_BDINFO_SIZE) | ||
6835 | tg3_write_mem(tp, txrcb + TG3_BDINFO_MAXLEN_FLAGS, | ||
6836 | BDINFO_FLAGS_DISABLED); | ||
6837 | |||
6838 | |||
6839 | /* Disable all receive return rings but the first. */ | ||
6840 | if (!(tp->tg3_flags2 & TG3_FLG2_5705_PLUS)) | ||
6841 | limit = NIC_SRAM_RCV_RET_RCB + TG3_BDINFO_SIZE * 16; | ||
6842 | else if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5755) | ||
6843 | limit = NIC_SRAM_RCV_RET_RCB + TG3_BDINFO_SIZE * 4; | ||
6844 | else | ||
6845 | limit = NIC_SRAM_RCV_RET_RCB + TG3_BDINFO_SIZE; | ||
6846 | |||
6847 | for (rxrcb = NIC_SRAM_RCV_RET_RCB + TG3_BDINFO_SIZE; | ||
6848 | rxrcb < limit; rxrcb += TG3_BDINFO_SIZE) | ||
6849 | tg3_write_mem(tp, rxrcb + TG3_BDINFO_MAXLEN_FLAGS, | ||
6850 | BDINFO_FLAGS_DISABLED); | ||
6851 | |||
6852 | /* Disable interrupts */ | ||
6853 | tw32_mailbox_f(tp->napi[0].int_mbox, 1); | ||
6854 | |||
6855 | /* Zero mailbox registers. */ | ||
6856 | tp->napi[0].tx_prod = 0; | ||
6857 | tp->napi[0].tx_cons = 0; | ||
6858 | tw32_mailbox(tp->napi[0].prodmbox, 0); | ||
6859 | tw32_rx_mbox(tp->napi[0].consmbox, 0); | ||
6860 | |||
6861 | /* Make sure the NIC-based send BD rings are disabled. */ | ||
6862 | if (!(tp->tg3_flags2 & TG3_FLG2_5705_PLUS)) { | ||
6863 | u32 mbox = MAILBOX_SNDNIC_PROD_IDX_0 + TG3_64BIT_REG_LOW; | ||
6864 | for (i = 0; i < 16; i++) | ||
6865 | tw32_tx_mbox(mbox + i * 8, 0); | ||
6866 | } | ||
6867 | |||
6868 | txrcb = NIC_SRAM_SEND_RCB; | ||
6869 | rxrcb = NIC_SRAM_RCV_RET_RCB; | ||
6870 | |||
6871 | /* Clear status block in ram. */ | ||
6872 | memset(tnapi->hw_status, 0, TG3_HW_STATUS_SIZE); | ||
6873 | |||
6874 | /* Set status block DMA address */ | ||
6875 | tw32(HOSTCC_STATUS_BLK_HOST_ADDR + TG3_64BIT_REG_HIGH, | ||
6876 | ((u64) tnapi->status_mapping >> 32)); | ||
6877 | tw32(HOSTCC_STATUS_BLK_HOST_ADDR + TG3_64BIT_REG_LOW, | ||
6878 | ((u64) tnapi->status_mapping & 0xffffffff)); | ||
6879 | |||
6880 | tg3_set_bdinfo(tp, txrcb, tnapi->tx_desc_mapping, | ||
6881 | (TG3_TX_RING_SIZE << | ||
6882 | BDINFO_FLAGS_MAXLEN_SHIFT), | ||
6883 | NIC_SRAM_TX_BUFFER_DESC); | ||
6884 | |||
6885 | tg3_set_bdinfo(tp, rxrcb, tnapi->rx_rcb_mapping, | ||
6886 | (TG3_RX_RCB_RING_SIZE(tp) << | ||
6887 | BDINFO_FLAGS_MAXLEN_SHIFT), 0); | ||
6888 | } | ||
6889 | |||
6890 | /* tp->lock is held. */ | ||
6821 | static int tg3_reset_hw(struct tg3 *tp, int reset_phy) | 6891 | static int tg3_reset_hw(struct tg3 *tp, int reset_phy) |
6822 | { | 6892 | { |
6823 | u32 val, rdmac_mode; | 6893 | u32 val, rdmac_mode; |
@@ -7091,48 +7161,6 @@ static int tg3_reset_hw(struct tg3 *tp, int reset_phy) | |||
7091 | 7161 | ||
7092 | tw32(RCVDBDI_STD_BD + TG3_BDINFO_MAXLEN_FLAGS, val); | 7162 | tw32(RCVDBDI_STD_BD + TG3_BDINFO_MAXLEN_FLAGS, val); |
7093 | 7163 | ||
7094 | /* There is only one send ring on 5705/5750, no need to explicitly | ||
7095 | * disable the others. | ||
7096 | */ | ||
7097 | if (!(tp->tg3_flags2 & TG3_FLG2_5705_PLUS)) { | ||
7098 | /* Clear out send RCB ring in SRAM. */ | ||
7099 | for (i = NIC_SRAM_SEND_RCB; i < NIC_SRAM_RCV_RET_RCB; i += TG3_BDINFO_SIZE) | ||
7100 | tg3_write_mem(tp, i + TG3_BDINFO_MAXLEN_FLAGS, | ||
7101 | BDINFO_FLAGS_DISABLED); | ||
7102 | } | ||
7103 | |||
7104 | tp->napi[0].tx_prod = 0; | ||
7105 | tp->napi[0].tx_cons = 0; | ||
7106 | tw32_tx_mbox(MAILBOX_SNDNIC_PROD_IDX_0 + TG3_64BIT_REG_LOW, 0); | ||
7107 | |||
7108 | val = MAILBOX_SNDHOST_PROD_IDX_0 + TG3_64BIT_REG_LOW; | ||
7109 | tw32_mailbox(val, 0); | ||
7110 | |||
7111 | tg3_set_bdinfo(tp, NIC_SRAM_SEND_RCB, | ||
7112 | tp->napi[0].tx_desc_mapping, | ||
7113 | (TG3_TX_RING_SIZE << | ||
7114 | BDINFO_FLAGS_MAXLEN_SHIFT), | ||
7115 | NIC_SRAM_TX_BUFFER_DESC); | ||
7116 | |||
7117 | /* There is only one receive return ring on 5705/5750, no need | ||
7118 | * to explicitly disable the others. | ||
7119 | */ | ||
7120 | if (!(tp->tg3_flags2 & TG3_FLG2_5705_PLUS)) { | ||
7121 | for (i = NIC_SRAM_RCV_RET_RCB; i < NIC_SRAM_STATS_BLK; | ||
7122 | i += TG3_BDINFO_SIZE) { | ||
7123 | tg3_write_mem(tp, i + TG3_BDINFO_MAXLEN_FLAGS, | ||
7124 | BDINFO_FLAGS_DISABLED); | ||
7125 | } | ||
7126 | } | ||
7127 | |||
7128 | tw32_rx_mbox(tp->napi[0].consmbox, 0); | ||
7129 | |||
7130 | tg3_set_bdinfo(tp, NIC_SRAM_RCV_RET_RCB, | ||
7131 | tp->napi[0].rx_rcb_mapping, | ||
7132 | (TG3_RX_RCB_RING_SIZE(tp) << | ||
7133 | BDINFO_FLAGS_MAXLEN_SHIFT), | ||
7134 | 0); | ||
7135 | |||
7136 | tpr->rx_std_ptr = tp->rx_pending; | 7164 | tpr->rx_std_ptr = tp->rx_pending; |
7137 | tw32_rx_mbox(MAILBOX_RCV_STD_PROD_IDX + TG3_64BIT_REG_LOW, | 7165 | tw32_rx_mbox(MAILBOX_RCV_STD_PROD_IDX + TG3_64BIT_REG_LOW, |
7138 | tpr->rx_std_ptr); | 7166 | tpr->rx_std_ptr); |
@@ -7142,6 +7170,8 @@ static int tg3_reset_hw(struct tg3 *tp, int reset_phy) | |||
7142 | tw32_rx_mbox(MAILBOX_RCV_JUMBO_PROD_IDX + TG3_64BIT_REG_LOW, | 7170 | tw32_rx_mbox(MAILBOX_RCV_JUMBO_PROD_IDX + TG3_64BIT_REG_LOW, |
7143 | tpr->rx_jmb_ptr); | 7171 | tpr->rx_jmb_ptr); |
7144 | 7172 | ||
7173 | tg3_rings_reset(tp); | ||
7174 | |||
7145 | /* Initialize MAC address and backoff seed. */ | 7175 | /* Initialize MAC address and backoff seed. */ |
7146 | __tg3_set_mac_addr(tp, 0); | 7176 | __tg3_set_mac_addr(tp, 0); |
7147 | 7177 | ||
@@ -7229,12 +7259,6 @@ static int tg3_reset_hw(struct tg3 *tp, int reset_phy) | |||
7229 | 7259 | ||
7230 | __tg3_set_coalesce(tp, &tp->coal); | 7260 | __tg3_set_coalesce(tp, &tp->coal); |
7231 | 7261 | ||
7232 | /* set status block DMA address */ | ||
7233 | tw32(HOSTCC_STATUS_BLK_HOST_ADDR + TG3_64BIT_REG_HIGH, | ||
7234 | ((u64) tp->napi[0].status_mapping >> 32)); | ||
7235 | tw32(HOSTCC_STATUS_BLK_HOST_ADDR + TG3_64BIT_REG_LOW, | ||
7236 | ((u64) tp->napi[0].status_mapping & 0xffffffff)); | ||
7237 | |||
7238 | if (!(tp->tg3_flags2 & TG3_FLG2_5705_PLUS)) { | 7262 | if (!(tp->tg3_flags2 & TG3_FLG2_5705_PLUS)) { |
7239 | /* Status/statistics block address. See tg3_timer, | 7263 | /* Status/statistics block address. See tg3_timer, |
7240 | * the tg3_periodic_fetch_stats call there, and | 7264 | * the tg3_periodic_fetch_stats call there, and |
@@ -7245,7 +7269,16 @@ static int tg3_reset_hw(struct tg3 *tp, int reset_phy) | |||
7245 | tw32(HOSTCC_STATS_BLK_HOST_ADDR + TG3_64BIT_REG_LOW, | 7269 | tw32(HOSTCC_STATS_BLK_HOST_ADDR + TG3_64BIT_REG_LOW, |
7246 | ((u64) tp->stats_mapping & 0xffffffff)); | 7270 | ((u64) tp->stats_mapping & 0xffffffff)); |
7247 | tw32(HOSTCC_STATS_BLK_NIC_ADDR, NIC_SRAM_STATS_BLK); | 7271 | tw32(HOSTCC_STATS_BLK_NIC_ADDR, NIC_SRAM_STATS_BLK); |
7272 | |||
7248 | tw32(HOSTCC_STATUS_BLK_NIC_ADDR, NIC_SRAM_STATUS_BLK); | 7273 | tw32(HOSTCC_STATUS_BLK_NIC_ADDR, NIC_SRAM_STATUS_BLK); |
7274 | |||
7275 | /* Clear statistics and status block memory areas */ | ||
7276 | for (i = NIC_SRAM_STATS_BLK; | ||
7277 | i < NIC_SRAM_STATUS_BLK + TG3_HW_STATUS_SIZE; | ||
7278 | i += sizeof(u32)) { | ||
7279 | tg3_write_mem(tp, i, 0); | ||
7280 | udelay(40); | ||
7281 | } | ||
7249 | } | 7282 | } |
7250 | 7283 | ||
7251 | tw32(HOSTCC_MODE, HOSTCC_MODE_ENABLE | tp->coalesce_mode); | 7284 | tw32(HOSTCC_MODE, HOSTCC_MODE_ENABLE | tp->coalesce_mode); |
@@ -7255,15 +7288,6 @@ static int tg3_reset_hw(struct tg3 *tp, int reset_phy) | |||
7255 | if (!(tp->tg3_flags2 & TG3_FLG2_5705_PLUS)) | 7288 | if (!(tp->tg3_flags2 & TG3_FLG2_5705_PLUS)) |
7256 | tw32(RCVLSC_MODE, RCVLSC_MODE_ENABLE | RCVLSC_MODE_ATTN_ENABLE); | 7289 | tw32(RCVLSC_MODE, RCVLSC_MODE_ENABLE | RCVLSC_MODE_ATTN_ENABLE); |
7257 | 7290 | ||
7258 | /* Clear statistics/status block in chip, and status block in ram. */ | ||
7259 | for (i = NIC_SRAM_STATS_BLK; | ||
7260 | i < NIC_SRAM_STATUS_BLK + TG3_HW_STATUS_SIZE; | ||
7261 | i += sizeof(u32)) { | ||
7262 | tg3_write_mem(tp, i, 0); | ||
7263 | udelay(40); | ||
7264 | } | ||
7265 | memset(tp->napi[0].hw_status, 0, TG3_HW_STATUS_SIZE); | ||
7266 | |||
7267 | if (tp->tg3_flags2 & TG3_FLG2_MII_SERDES) { | 7291 | if (tp->tg3_flags2 & TG3_FLG2_MII_SERDES) { |
7268 | tp->tg3_flags2 &= ~TG3_FLG2_PARALLEL_DETECT; | 7292 | tp->tg3_flags2 &= ~TG3_FLG2_PARALLEL_DETECT; |
7269 | /* reset to prevent losing 1st rx packet intermittently */ | 7293 | /* reset to prevent losing 1st rx packet intermittently */ |
@@ -7315,8 +7339,6 @@ static int tg3_reset_hw(struct tg3 *tp, int reset_phy) | |||
7315 | tw32_f(GRC_LOCAL_CTRL, tp->grc_local_ctrl); | 7339 | tw32_f(GRC_LOCAL_CTRL, tp->grc_local_ctrl); |
7316 | udelay(100); | 7340 | udelay(100); |
7317 | 7341 | ||
7318 | tw32_mailbox_f(tp->napi[0].int_mbox, 0); | ||
7319 | |||
7320 | if (!(tp->tg3_flags2 & TG3_FLG2_5705_PLUS)) { | 7342 | if (!(tp->tg3_flags2 & TG3_FLG2_5705_PLUS)) { |
7321 | tw32_f(DMAC_MODE, DMAC_MODE_ENABLE); | 7343 | tw32_f(DMAC_MODE, DMAC_MODE_ENABLE); |
7322 | udelay(40); | 7344 | udelay(40); |