Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 1 | /* |
Dhananjay Phadke | 5d242f1 | 2009-02-25 15:57:56 +0000 | [diff] [blame] | 2 | * Copyright (C) 2003 - 2009 NetXen, Inc. |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 3 | * All rights reserved. |
Amit S. Kale | 80922fb | 2006-12-04 09:18:00 -0800 | [diff] [blame] | 4 | * |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 5 | * This program is free software; you can redistribute it and/or |
| 6 | * modify it under the terms of the GNU General Public License |
| 7 | * as published by the Free Software Foundation; either version 2 |
| 8 | * of the License, or (at your option) any later version. |
Amit S. Kale | cb8011a | 2006-11-29 09:00:10 -0800 | [diff] [blame] | 9 | * |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 10 | * This program is distributed in the hope that it will be useful, but |
| 11 | * WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 13 | * GNU General Public License for more details. |
Amit S. Kale | cb8011a | 2006-11-29 09:00:10 -0800 | [diff] [blame] | 14 | * |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 15 | * You should have received a copy of the GNU General Public License |
| 16 | * along with this program; if not, write to the Free Software |
| 17 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, |
| 18 | * MA 02111-1307, USA. |
Amit S. Kale | 80922fb | 2006-12-04 09:18:00 -0800 | [diff] [blame] | 19 | * |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 20 | * The full GNU General Public License is included in this distribution |
| 21 | * in the file called LICENSE. |
Amit S. Kale | 80922fb | 2006-12-04 09:18:00 -0800 | [diff] [blame] | 22 | * |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 23 | * Contact Information: |
| 24 | * info@netxen.com |
Dhananjay Phadke | 5d242f1 | 2009-02-25 15:57:56 +0000 | [diff] [blame] | 25 | * NetXen Inc, |
| 26 | * 18922 Forge Drive |
| 27 | * Cupertino, CA 95014-0701 |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 28 | * |
| 29 | */ |
| 30 | |
| 31 | #include "netxen_nic.h" |
| 32 | #include "netxen_nic_hw.h" |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 33 | |
Arnaldo Carvalho de Melo | c9bdd4b | 2007-03-12 20:09:15 -0300 | [diff] [blame] | 34 | #include <net/ip.h> |
| 35 | |
Dhananjay Phadke | 3ce06a3 | 2008-07-21 19:44:03 -0700 | [diff] [blame] | 36 | #define MASK(n) ((1ULL<<(n))-1) |
| 37 | #define MN_WIN(addr) (((addr & 0x1fc0000) >> 1) | ((addr >> 25) & 0x3ff)) |
| 38 | #define OCM_WIN(addr) (((addr & 0x1ff0000) >> 1) | ((addr >> 25) & 0x3ff)) |
| 39 | #define MS_WIN(addr) (addr & 0x0ffc0000) |
| 40 | |
| 41 | #define GET_MEM_OFFS_2M(addr) (addr & MASK(18)) |
| 42 | |
| 43 | #define CRB_BLK(off) ((off >> 20) & 0x3f) |
| 44 | #define CRB_SUBBLK(off) ((off >> 16) & 0xf) |
| 45 | #define CRB_WINDOW_2M (0x130060) |
| 46 | #define CRB_HI(off) ((crb_hub_agt[CRB_BLK(off)] << 20) | ((off) & 0xf0000)) |
| 47 | #define CRB_INDIRECT_2M (0x1e0000UL) |
| 48 | |
Dhananjay Phadke | e98e335 | 2009-04-07 22:50:38 +0000 | [diff] [blame] | 49 | #ifndef readq |
| 50 | static inline u64 readq(void __iomem *addr) |
| 51 | { |
| 52 | return readl(addr) | (((u64) readl(addr + 4)) << 32LL); |
| 53 | } |
| 54 | #endif |
| 55 | |
| 56 | #ifndef writeq |
| 57 | static inline void writeq(u64 val, void __iomem *addr) |
| 58 | { |
| 59 | writel(((u32) (val)), (addr)); |
| 60 | writel(((u32) (val >> 32)), (addr + 4)); |
| 61 | } |
| 62 | #endif |
| 63 | |
Dhananjay Phadke | 1fbe632 | 2009-04-07 22:50:44 +0000 | [diff] [blame] | 64 | #define ADDR_IN_RANGE(addr, low, high) \ |
| 65 | (((addr) < (high)) && ((addr) >= (low))) |
| 66 | |
| 67 | #define PCI_OFFSET_FIRST_RANGE(adapter, off) \ |
| 68 | ((adapter)->ahw.pci_base0 + (off)) |
| 69 | #define PCI_OFFSET_SECOND_RANGE(adapter, off) \ |
| 70 | ((adapter)->ahw.pci_base1 + (off) - SECOND_PAGE_GROUP_START) |
| 71 | #define PCI_OFFSET_THIRD_RANGE(adapter, off) \ |
| 72 | ((adapter)->ahw.pci_base2 + (off) - THIRD_PAGE_GROUP_START) |
| 73 | |
| 74 | static void __iomem *pci_base_offset(struct netxen_adapter *adapter, |
| 75 | unsigned long off) |
| 76 | { |
| 77 | if (ADDR_IN_RANGE(off, FIRST_PAGE_GROUP_START, FIRST_PAGE_GROUP_END)) |
| 78 | return PCI_OFFSET_FIRST_RANGE(adapter, off); |
| 79 | |
| 80 | if (ADDR_IN_RANGE(off, SECOND_PAGE_GROUP_START, SECOND_PAGE_GROUP_END)) |
| 81 | return PCI_OFFSET_SECOND_RANGE(adapter, off); |
| 82 | |
| 83 | if (ADDR_IN_RANGE(off, THIRD_PAGE_GROUP_START, THIRD_PAGE_GROUP_END)) |
| 84 | return PCI_OFFSET_THIRD_RANGE(adapter, off); |
| 85 | |
| 86 | return NULL; |
| 87 | } |
| 88 | |
Dhananjay Phadke | ea7eaa3 | 2009-04-07 22:50:48 +0000 | [diff] [blame] | 89 | static crb_128M_2M_block_map_t |
| 90 | crb_128M_2M_map[64] __cacheline_aligned_in_smp = { |
Dhananjay Phadke | 3ce06a3 | 2008-07-21 19:44:03 -0700 | [diff] [blame] | 91 | {{{0, 0, 0, 0} } }, /* 0: PCI */ |
| 92 | {{{1, 0x0100000, 0x0102000, 0x120000}, /* 1: PCIE */ |
| 93 | {1, 0x0110000, 0x0120000, 0x130000}, |
| 94 | {1, 0x0120000, 0x0122000, 0x124000}, |
| 95 | {1, 0x0130000, 0x0132000, 0x126000}, |
| 96 | {1, 0x0140000, 0x0142000, 0x128000}, |
| 97 | {1, 0x0150000, 0x0152000, 0x12a000}, |
| 98 | {1, 0x0160000, 0x0170000, 0x110000}, |
| 99 | {1, 0x0170000, 0x0172000, 0x12e000}, |
| 100 | {0, 0x0000000, 0x0000000, 0x000000}, |
| 101 | {0, 0x0000000, 0x0000000, 0x000000}, |
| 102 | {0, 0x0000000, 0x0000000, 0x000000}, |
| 103 | {0, 0x0000000, 0x0000000, 0x000000}, |
| 104 | {0, 0x0000000, 0x0000000, 0x000000}, |
| 105 | {0, 0x0000000, 0x0000000, 0x000000}, |
| 106 | {1, 0x01e0000, 0x01e0800, 0x122000}, |
| 107 | {0, 0x0000000, 0x0000000, 0x000000} } }, |
| 108 | {{{1, 0x0200000, 0x0210000, 0x180000} } },/* 2: MN */ |
| 109 | {{{0, 0, 0, 0} } }, /* 3: */ |
| 110 | {{{1, 0x0400000, 0x0401000, 0x169000} } },/* 4: P2NR1 */ |
| 111 | {{{1, 0x0500000, 0x0510000, 0x140000} } },/* 5: SRE */ |
| 112 | {{{1, 0x0600000, 0x0610000, 0x1c0000} } },/* 6: NIU */ |
| 113 | {{{1, 0x0700000, 0x0704000, 0x1b8000} } },/* 7: QM */ |
| 114 | {{{1, 0x0800000, 0x0802000, 0x170000}, /* 8: SQM0 */ |
| 115 | {0, 0x0000000, 0x0000000, 0x000000}, |
| 116 | {0, 0x0000000, 0x0000000, 0x000000}, |
| 117 | {0, 0x0000000, 0x0000000, 0x000000}, |
| 118 | {0, 0x0000000, 0x0000000, 0x000000}, |
| 119 | {0, 0x0000000, 0x0000000, 0x000000}, |
| 120 | {0, 0x0000000, 0x0000000, 0x000000}, |
| 121 | {0, 0x0000000, 0x0000000, 0x000000}, |
| 122 | {0, 0x0000000, 0x0000000, 0x000000}, |
| 123 | {0, 0x0000000, 0x0000000, 0x000000}, |
| 124 | {0, 0x0000000, 0x0000000, 0x000000}, |
| 125 | {0, 0x0000000, 0x0000000, 0x000000}, |
| 126 | {0, 0x0000000, 0x0000000, 0x000000}, |
| 127 | {0, 0x0000000, 0x0000000, 0x000000}, |
| 128 | {0, 0x0000000, 0x0000000, 0x000000}, |
| 129 | {1, 0x08f0000, 0x08f2000, 0x172000} } }, |
| 130 | {{{1, 0x0900000, 0x0902000, 0x174000}, /* 9: SQM1*/ |
| 131 | {0, 0x0000000, 0x0000000, 0x000000}, |
| 132 | {0, 0x0000000, 0x0000000, 0x000000}, |
| 133 | {0, 0x0000000, 0x0000000, 0x000000}, |
| 134 | {0, 0x0000000, 0x0000000, 0x000000}, |
| 135 | {0, 0x0000000, 0x0000000, 0x000000}, |
| 136 | {0, 0x0000000, 0x0000000, 0x000000}, |
| 137 | {0, 0x0000000, 0x0000000, 0x000000}, |
| 138 | {0, 0x0000000, 0x0000000, 0x000000}, |
| 139 | {0, 0x0000000, 0x0000000, 0x000000}, |
| 140 | {0, 0x0000000, 0x0000000, 0x000000}, |
| 141 | {0, 0x0000000, 0x0000000, 0x000000}, |
| 142 | {0, 0x0000000, 0x0000000, 0x000000}, |
| 143 | {0, 0x0000000, 0x0000000, 0x000000}, |
| 144 | {0, 0x0000000, 0x0000000, 0x000000}, |
| 145 | {1, 0x09f0000, 0x09f2000, 0x176000} } }, |
| 146 | {{{0, 0x0a00000, 0x0a02000, 0x178000}, /* 10: SQM2*/ |
| 147 | {0, 0x0000000, 0x0000000, 0x000000}, |
| 148 | {0, 0x0000000, 0x0000000, 0x000000}, |
| 149 | {0, 0x0000000, 0x0000000, 0x000000}, |
| 150 | {0, 0x0000000, 0x0000000, 0x000000}, |
| 151 | {0, 0x0000000, 0x0000000, 0x000000}, |
| 152 | {0, 0x0000000, 0x0000000, 0x000000}, |
| 153 | {0, 0x0000000, 0x0000000, 0x000000}, |
| 154 | {0, 0x0000000, 0x0000000, 0x000000}, |
| 155 | {0, 0x0000000, 0x0000000, 0x000000}, |
| 156 | {0, 0x0000000, 0x0000000, 0x000000}, |
| 157 | {0, 0x0000000, 0x0000000, 0x000000}, |
| 158 | {0, 0x0000000, 0x0000000, 0x000000}, |
| 159 | {0, 0x0000000, 0x0000000, 0x000000}, |
| 160 | {0, 0x0000000, 0x0000000, 0x000000}, |
| 161 | {1, 0x0af0000, 0x0af2000, 0x17a000} } }, |
| 162 | {{{0, 0x0b00000, 0x0b02000, 0x17c000}, /* 11: SQM3*/ |
| 163 | {0, 0x0000000, 0x0000000, 0x000000}, |
| 164 | {0, 0x0000000, 0x0000000, 0x000000}, |
| 165 | {0, 0x0000000, 0x0000000, 0x000000}, |
| 166 | {0, 0x0000000, 0x0000000, 0x000000}, |
| 167 | {0, 0x0000000, 0x0000000, 0x000000}, |
| 168 | {0, 0x0000000, 0x0000000, 0x000000}, |
| 169 | {0, 0x0000000, 0x0000000, 0x000000}, |
| 170 | {0, 0x0000000, 0x0000000, 0x000000}, |
| 171 | {0, 0x0000000, 0x0000000, 0x000000}, |
| 172 | {0, 0x0000000, 0x0000000, 0x000000}, |
| 173 | {0, 0x0000000, 0x0000000, 0x000000}, |
| 174 | {0, 0x0000000, 0x0000000, 0x000000}, |
| 175 | {0, 0x0000000, 0x0000000, 0x000000}, |
| 176 | {0, 0x0000000, 0x0000000, 0x000000}, |
| 177 | {1, 0x0bf0000, 0x0bf2000, 0x17e000} } }, |
| 178 | {{{1, 0x0c00000, 0x0c04000, 0x1d4000} } },/* 12: I2Q */ |
| 179 | {{{1, 0x0d00000, 0x0d04000, 0x1a4000} } },/* 13: TMR */ |
| 180 | {{{1, 0x0e00000, 0x0e04000, 0x1a0000} } },/* 14: ROMUSB */ |
| 181 | {{{1, 0x0f00000, 0x0f01000, 0x164000} } },/* 15: PEG4 */ |
| 182 | {{{0, 0x1000000, 0x1004000, 0x1a8000} } },/* 16: XDMA */ |
| 183 | {{{1, 0x1100000, 0x1101000, 0x160000} } },/* 17: PEG0 */ |
| 184 | {{{1, 0x1200000, 0x1201000, 0x161000} } },/* 18: PEG1 */ |
| 185 | {{{1, 0x1300000, 0x1301000, 0x162000} } },/* 19: PEG2 */ |
| 186 | {{{1, 0x1400000, 0x1401000, 0x163000} } },/* 20: PEG3 */ |
| 187 | {{{1, 0x1500000, 0x1501000, 0x165000} } },/* 21: P2ND */ |
| 188 | {{{1, 0x1600000, 0x1601000, 0x166000} } },/* 22: P2NI */ |
| 189 | {{{0, 0, 0, 0} } }, /* 23: */ |
| 190 | {{{0, 0, 0, 0} } }, /* 24: */ |
| 191 | {{{0, 0, 0, 0} } }, /* 25: */ |
| 192 | {{{0, 0, 0, 0} } }, /* 26: */ |
| 193 | {{{0, 0, 0, 0} } }, /* 27: */ |
| 194 | {{{0, 0, 0, 0} } }, /* 28: */ |
| 195 | {{{1, 0x1d00000, 0x1d10000, 0x190000} } },/* 29: MS */ |
| 196 | {{{1, 0x1e00000, 0x1e01000, 0x16a000} } },/* 30: P2NR2 */ |
| 197 | {{{1, 0x1f00000, 0x1f10000, 0x150000} } },/* 31: EPG */ |
| 198 | {{{0} } }, /* 32: PCI */ |
| 199 | {{{1, 0x2100000, 0x2102000, 0x120000}, /* 33: PCIE */ |
| 200 | {1, 0x2110000, 0x2120000, 0x130000}, |
| 201 | {1, 0x2120000, 0x2122000, 0x124000}, |
| 202 | {1, 0x2130000, 0x2132000, 0x126000}, |
| 203 | {1, 0x2140000, 0x2142000, 0x128000}, |
| 204 | {1, 0x2150000, 0x2152000, 0x12a000}, |
| 205 | {1, 0x2160000, 0x2170000, 0x110000}, |
| 206 | {1, 0x2170000, 0x2172000, 0x12e000}, |
| 207 | {0, 0x0000000, 0x0000000, 0x000000}, |
| 208 | {0, 0x0000000, 0x0000000, 0x000000}, |
| 209 | {0, 0x0000000, 0x0000000, 0x000000}, |
| 210 | {0, 0x0000000, 0x0000000, 0x000000}, |
| 211 | {0, 0x0000000, 0x0000000, 0x000000}, |
| 212 | {0, 0x0000000, 0x0000000, 0x000000}, |
| 213 | {0, 0x0000000, 0x0000000, 0x000000}, |
| 214 | {0, 0x0000000, 0x0000000, 0x000000} } }, |
| 215 | {{{1, 0x2200000, 0x2204000, 0x1b0000} } },/* 34: CAM */ |
| 216 | {{{0} } }, /* 35: */ |
| 217 | {{{0} } }, /* 36: */ |
| 218 | {{{0} } }, /* 37: */ |
| 219 | {{{0} } }, /* 38: */ |
| 220 | {{{0} } }, /* 39: */ |
| 221 | {{{1, 0x2800000, 0x2804000, 0x1a4000} } },/* 40: TMR */ |
| 222 | {{{1, 0x2900000, 0x2901000, 0x16b000} } },/* 41: P2NR3 */ |
| 223 | {{{1, 0x2a00000, 0x2a00400, 0x1ac400} } },/* 42: RPMX1 */ |
| 224 | {{{1, 0x2b00000, 0x2b00400, 0x1ac800} } },/* 43: RPMX2 */ |
| 225 | {{{1, 0x2c00000, 0x2c00400, 0x1acc00} } },/* 44: RPMX3 */ |
| 226 | {{{1, 0x2d00000, 0x2d00400, 0x1ad000} } },/* 45: RPMX4 */ |
| 227 | {{{1, 0x2e00000, 0x2e00400, 0x1ad400} } },/* 46: RPMX5 */ |
| 228 | {{{1, 0x2f00000, 0x2f00400, 0x1ad800} } },/* 47: RPMX6 */ |
| 229 | {{{1, 0x3000000, 0x3000400, 0x1adc00} } },/* 48: RPMX7 */ |
| 230 | {{{0, 0x3100000, 0x3104000, 0x1a8000} } },/* 49: XDMA */ |
| 231 | {{{1, 0x3200000, 0x3204000, 0x1d4000} } },/* 50: I2Q */ |
| 232 | {{{1, 0x3300000, 0x3304000, 0x1a0000} } },/* 51: ROMUSB */ |
| 233 | {{{0} } }, /* 52: */ |
| 234 | {{{1, 0x3500000, 0x3500400, 0x1ac000} } },/* 53: RPMX0 */ |
| 235 | {{{1, 0x3600000, 0x3600400, 0x1ae000} } },/* 54: RPMX8 */ |
| 236 | {{{1, 0x3700000, 0x3700400, 0x1ae400} } },/* 55: RPMX9 */ |
| 237 | {{{1, 0x3800000, 0x3804000, 0x1d0000} } },/* 56: OCM0 */ |
| 238 | {{{1, 0x3900000, 0x3904000, 0x1b4000} } },/* 57: CRYPTO */ |
| 239 | {{{1, 0x3a00000, 0x3a04000, 0x1d8000} } },/* 58: SMB */ |
| 240 | {{{0} } }, /* 59: I2C0 */ |
| 241 | {{{0} } }, /* 60: I2C1 */ |
| 242 | {{{1, 0x3d00000, 0x3d04000, 0x1d8000} } },/* 61: LPC */ |
| 243 | {{{1, 0x3e00000, 0x3e01000, 0x167000} } },/* 62: P2NC */ |
| 244 | {{{1, 0x3f00000, 0x3f01000, 0x168000} } } /* 63: P2NR0 */ |
| 245 | }; |
| 246 | |
| 247 | /* |
| 248 | * top 12 bits of crb internal address (hub, agent) |
| 249 | */ |
| 250 | static unsigned crb_hub_agt[64] = |
| 251 | { |
| 252 | 0, |
| 253 | NETXEN_HW_CRB_HUB_AGT_ADR_PS, |
| 254 | NETXEN_HW_CRB_HUB_AGT_ADR_MN, |
| 255 | NETXEN_HW_CRB_HUB_AGT_ADR_MS, |
| 256 | 0, |
| 257 | NETXEN_HW_CRB_HUB_AGT_ADR_SRE, |
| 258 | NETXEN_HW_CRB_HUB_AGT_ADR_NIU, |
| 259 | NETXEN_HW_CRB_HUB_AGT_ADR_QMN, |
| 260 | NETXEN_HW_CRB_HUB_AGT_ADR_SQN0, |
| 261 | NETXEN_HW_CRB_HUB_AGT_ADR_SQN1, |
| 262 | NETXEN_HW_CRB_HUB_AGT_ADR_SQN2, |
| 263 | NETXEN_HW_CRB_HUB_AGT_ADR_SQN3, |
| 264 | NETXEN_HW_CRB_HUB_AGT_ADR_I2Q, |
| 265 | NETXEN_HW_CRB_HUB_AGT_ADR_TIMR, |
| 266 | NETXEN_HW_CRB_HUB_AGT_ADR_ROMUSB, |
| 267 | NETXEN_HW_CRB_HUB_AGT_ADR_PGN4, |
| 268 | NETXEN_HW_CRB_HUB_AGT_ADR_XDMA, |
| 269 | NETXEN_HW_CRB_HUB_AGT_ADR_PGN0, |
| 270 | NETXEN_HW_CRB_HUB_AGT_ADR_PGN1, |
| 271 | NETXEN_HW_CRB_HUB_AGT_ADR_PGN2, |
| 272 | NETXEN_HW_CRB_HUB_AGT_ADR_PGN3, |
| 273 | NETXEN_HW_CRB_HUB_AGT_ADR_PGND, |
| 274 | NETXEN_HW_CRB_HUB_AGT_ADR_PGNI, |
| 275 | NETXEN_HW_CRB_HUB_AGT_ADR_PGS0, |
| 276 | NETXEN_HW_CRB_HUB_AGT_ADR_PGS1, |
| 277 | NETXEN_HW_CRB_HUB_AGT_ADR_PGS2, |
| 278 | NETXEN_HW_CRB_HUB_AGT_ADR_PGS3, |
| 279 | 0, |
| 280 | NETXEN_HW_CRB_HUB_AGT_ADR_PGSI, |
| 281 | NETXEN_HW_CRB_HUB_AGT_ADR_SN, |
| 282 | 0, |
| 283 | NETXEN_HW_CRB_HUB_AGT_ADR_EG, |
| 284 | 0, |
| 285 | NETXEN_HW_CRB_HUB_AGT_ADR_PS, |
| 286 | NETXEN_HW_CRB_HUB_AGT_ADR_CAM, |
| 287 | 0, |
| 288 | 0, |
| 289 | 0, |
| 290 | 0, |
| 291 | 0, |
| 292 | NETXEN_HW_CRB_HUB_AGT_ADR_TIMR, |
| 293 | 0, |
| 294 | NETXEN_HW_CRB_HUB_AGT_ADR_RPMX1, |
| 295 | NETXEN_HW_CRB_HUB_AGT_ADR_RPMX2, |
| 296 | NETXEN_HW_CRB_HUB_AGT_ADR_RPMX3, |
| 297 | NETXEN_HW_CRB_HUB_AGT_ADR_RPMX4, |
| 298 | NETXEN_HW_CRB_HUB_AGT_ADR_RPMX5, |
| 299 | NETXEN_HW_CRB_HUB_AGT_ADR_RPMX6, |
| 300 | NETXEN_HW_CRB_HUB_AGT_ADR_RPMX7, |
| 301 | NETXEN_HW_CRB_HUB_AGT_ADR_XDMA, |
| 302 | NETXEN_HW_CRB_HUB_AGT_ADR_I2Q, |
| 303 | NETXEN_HW_CRB_HUB_AGT_ADR_ROMUSB, |
| 304 | 0, |
| 305 | NETXEN_HW_CRB_HUB_AGT_ADR_RPMX0, |
| 306 | NETXEN_HW_CRB_HUB_AGT_ADR_RPMX8, |
| 307 | NETXEN_HW_CRB_HUB_AGT_ADR_RPMX9, |
| 308 | NETXEN_HW_CRB_HUB_AGT_ADR_OCM0, |
| 309 | 0, |
| 310 | NETXEN_HW_CRB_HUB_AGT_ADR_SMB, |
| 311 | NETXEN_HW_CRB_HUB_AGT_ADR_I2C0, |
| 312 | NETXEN_HW_CRB_HUB_AGT_ADR_I2C1, |
| 313 | 0, |
| 314 | NETXEN_HW_CRB_HUB_AGT_ADR_PGNC, |
| 315 | 0, |
| 316 | }; |
| 317 | |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 318 | /* PCI Windowing for DDR regions. */ |
| 319 | |
Dhananjay Phadke | 3ce06a3 | 2008-07-21 19:44:03 -0700 | [diff] [blame] | 320 | #define NETXEN_WINDOW_ONE 0x2000000 /*CRB Window: bit 25 of CRB address */ |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 321 | |
Dhananjay Phadke | c9517e5 | 2009-08-24 19:23:26 +0000 | [diff] [blame] | 322 | #define NETXEN_PCIE_SEM_TIMEOUT 10000 |
| 323 | |
| 324 | int |
| 325 | netxen_pcie_sem_lock(struct netxen_adapter *adapter, int sem, u32 id_reg) |
| 326 | { |
| 327 | int done = 0, timeout = 0; |
| 328 | |
| 329 | while (!done) { |
| 330 | done = NXRD32(adapter, NETXEN_PCIE_REG(PCIE_SEM_LOCK(sem))); |
| 331 | if (done == 1) |
| 332 | break; |
| 333 | if (++timeout >= NETXEN_PCIE_SEM_TIMEOUT) |
| 334 | return -1; |
| 335 | msleep(1); |
| 336 | } |
| 337 | |
| 338 | if (id_reg) |
| 339 | NXWR32(adapter, id_reg, adapter->portnum); |
| 340 | |
| 341 | return 0; |
| 342 | } |
| 343 | |
| 344 | void |
| 345 | netxen_pcie_sem_unlock(struct netxen_adapter *adapter, int sem) |
| 346 | { |
| 347 | int val; |
| 348 | val = NXRD32(adapter, NETXEN_PCIE_REG(PCIE_SEM_UNLOCK(sem))); |
| 349 | } |
| 350 | |
Dhananjay Phadke | 3ad4467 | 2009-08-24 19:23:27 +0000 | [diff] [blame^] | 351 | int netxen_niu_xg_init_port(struct netxen_adapter *adapter, int port) |
| 352 | { |
| 353 | if (NX_IS_REVISION_P2(adapter->ahw.revision_id)) { |
| 354 | NXWR32(adapter, NETXEN_NIU_XGE_CONFIG_1+(0x10000*port), 0x1447); |
| 355 | NXWR32(adapter, NETXEN_NIU_XGE_CONFIG_0+(0x10000*port), 0x5); |
| 356 | } |
| 357 | |
| 358 | return 0; |
| 359 | } |
| 360 | |
| 361 | /* Disable an XG interface */ |
| 362 | int netxen_niu_disable_xg_port(struct netxen_adapter *adapter) |
| 363 | { |
| 364 | __u32 mac_cfg; |
| 365 | u32 port = adapter->physical_port; |
| 366 | |
| 367 | if (NX_IS_REVISION_P3(adapter->ahw.revision_id)) |
| 368 | return 0; |
| 369 | |
| 370 | if (port > NETXEN_NIU_MAX_XG_PORTS) |
| 371 | return -EINVAL; |
| 372 | |
| 373 | mac_cfg = 0; |
| 374 | if (NXWR32(adapter, |
| 375 | NETXEN_NIU_XGE_CONFIG_0 + (0x10000 * port), mac_cfg)) |
| 376 | return -EIO; |
| 377 | return 0; |
| 378 | } |
| 379 | |
Dhananjay Phadke | 623621b | 2008-07-21 19:44:01 -0700 | [diff] [blame] | 380 | #define NETXEN_UNICAST_ADDR(port, index) \ |
| 381 | (NETXEN_UNICAST_ADDR_BASE+(port*32)+(index*8)) |
| 382 | #define NETXEN_MCAST_ADDR(port, index) \ |
| 383 | (NETXEN_MULTICAST_ADDR_BASE+(port*0x80)+(index*8)) |
| 384 | #define MAC_HI(addr) \ |
| 385 | ((addr[2] << 16) | (addr[1] << 8) | (addr[0])) |
| 386 | #define MAC_LO(addr) \ |
| 387 | ((addr[5] << 16) | (addr[4] << 8) | (addr[3])) |
| 388 | |
Dhananjay Phadke | 3ad4467 | 2009-08-24 19:23:27 +0000 | [diff] [blame^] | 389 | int netxen_p2_nic_set_promisc(struct netxen_adapter *adapter, u32 mode) |
| 390 | { |
| 391 | __u32 reg; |
| 392 | u32 port = adapter->physical_port; |
| 393 | |
| 394 | if (port > NETXEN_NIU_MAX_XG_PORTS) |
| 395 | return -EINVAL; |
| 396 | |
| 397 | reg = NXRD32(adapter, NETXEN_NIU_XGE_CONFIG_1 + (0x10000 * port)); |
| 398 | if (mode == NETXEN_NIU_PROMISC_MODE) |
| 399 | reg = (reg | 0x2000UL); |
| 400 | else |
| 401 | reg = (reg & ~0x2000UL); |
| 402 | |
| 403 | if (mode == NETXEN_NIU_ALLMULTI_MODE) |
| 404 | reg = (reg | 0x1000UL); |
| 405 | else |
| 406 | reg = (reg & ~0x1000UL); |
| 407 | |
| 408 | NXWR32(adapter, NETXEN_NIU_XGE_CONFIG_1 + (0x10000 * port), reg); |
| 409 | |
| 410 | return 0; |
| 411 | } |
| 412 | |
| 413 | int netxen_p2_nic_set_mac_addr(struct netxen_adapter *adapter, u8 *addr) |
| 414 | { |
| 415 | u32 mac_hi, mac_lo; |
| 416 | u32 reg_hi, reg_lo; |
| 417 | |
| 418 | u8 phy = adapter->physical_port; |
| 419 | |
| 420 | if (phy >= NETXEN_NIU_MAX_XG_PORTS) |
| 421 | return -EINVAL; |
| 422 | |
| 423 | mac_lo = ((u32)addr[0] << 16) | ((u32)addr[1] << 24); |
| 424 | mac_hi = addr[2] | ((u32)addr[3] << 8) | |
| 425 | ((u32)addr[4] << 16) | ((u32)addr[5] << 24); |
| 426 | |
| 427 | reg_lo = NETXEN_NIU_XGE_STATION_ADDR_0_1 + (0x10000 * phy); |
| 428 | reg_hi = NETXEN_NIU_XGE_STATION_ADDR_0_HI + (0x10000 * phy); |
| 429 | |
| 430 | /* write twice to flush */ |
| 431 | if (NXWR32(adapter, reg_lo, mac_lo) || NXWR32(adapter, reg_hi, mac_hi)) |
| 432 | return -EIO; |
| 433 | if (NXWR32(adapter, reg_lo, mac_lo) || NXWR32(adapter, reg_hi, mac_hi)) |
| 434 | return -EIO; |
| 435 | |
| 436 | return 0; |
| 437 | } |
| 438 | |
Dhananjay Phadke | 623621b | 2008-07-21 19:44:01 -0700 | [diff] [blame] | 439 | static int |
| 440 | netxen_nic_enable_mcast_filter(struct netxen_adapter *adapter) |
| 441 | { |
| 442 | u32 val = 0; |
| 443 | u16 port = adapter->physical_port; |
| 444 | u8 *addr = adapter->netdev->dev_addr; |
| 445 | |
| 446 | if (adapter->mc_enabled) |
| 447 | return 0; |
| 448 | |
Dhananjay Phadke | f98a9f6 | 2009-04-07 22:50:45 +0000 | [diff] [blame] | 449 | val = NXRD32(adapter, NETXEN_MAC_ADDR_CNTL_REG); |
Dhananjay Phadke | 623621b | 2008-07-21 19:44:01 -0700 | [diff] [blame] | 450 | val |= (1UL << (28+port)); |
Dhananjay Phadke | f98a9f6 | 2009-04-07 22:50:45 +0000 | [diff] [blame] | 451 | NXWR32(adapter, NETXEN_MAC_ADDR_CNTL_REG, val); |
Dhananjay Phadke | 623621b | 2008-07-21 19:44:01 -0700 | [diff] [blame] | 452 | |
| 453 | /* add broadcast addr to filter */ |
| 454 | val = 0xffffff; |
Dhananjay Phadke | f98a9f6 | 2009-04-07 22:50:45 +0000 | [diff] [blame] | 455 | NXWR32(adapter, NETXEN_UNICAST_ADDR(port, 0), val); |
| 456 | NXWR32(adapter, NETXEN_UNICAST_ADDR(port, 0)+4, val); |
Dhananjay Phadke | 623621b | 2008-07-21 19:44:01 -0700 | [diff] [blame] | 457 | |
| 458 | /* add station addr to filter */ |
| 459 | val = MAC_HI(addr); |
Dhananjay Phadke | f98a9f6 | 2009-04-07 22:50:45 +0000 | [diff] [blame] | 460 | NXWR32(adapter, NETXEN_UNICAST_ADDR(port, 1), val); |
Dhananjay Phadke | 623621b | 2008-07-21 19:44:01 -0700 | [diff] [blame] | 461 | val = MAC_LO(addr); |
Dhananjay Phadke | f98a9f6 | 2009-04-07 22:50:45 +0000 | [diff] [blame] | 462 | NXWR32(adapter, NETXEN_UNICAST_ADDR(port, 1)+4, val); |
Dhananjay Phadke | 623621b | 2008-07-21 19:44:01 -0700 | [diff] [blame] | 463 | |
| 464 | adapter->mc_enabled = 1; |
| 465 | return 0; |
| 466 | } |
| 467 | |
| 468 | static int |
| 469 | netxen_nic_disable_mcast_filter(struct netxen_adapter *adapter) |
| 470 | { |
| 471 | u32 val = 0; |
| 472 | u16 port = adapter->physical_port; |
| 473 | u8 *addr = adapter->netdev->dev_addr; |
| 474 | |
| 475 | if (!adapter->mc_enabled) |
| 476 | return 0; |
| 477 | |
Dhananjay Phadke | f98a9f6 | 2009-04-07 22:50:45 +0000 | [diff] [blame] | 478 | val = NXRD32(adapter, NETXEN_MAC_ADDR_CNTL_REG); |
Dhananjay Phadke | 623621b | 2008-07-21 19:44:01 -0700 | [diff] [blame] | 479 | val &= ~(1UL << (28+port)); |
Dhananjay Phadke | f98a9f6 | 2009-04-07 22:50:45 +0000 | [diff] [blame] | 480 | NXWR32(adapter, NETXEN_MAC_ADDR_CNTL_REG, val); |
Dhananjay Phadke | 623621b | 2008-07-21 19:44:01 -0700 | [diff] [blame] | 481 | |
| 482 | val = MAC_HI(addr); |
Dhananjay Phadke | f98a9f6 | 2009-04-07 22:50:45 +0000 | [diff] [blame] | 483 | NXWR32(adapter, NETXEN_UNICAST_ADDR(port, 0), val); |
Dhananjay Phadke | 623621b | 2008-07-21 19:44:01 -0700 | [diff] [blame] | 484 | val = MAC_LO(addr); |
Dhananjay Phadke | f98a9f6 | 2009-04-07 22:50:45 +0000 | [diff] [blame] | 485 | NXWR32(adapter, NETXEN_UNICAST_ADDR(port, 0)+4, val); |
Dhananjay Phadke | 623621b | 2008-07-21 19:44:01 -0700 | [diff] [blame] | 486 | |
Dhananjay Phadke | f98a9f6 | 2009-04-07 22:50:45 +0000 | [diff] [blame] | 487 | NXWR32(adapter, NETXEN_UNICAST_ADDR(port, 1), 0); |
| 488 | NXWR32(adapter, NETXEN_UNICAST_ADDR(port, 1)+4, 0); |
Dhananjay Phadke | 623621b | 2008-07-21 19:44:01 -0700 | [diff] [blame] | 489 | |
| 490 | adapter->mc_enabled = 0; |
| 491 | return 0; |
| 492 | } |
| 493 | |
| 494 | static int |
| 495 | netxen_nic_set_mcast_addr(struct netxen_adapter *adapter, |
| 496 | int index, u8 *addr) |
| 497 | { |
| 498 | u32 hi = 0, lo = 0; |
| 499 | u16 port = adapter->physical_port; |
| 500 | |
| 501 | lo = MAC_LO(addr); |
| 502 | hi = MAC_HI(addr); |
| 503 | |
Dhananjay Phadke | f98a9f6 | 2009-04-07 22:50:45 +0000 | [diff] [blame] | 504 | NXWR32(adapter, NETXEN_MCAST_ADDR(port, index), hi); |
| 505 | NXWR32(adapter, NETXEN_MCAST_ADDR(port, index)+4, lo); |
Dhananjay Phadke | 623621b | 2008-07-21 19:44:01 -0700 | [diff] [blame] | 506 | |
| 507 | return 0; |
| 508 | } |
| 509 | |
Dhananjay Phadke | c9fc891 | 2008-07-21 19:44:07 -0700 | [diff] [blame] | 510 | void netxen_p2_nic_set_multi(struct net_device *netdev) |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 511 | { |
Mithlesh Thukral | 3176ff3 | 2007-04-20 07:52:37 -0700 | [diff] [blame] | 512 | struct netxen_adapter *adapter = netdev_priv(netdev); |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 513 | struct dev_mc_list *mc_ptr; |
Dhananjay Phadke | 623621b | 2008-07-21 19:44:01 -0700 | [diff] [blame] | 514 | u8 null_addr[6]; |
| 515 | int index = 0; |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 516 | |
Dhananjay Phadke | 623621b | 2008-07-21 19:44:01 -0700 | [diff] [blame] | 517 | memset(null_addr, 0, 6); |
| 518 | |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 519 | if (netdev->flags & IFF_PROMISC) { |
Dhananjay Phadke | 623621b | 2008-07-21 19:44:01 -0700 | [diff] [blame] | 520 | |
| 521 | adapter->set_promisc(adapter, |
| 522 | NETXEN_NIU_PROMISC_MODE); |
| 523 | |
| 524 | /* Full promiscuous mode */ |
| 525 | netxen_nic_disable_mcast_filter(adapter); |
| 526 | |
| 527 | return; |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 528 | } |
Dhananjay Phadke | 623621b | 2008-07-21 19:44:01 -0700 | [diff] [blame] | 529 | |
| 530 | if (netdev->mc_count == 0) { |
| 531 | adapter->set_promisc(adapter, |
| 532 | NETXEN_NIU_NON_PROMISC_MODE); |
| 533 | netxen_nic_disable_mcast_filter(adapter); |
| 534 | return; |
| 535 | } |
| 536 | |
| 537 | adapter->set_promisc(adapter, NETXEN_NIU_ALLMULTI_MODE); |
| 538 | if (netdev->flags & IFF_ALLMULTI || |
| 539 | netdev->mc_count > adapter->max_mc_count) { |
| 540 | netxen_nic_disable_mcast_filter(adapter); |
| 541 | return; |
| 542 | } |
| 543 | |
| 544 | netxen_nic_enable_mcast_filter(adapter); |
| 545 | |
| 546 | for (mc_ptr = netdev->mc_list; mc_ptr; mc_ptr = mc_ptr->next, index++) |
| 547 | netxen_nic_set_mcast_addr(adapter, index, mc_ptr->dmi_addr); |
| 548 | |
| 549 | if (index != netdev->mc_count) |
| 550 | printk(KERN_WARNING "%s: %s multicast address count mismatch\n", |
| 551 | netxen_nic_driver_name, netdev->name); |
| 552 | |
| 553 | /* Clear out remaining addresses */ |
| 554 | for (; index < adapter->max_mc_count; index++) |
| 555 | netxen_nic_set_mcast_addr(adapter, index, null_addr); |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 556 | } |
| 557 | |
Dhananjay Phadke | c9fc891 | 2008-07-21 19:44:07 -0700 | [diff] [blame] | 558 | static int |
| 559 | netxen_send_cmd_descs(struct netxen_adapter *adapter, |
Dhananjay Phadke | d877f1e | 2009-04-07 22:50:40 +0000 | [diff] [blame] | 560 | struct cmd_desc_type0 *cmd_desc_arr, int nr_desc) |
Dhananjay Phadke | c9fc891 | 2008-07-21 19:44:07 -0700 | [diff] [blame] | 561 | { |
Dhananjay Phadke | d877f1e | 2009-04-07 22:50:40 +0000 | [diff] [blame] | 562 | u32 i, producer, consumer; |
Dhananjay Phadke | c9fc891 | 2008-07-21 19:44:07 -0700 | [diff] [blame] | 563 | struct netxen_cmd_buffer *pbuf; |
| 564 | struct cmd_desc_type0 *cmd_desc; |
Dhananjay Phadke | d877f1e | 2009-04-07 22:50:40 +0000 | [diff] [blame] | 565 | struct nx_host_tx_ring *tx_ring; |
Dhananjay Phadke | c9fc891 | 2008-07-21 19:44:07 -0700 | [diff] [blame] | 566 | |
| 567 | i = 0; |
| 568 | |
Dhananjay Phadke | 4ea528a | 2009-04-28 15:29:10 +0000 | [diff] [blame] | 569 | tx_ring = adapter->tx_ring; |
Dhananjay Phadke | b2af9cb | 2009-07-17 15:27:07 +0000 | [diff] [blame] | 570 | __netif_tx_lock_bh(tx_ring->txq); |
Dhananjay Phadke | 03e678e | 2009-01-14 20:49:43 -0800 | [diff] [blame] | 571 | |
Dhananjay Phadke | d877f1e | 2009-04-07 22:50:40 +0000 | [diff] [blame] | 572 | producer = tx_ring->producer; |
| 573 | consumer = tx_ring->sw_consumer; |
| 574 | |
Dhananjay Phadke | b2af9cb | 2009-07-17 15:27:07 +0000 | [diff] [blame] | 575 | if (nr_desc >= netxen_tx_avail(tx_ring)) { |
| 576 | netif_tx_stop_queue(tx_ring->txq); |
| 577 | __netif_tx_unlock_bh(tx_ring->txq); |
Dhananjay Phadke | d877f1e | 2009-04-07 22:50:40 +0000 | [diff] [blame] | 578 | return -EBUSY; |
| 579 | } |
| 580 | |
Dhananjay Phadke | c9fc891 | 2008-07-21 19:44:07 -0700 | [diff] [blame] | 581 | do { |
| 582 | cmd_desc = &cmd_desc_arr[i]; |
| 583 | |
Dhananjay Phadke | d877f1e | 2009-04-07 22:50:40 +0000 | [diff] [blame] | 584 | pbuf = &tx_ring->cmd_buf_arr[producer]; |
Dhananjay Phadke | c9fc891 | 2008-07-21 19:44:07 -0700 | [diff] [blame] | 585 | pbuf->skb = NULL; |
Dhananjay Phadke | c9fc891 | 2008-07-21 19:44:07 -0700 | [diff] [blame] | 586 | pbuf->frag_count = 0; |
Dhananjay Phadke | c9fc891 | 2008-07-21 19:44:07 -0700 | [diff] [blame] | 587 | |
Dhananjay Phadke | d877f1e | 2009-04-07 22:50:40 +0000 | [diff] [blame] | 588 | memcpy(&tx_ring->desc_head[producer], |
Dhananjay Phadke | c9fc891 | 2008-07-21 19:44:07 -0700 | [diff] [blame] | 589 | &cmd_desc_arr[i], sizeof(struct cmd_desc_type0)); |
| 590 | |
Dhananjay Phadke | d877f1e | 2009-04-07 22:50:40 +0000 | [diff] [blame] | 591 | producer = get_next_index(producer, tx_ring->num_desc); |
Dhananjay Phadke | c9fc891 | 2008-07-21 19:44:07 -0700 | [diff] [blame] | 592 | i++; |
| 593 | |
Dhananjay Phadke | d877f1e | 2009-04-07 22:50:40 +0000 | [diff] [blame] | 594 | } while (i != nr_desc); |
Dhananjay Phadke | c9fc891 | 2008-07-21 19:44:07 -0700 | [diff] [blame] | 595 | |
Dhananjay Phadke | d877f1e | 2009-04-07 22:50:40 +0000 | [diff] [blame] | 596 | tx_ring->producer = producer; |
Dhananjay Phadke | c9fc891 | 2008-07-21 19:44:07 -0700 | [diff] [blame] | 597 | |
Dhananjay Phadke | cb2107b | 2009-06-17 17:27:25 +0000 | [diff] [blame] | 598 | netxen_nic_update_cmd_producer(adapter, tx_ring); |
Dhananjay Phadke | c9fc891 | 2008-07-21 19:44:07 -0700 | [diff] [blame] | 599 | |
Dhananjay Phadke | b2af9cb | 2009-07-17 15:27:07 +0000 | [diff] [blame] | 600 | __netif_tx_unlock_bh(tx_ring->txq); |
Dhananjay Phadke | 03e678e | 2009-01-14 20:49:43 -0800 | [diff] [blame] | 601 | |
Dhananjay Phadke | c9fc891 | 2008-07-21 19:44:07 -0700 | [diff] [blame] | 602 | return 0; |
| 603 | } |
| 604 | |
Dhananjay Phadke | 5cf4d32 | 2009-05-05 19:05:07 +0000 | [diff] [blame] | 605 | static int |
| 606 | nx_p3_sre_macaddr_change(struct netxen_adapter *adapter, u8 *addr, unsigned op) |
Dhananjay Phadke | c9fc891 | 2008-07-21 19:44:07 -0700 | [diff] [blame] | 607 | { |
Dhananjay Phadke | c9fc891 | 2008-07-21 19:44:07 -0700 | [diff] [blame] | 608 | nx_nic_req_t req; |
Dhananjay Phadke | 2edbb45 | 2009-01-14 20:47:30 -0800 | [diff] [blame] | 609 | nx_mac_req_t *mac_req; |
| 610 | u64 word; |
Dhananjay Phadke | c9fc891 | 2008-07-21 19:44:07 -0700 | [diff] [blame] | 611 | |
| 612 | memset(&req, 0, sizeof(nx_nic_req_t)); |
Dhananjay Phadke | 2edbb45 | 2009-01-14 20:47:30 -0800 | [diff] [blame] | 613 | req.qhdr = cpu_to_le64(NX_NIC_REQUEST << 23); |
| 614 | |
| 615 | word = NX_MAC_EVENT | ((u64)adapter->portnum << 16); |
| 616 | req.req_hdr = cpu_to_le64(word); |
| 617 | |
| 618 | mac_req = (nx_mac_req_t *)&req.words[0]; |
| 619 | mac_req->op = op; |
| 620 | memcpy(mac_req->mac_addr, addr, 6); |
Dhananjay Phadke | c9fc891 | 2008-07-21 19:44:07 -0700 | [diff] [blame] | 621 | |
Dhananjay Phadke | 5cf4d32 | 2009-05-05 19:05:07 +0000 | [diff] [blame] | 622 | return netxen_send_cmd_descs(adapter, (struct cmd_desc_type0 *)&req, 1); |
| 623 | } |
| 624 | |
| 625 | static int nx_p3_nic_add_mac(struct netxen_adapter *adapter, |
| 626 | u8 *addr, struct list_head *del_list) |
| 627 | { |
| 628 | struct list_head *head; |
| 629 | nx_mac_list_t *cur; |
| 630 | |
| 631 | /* look up if already exists */ |
| 632 | list_for_each(head, del_list) { |
| 633 | cur = list_entry(head, nx_mac_list_t, list); |
| 634 | |
| 635 | if (memcmp(addr, cur->mac_addr, ETH_ALEN) == 0) { |
| 636 | list_move_tail(head, &adapter->mac_list); |
| 637 | return 0; |
| 638 | } |
Dhananjay Phadke | c9fc891 | 2008-07-21 19:44:07 -0700 | [diff] [blame] | 639 | } |
| 640 | |
Dhananjay Phadke | 5cf4d32 | 2009-05-05 19:05:07 +0000 | [diff] [blame] | 641 | cur = kzalloc(sizeof(nx_mac_list_t), GFP_ATOMIC); |
| 642 | if (cur == NULL) { |
| 643 | printk(KERN_ERR "%s: failed to add mac address filter\n", |
| 644 | adapter->netdev->name); |
| 645 | return -ENOMEM; |
| 646 | } |
| 647 | memcpy(cur->mac_addr, addr, ETH_ALEN); |
| 648 | list_add_tail(&cur->list, &adapter->mac_list); |
| 649 | return nx_p3_sre_macaddr_change(adapter, |
| 650 | cur->mac_addr, NETXEN_MAC_ADD); |
Dhananjay Phadke | c9fc891 | 2008-07-21 19:44:07 -0700 | [diff] [blame] | 651 | } |
| 652 | |
| 653 | void netxen_p3_nic_set_multi(struct net_device *netdev) |
| 654 | { |
| 655 | struct netxen_adapter *adapter = netdev_priv(netdev); |
Dhananjay Phadke | c9fc891 | 2008-07-21 19:44:07 -0700 | [diff] [blame] | 656 | struct dev_mc_list *mc_ptr; |
| 657 | u8 bcast_addr[ETH_ALEN] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff }; |
Dhananjay Phadke | 9ad2764 | 2008-08-01 03:14:59 -0700 | [diff] [blame] | 658 | u32 mode = VPORT_MISS_MODE_DROP; |
Dhananjay Phadke | 5cf4d32 | 2009-05-05 19:05:07 +0000 | [diff] [blame] | 659 | LIST_HEAD(del_list); |
| 660 | struct list_head *head; |
| 661 | nx_mac_list_t *cur; |
Dhananjay Phadke | c9fc891 | 2008-07-21 19:44:07 -0700 | [diff] [blame] | 662 | |
Dhananjay Phadke | 5cf4d32 | 2009-05-05 19:05:07 +0000 | [diff] [blame] | 663 | list_splice_tail_init(&adapter->mac_list, &del_list); |
Dhananjay Phadke | c9fc891 | 2008-07-21 19:44:07 -0700 | [diff] [blame] | 664 | |
Dhananjay Phadke | 5cf4d32 | 2009-05-05 19:05:07 +0000 | [diff] [blame] | 665 | nx_p3_nic_add_mac(adapter, netdev->dev_addr, &del_list); |
| 666 | nx_p3_nic_add_mac(adapter, bcast_addr, &del_list); |
Dhananjay Phadke | 9ad2764 | 2008-08-01 03:14:59 -0700 | [diff] [blame] | 667 | |
| 668 | if (netdev->flags & IFF_PROMISC) { |
| 669 | mode = VPORT_MISS_MODE_ACCEPT_ALL; |
| 670 | goto send_fw_cmd; |
| 671 | } |
| 672 | |
| 673 | if ((netdev->flags & IFF_ALLMULTI) || |
| 674 | (netdev->mc_count > adapter->max_mc_count)) { |
| 675 | mode = VPORT_MISS_MODE_ACCEPT_MULTI; |
| 676 | goto send_fw_cmd; |
| 677 | } |
| 678 | |
Dhananjay Phadke | c9fc891 | 2008-07-21 19:44:07 -0700 | [diff] [blame] | 679 | if (netdev->mc_count > 0) { |
Dhananjay Phadke | c9fc891 | 2008-07-21 19:44:07 -0700 | [diff] [blame] | 680 | for (mc_ptr = netdev->mc_list; mc_ptr; |
| 681 | mc_ptr = mc_ptr->next) { |
Dhananjay Phadke | 5cf4d32 | 2009-05-05 19:05:07 +0000 | [diff] [blame] | 682 | nx_p3_nic_add_mac(adapter, mc_ptr->dmi_addr, &del_list); |
Dhananjay Phadke | c9fc891 | 2008-07-21 19:44:07 -0700 | [diff] [blame] | 683 | } |
| 684 | } |
Dhananjay Phadke | 9ad2764 | 2008-08-01 03:14:59 -0700 | [diff] [blame] | 685 | |
| 686 | send_fw_cmd: |
| 687 | adapter->set_promisc(adapter, mode); |
Dhananjay Phadke | 5cf4d32 | 2009-05-05 19:05:07 +0000 | [diff] [blame] | 688 | head = &del_list; |
| 689 | while (!list_empty(head)) { |
| 690 | cur = list_entry(head->next, nx_mac_list_t, list); |
| 691 | |
| 692 | nx_p3_sre_macaddr_change(adapter, |
| 693 | cur->mac_addr, NETXEN_MAC_DEL); |
| 694 | list_del(&cur->list); |
Dhananjay Phadke | c9fc891 | 2008-07-21 19:44:07 -0700 | [diff] [blame] | 695 | kfree(cur); |
Dhananjay Phadke | c9fc891 | 2008-07-21 19:44:07 -0700 | [diff] [blame] | 696 | } |
| 697 | } |
| 698 | |
Dhananjay Phadke | 9ad2764 | 2008-08-01 03:14:59 -0700 | [diff] [blame] | 699 | int netxen_p3_nic_set_promisc(struct netxen_adapter *adapter, u32 mode) |
| 700 | { |
| 701 | nx_nic_req_t req; |
Dhananjay Phadke | 2edbb45 | 2009-01-14 20:47:30 -0800 | [diff] [blame] | 702 | u64 word; |
Dhananjay Phadke | 9ad2764 | 2008-08-01 03:14:59 -0700 | [diff] [blame] | 703 | |
| 704 | memset(&req, 0, sizeof(nx_nic_req_t)); |
| 705 | |
Dhananjay Phadke | 2edbb45 | 2009-01-14 20:47:30 -0800 | [diff] [blame] | 706 | req.qhdr = cpu_to_le64(NX_HOST_REQUEST << 23); |
| 707 | |
| 708 | word = NX_NIC_H2C_OPCODE_PROXY_SET_VPORT_MISS_MODE | |
| 709 | ((u64)adapter->portnum << 16); |
| 710 | req.req_hdr = cpu_to_le64(word); |
| 711 | |
Dhananjay Phadke | 9ad2764 | 2008-08-01 03:14:59 -0700 | [diff] [blame] | 712 | req.words[0] = cpu_to_le64(mode); |
| 713 | |
| 714 | return netxen_send_cmd_descs(adapter, |
| 715 | (struct cmd_desc_type0 *)&req, 1); |
| 716 | } |
| 717 | |
Dhananjay Phadke | 06e9d9f | 2009-01-14 20:49:22 -0800 | [diff] [blame] | 718 | void netxen_p3_free_mac_list(struct netxen_adapter *adapter) |
| 719 | { |
Dhananjay Phadke | 5cf4d32 | 2009-05-05 19:05:07 +0000 | [diff] [blame] | 720 | nx_mac_list_t *cur; |
| 721 | struct list_head *head = &adapter->mac_list; |
Dhananjay Phadke | 06e9d9f | 2009-01-14 20:49:22 -0800 | [diff] [blame] | 722 | |
Dhananjay Phadke | 5cf4d32 | 2009-05-05 19:05:07 +0000 | [diff] [blame] | 723 | while (!list_empty(head)) { |
| 724 | cur = list_entry(head->next, nx_mac_list_t, list); |
| 725 | nx_p3_sre_macaddr_change(adapter, |
| 726 | cur->mac_addr, NETXEN_MAC_DEL); |
| 727 | list_del(&cur->list); |
Dhananjay Phadke | 06e9d9f | 2009-01-14 20:49:22 -0800 | [diff] [blame] | 728 | kfree(cur); |
Dhananjay Phadke | 06e9d9f | 2009-01-14 20:49:22 -0800 | [diff] [blame] | 729 | } |
| 730 | } |
| 731 | |
Dhananjay Phadke | 3d0a3cc | 2009-05-05 19:05:08 +0000 | [diff] [blame] | 732 | int netxen_p3_nic_set_mac_addr(struct netxen_adapter *adapter, u8 *addr) |
| 733 | { |
| 734 | /* assuming caller has already copied new addr to netdev */ |
| 735 | netxen_p3_nic_set_multi(adapter->netdev); |
| 736 | return 0; |
| 737 | } |
| 738 | |
Dhananjay Phadke | cd1f816 | 2008-07-21 19:44:09 -0700 | [diff] [blame] | 739 | #define NETXEN_CONFIG_INTR_COALESCE 3 |
| 740 | |
| 741 | /* |
| 742 | * Send the interrupt coalescing parameter set by ethtool to the card. |
| 743 | */ |
| 744 | int netxen_config_intr_coalesce(struct netxen_adapter *adapter) |
| 745 | { |
| 746 | nx_nic_req_t req; |
Dhananjay Phadke | 2edbb45 | 2009-01-14 20:47:30 -0800 | [diff] [blame] | 747 | u64 word; |
Dhananjay Phadke | cd1f816 | 2008-07-21 19:44:09 -0700 | [diff] [blame] | 748 | int rv; |
| 749 | |
| 750 | memset(&req, 0, sizeof(nx_nic_req_t)); |
| 751 | |
Narender Kumar | 1bb482f | 2009-08-23 08:35:09 +0000 | [diff] [blame] | 752 | req.qhdr = cpu_to_le64(NX_HOST_REQUEST << 23); |
Dhananjay Phadke | 2edbb45 | 2009-01-14 20:47:30 -0800 | [diff] [blame] | 753 | |
| 754 | word = NETXEN_CONFIG_INTR_COALESCE | ((u64)adapter->portnum << 16); |
| 755 | req.req_hdr = cpu_to_le64(word); |
Dhananjay Phadke | cd1f816 | 2008-07-21 19:44:09 -0700 | [diff] [blame] | 756 | |
| 757 | memcpy(&req.words[0], &adapter->coal, sizeof(adapter->coal)); |
| 758 | |
| 759 | rv = netxen_send_cmd_descs(adapter, (struct cmd_desc_type0 *)&req, 1); |
| 760 | if (rv != 0) { |
| 761 | printk(KERN_ERR "ERROR. Could not send " |
| 762 | "interrupt coalescing parameters\n"); |
| 763 | } |
| 764 | |
| 765 | return rv; |
| 766 | } |
| 767 | |
Narender Kumar | 1bb482f | 2009-08-23 08:35:09 +0000 | [diff] [blame] | 768 | int netxen_config_hw_lro(struct netxen_adapter *adapter, int enable) |
| 769 | { |
| 770 | nx_nic_req_t req; |
| 771 | u64 word; |
| 772 | int rv = 0; |
| 773 | |
| 774 | if ((adapter->flags & NETXEN_NIC_LRO_ENABLED) == enable) |
| 775 | return 0; |
| 776 | |
| 777 | memset(&req, 0, sizeof(nx_nic_req_t)); |
| 778 | |
| 779 | req.qhdr = cpu_to_le64(NX_HOST_REQUEST << 23); |
| 780 | |
| 781 | word = NX_NIC_H2C_OPCODE_CONFIG_HW_LRO | ((u64)adapter->portnum << 16); |
| 782 | req.req_hdr = cpu_to_le64(word); |
| 783 | |
| 784 | req.words[0] = cpu_to_le64(enable); |
| 785 | |
| 786 | rv = netxen_send_cmd_descs(adapter, (struct cmd_desc_type0 *)&req, 1); |
| 787 | if (rv != 0) { |
| 788 | printk(KERN_ERR "ERROR. Could not send " |
| 789 | "configure hw lro request\n"); |
| 790 | } |
| 791 | |
| 792 | adapter->flags ^= NETXEN_NIC_LRO_ENABLED; |
| 793 | |
| 794 | return rv; |
| 795 | } |
| 796 | |
Dhananjay Phadke | d8b100c | 2009-03-13 14:52:05 +0000 | [diff] [blame] | 797 | #define RSS_HASHTYPE_IP_TCP 0x3 |
| 798 | |
| 799 | int netxen_config_rss(struct netxen_adapter *adapter, int enable) |
| 800 | { |
| 801 | nx_nic_req_t req; |
| 802 | u64 word; |
| 803 | int i, rv; |
| 804 | |
| 805 | u64 key[] = { 0xbeac01fa6a42b73bULL, 0x8030f20c77cb2da3ULL, |
| 806 | 0xae7b30b4d0ca2bcbULL, 0x43a38fb04167253dULL, |
| 807 | 0x255b0ec26d5a56daULL }; |
| 808 | |
| 809 | |
| 810 | memset(&req, 0, sizeof(nx_nic_req_t)); |
| 811 | req.qhdr = cpu_to_le64(NX_HOST_REQUEST << 23); |
| 812 | |
| 813 | word = NX_NIC_H2C_OPCODE_CONFIG_RSS | ((u64)adapter->portnum << 16); |
| 814 | req.req_hdr = cpu_to_le64(word); |
| 815 | |
| 816 | /* |
| 817 | * RSS request: |
| 818 | * bits 3-0: hash_method |
| 819 | * 5-4: hash_type_ipv4 |
| 820 | * 7-6: hash_type_ipv6 |
| 821 | * 8: enable |
| 822 | * 9: use indirection table |
| 823 | * 47-10: reserved |
| 824 | * 63-48: indirection table mask |
| 825 | */ |
| 826 | word = ((u64)(RSS_HASHTYPE_IP_TCP & 0x3) << 4) | |
| 827 | ((u64)(RSS_HASHTYPE_IP_TCP & 0x3) << 6) | |
| 828 | ((u64)(enable & 0x1) << 8) | |
| 829 | ((0x7ULL) << 48); |
| 830 | req.words[0] = cpu_to_le64(word); |
| 831 | for (i = 0; i < 5; i++) |
| 832 | req.words[i+1] = cpu_to_le64(key[i]); |
| 833 | |
| 834 | |
| 835 | rv = netxen_send_cmd_descs(adapter, (struct cmd_desc_type0 *)&req, 1); |
| 836 | if (rv != 0) { |
| 837 | printk(KERN_ERR "%s: could not configure RSS\n", |
| 838 | adapter->netdev->name); |
| 839 | } |
| 840 | |
| 841 | return rv; |
| 842 | } |
| 843 | |
Dhananjay Phadke | 6598b16 | 2009-07-26 20:07:37 +0000 | [diff] [blame] | 844 | int netxen_config_ipaddr(struct netxen_adapter *adapter, u32 ip, int cmd) |
| 845 | { |
| 846 | nx_nic_req_t req; |
| 847 | u64 word; |
| 848 | int rv; |
| 849 | |
| 850 | memset(&req, 0, sizeof(nx_nic_req_t)); |
| 851 | req.qhdr = cpu_to_le64(NX_HOST_REQUEST << 23); |
| 852 | |
| 853 | word = NX_NIC_H2C_OPCODE_CONFIG_IPADDR | ((u64)adapter->portnum << 16); |
| 854 | req.req_hdr = cpu_to_le64(word); |
| 855 | |
| 856 | req.words[0] = cpu_to_le64(cmd); |
| 857 | req.words[1] = cpu_to_le64(ip); |
| 858 | |
| 859 | rv = netxen_send_cmd_descs(adapter, (struct cmd_desc_type0 *)&req, 1); |
| 860 | if (rv != 0) { |
| 861 | printk(KERN_ERR "%s: could not notify %s IP 0x%x reuqest\n", |
| 862 | adapter->netdev->name, |
| 863 | (cmd == NX_IP_UP) ? "Add" : "Remove", ip); |
| 864 | } |
| 865 | return rv; |
| 866 | } |
| 867 | |
Dhananjay Phadke | 3bf26ce | 2009-04-07 22:50:42 +0000 | [diff] [blame] | 868 | int netxen_linkevent_request(struct netxen_adapter *adapter, int enable) |
| 869 | { |
| 870 | nx_nic_req_t req; |
| 871 | u64 word; |
| 872 | int rv; |
| 873 | |
| 874 | memset(&req, 0, sizeof(nx_nic_req_t)); |
| 875 | req.qhdr = cpu_to_le64(NX_HOST_REQUEST << 23); |
| 876 | |
| 877 | word = NX_NIC_H2C_OPCODE_GET_LINKEVENT | ((u64)adapter->portnum << 16); |
| 878 | req.req_hdr = cpu_to_le64(word); |
Dhananjay Phadke | 2252786 | 2009-05-05 19:05:06 +0000 | [diff] [blame] | 879 | req.words[0] = cpu_to_le64(enable | (enable << 8)); |
Dhananjay Phadke | 3bf26ce | 2009-04-07 22:50:42 +0000 | [diff] [blame] | 880 | |
| 881 | rv = netxen_send_cmd_descs(adapter, (struct cmd_desc_type0 *)&req, 1); |
| 882 | if (rv != 0) { |
| 883 | printk(KERN_ERR "%s: could not configure link notification\n", |
| 884 | adapter->netdev->name); |
| 885 | } |
| 886 | |
| 887 | return rv; |
| 888 | } |
| 889 | |
Narender Kumar | 1bb482f | 2009-08-23 08:35:09 +0000 | [diff] [blame] | 890 | int netxen_send_lro_cleanup(struct netxen_adapter *adapter) |
| 891 | { |
| 892 | nx_nic_req_t req; |
| 893 | u64 word; |
| 894 | int rv; |
| 895 | |
| 896 | memset(&req, 0, sizeof(nx_nic_req_t)); |
| 897 | req.qhdr = cpu_to_le64(NX_HOST_REQUEST << 23); |
| 898 | |
| 899 | word = NX_NIC_H2C_OPCODE_LRO_REQUEST | |
| 900 | ((u64)adapter->portnum << 16) | |
| 901 | ((u64)NX_NIC_LRO_REQUEST_CLEANUP << 56) ; |
| 902 | |
| 903 | req.req_hdr = cpu_to_le64(word); |
| 904 | |
| 905 | rv = netxen_send_cmd_descs(adapter, (struct cmd_desc_type0 *)&req, 1); |
| 906 | if (rv != 0) { |
| 907 | printk(KERN_ERR "%s: could not cleanup lro flows\n", |
| 908 | adapter->netdev->name); |
| 909 | } |
| 910 | return rv; |
| 911 | } |
| 912 | |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 913 | /* |
| 914 | * netxen_nic_change_mtu - Change the Maximum Transfer Unit |
| 915 | * @returns 0 on success, negative on failure |
| 916 | */ |
Dhananjay Phadke | c9fc891 | 2008-07-21 19:44:07 -0700 | [diff] [blame] | 917 | |
| 918 | #define MTU_FUDGE_FACTOR 100 |
| 919 | |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 920 | int netxen_nic_change_mtu(struct net_device *netdev, int mtu) |
| 921 | { |
Mithlesh Thukral | 3176ff3 | 2007-04-20 07:52:37 -0700 | [diff] [blame] | 922 | struct netxen_adapter *adapter = netdev_priv(netdev); |
Dhananjay Phadke | c9fc891 | 2008-07-21 19:44:07 -0700 | [diff] [blame] | 923 | int max_mtu; |
Dhananjay Phadke | 9ad2764 | 2008-08-01 03:14:59 -0700 | [diff] [blame] | 924 | int rc = 0; |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 925 | |
Dhananjay Phadke | c9fc891 | 2008-07-21 19:44:07 -0700 | [diff] [blame] | 926 | if (NX_IS_REVISION_P3(adapter->ahw.revision_id)) |
| 927 | max_mtu = P3_MAX_MTU; |
| 928 | else |
| 929 | max_mtu = P2_MAX_MTU; |
| 930 | |
| 931 | if (mtu > max_mtu) { |
| 932 | printk(KERN_ERR "%s: mtu > %d bytes unsupported\n", |
| 933 | netdev->name, max_mtu); |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 934 | return -EINVAL; |
| 935 | } |
| 936 | |
Amit S. Kale | 80922fb | 2006-12-04 09:18:00 -0800 | [diff] [blame] | 937 | if (adapter->set_mtu) |
Dhananjay Phadke | 9ad2764 | 2008-08-01 03:14:59 -0700 | [diff] [blame] | 938 | rc = adapter->set_mtu(adapter, mtu); |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 939 | |
Dhananjay Phadke | 9ad2764 | 2008-08-01 03:14:59 -0700 | [diff] [blame] | 940 | if (!rc) |
| 941 | netdev->mtu = mtu; |
Dhananjay Phadke | c9fc891 | 2008-07-21 19:44:07 -0700 | [diff] [blame] | 942 | |
Dhananjay Phadke | 9ad2764 | 2008-08-01 03:14:59 -0700 | [diff] [blame] | 943 | return rc; |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 944 | } |
| 945 | |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 946 | static int netxen_get_flash_block(struct netxen_adapter *adapter, int base, |
Al Viro | f305f78 | 2007-12-22 19:44:00 +0000 | [diff] [blame] | 947 | int size, __le32 * buf) |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 948 | { |
Dhananjay Phadke | 1e2d005 | 2009-03-09 08:50:56 +0000 | [diff] [blame] | 949 | int i, v, addr; |
Al Viro | f305f78 | 2007-12-22 19:44:00 +0000 | [diff] [blame] | 950 | __le32 *ptr32; |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 951 | |
| 952 | addr = base; |
| 953 | ptr32 = buf; |
| 954 | for (i = 0; i < size / sizeof(u32); i++) { |
Al Viro | f305f78 | 2007-12-22 19:44:00 +0000 | [diff] [blame] | 955 | if (netxen_rom_fast_read(adapter, addr, &v) == -1) |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 956 | return -1; |
Al Viro | f305f78 | 2007-12-22 19:44:00 +0000 | [diff] [blame] | 957 | *ptr32 = cpu_to_le32(v); |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 958 | ptr32++; |
| 959 | addr += sizeof(u32); |
| 960 | } |
| 961 | if ((char *)buf + size > (char *)ptr32) { |
Al Viro | f305f78 | 2007-12-22 19:44:00 +0000 | [diff] [blame] | 962 | __le32 local; |
| 963 | if (netxen_rom_fast_read(adapter, addr, &v) == -1) |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 964 | return -1; |
Al Viro | f305f78 | 2007-12-22 19:44:00 +0000 | [diff] [blame] | 965 | local = cpu_to_le32(v); |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 966 | memcpy(ptr32, &local, (char *)buf + size - (char *)ptr32); |
| 967 | } |
| 968 | |
| 969 | return 0; |
| 970 | } |
| 971 | |
Dhananjay Phadke | 9dc28ef | 2008-08-08 00:08:39 -0700 | [diff] [blame] | 972 | int netxen_get_flash_mac_addr(struct netxen_adapter *adapter, __le64 *mac) |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 973 | { |
Dhananjay Phadke | 9dc28ef | 2008-08-08 00:08:39 -0700 | [diff] [blame] | 974 | __le32 *pmac = (__le32 *) mac; |
| 975 | u32 offset; |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 976 | |
Dhananjay Phadke | 06db58c | 2009-08-05 07:34:08 +0000 | [diff] [blame] | 977 | offset = NX_FW_MAC_ADDR_OFFSET + (adapter->portnum * sizeof(u64)); |
Dhananjay Phadke | 9dc28ef | 2008-08-08 00:08:39 -0700 | [diff] [blame] | 978 | |
| 979 | if (netxen_get_flash_block(adapter, offset, sizeof(u64), pmac) == -1) |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 980 | return -1; |
Dhananjay Phadke | 9dc28ef | 2008-08-08 00:08:39 -0700 | [diff] [blame] | 981 | |
Al Viro | f305f78 | 2007-12-22 19:44:00 +0000 | [diff] [blame] | 982 | if (*mac == cpu_to_le64(~0ULL)) { |
Dhananjay Phadke | 9dc28ef | 2008-08-08 00:08:39 -0700 | [diff] [blame] | 983 | |
Dhananjay Phadke | 06db58c | 2009-08-05 07:34:08 +0000 | [diff] [blame] | 984 | offset = NX_OLD_MAC_ADDR_OFFSET + |
| 985 | (adapter->portnum * sizeof(u64)); |
Dhananjay Phadke | 9dc28ef | 2008-08-08 00:08:39 -0700 | [diff] [blame] | 986 | |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 987 | if (netxen_get_flash_block(adapter, |
Dhananjay Phadke | 9dc28ef | 2008-08-08 00:08:39 -0700 | [diff] [blame] | 988 | offset, sizeof(u64), pmac) == -1) |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 989 | return -1; |
Dhananjay Phadke | 9dc28ef | 2008-08-08 00:08:39 -0700 | [diff] [blame] | 990 | |
Al Viro | f305f78 | 2007-12-22 19:44:00 +0000 | [diff] [blame] | 991 | if (*mac == cpu_to_le64(~0ULL)) |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 992 | return -1; |
| 993 | } |
| 994 | return 0; |
| 995 | } |
| 996 | |
Dhananjay Phadke | 9dc28ef | 2008-08-08 00:08:39 -0700 | [diff] [blame] | 997 | int netxen_p3_get_mac_addr(struct netxen_adapter *adapter, __le64 *mac) |
| 998 | { |
| 999 | uint32_t crbaddr, mac_hi, mac_lo; |
| 1000 | int pci_func = adapter->ahw.pci_func; |
| 1001 | |
| 1002 | crbaddr = CRB_MAC_BLOCK_START + |
| 1003 | (4 * ((pci_func/2) * 3)) + (4 * (pci_func & 1)); |
| 1004 | |
Dhananjay Phadke | f98a9f6 | 2009-04-07 22:50:45 +0000 | [diff] [blame] | 1005 | mac_lo = NXRD32(adapter, crbaddr); |
| 1006 | mac_hi = NXRD32(adapter, crbaddr+4); |
Dhananjay Phadke | 9dc28ef | 2008-08-08 00:08:39 -0700 | [diff] [blame] | 1007 | |
Dhananjay Phadke | 9dc28ef | 2008-08-08 00:08:39 -0700 | [diff] [blame] | 1008 | if (pci_func & 1) |
Dhananjay Phadke | 2edbb45 | 2009-01-14 20:47:30 -0800 | [diff] [blame] | 1009 | *mac = le64_to_cpu((mac_lo >> 16) | ((u64)mac_hi << 16)); |
Dhananjay Phadke | 9dc28ef | 2008-08-08 00:08:39 -0700 | [diff] [blame] | 1010 | else |
Dhananjay Phadke | 2edbb45 | 2009-01-14 20:47:30 -0800 | [diff] [blame] | 1011 | *mac = le64_to_cpu((u64)mac_lo | ((u64)mac_hi << 32)); |
Dhananjay Phadke | 9dc28ef | 2008-08-08 00:08:39 -0700 | [diff] [blame] | 1012 | |
| 1013 | return 0; |
| 1014 | } |
| 1015 | |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 1016 | /* |
| 1017 | * Changes the CRB window to the specified window. |
| 1018 | */ |
Dhananjay Phadke | 3ce06a3 | 2008-07-21 19:44:03 -0700 | [diff] [blame] | 1019 | void |
| 1020 | netxen_nic_pci_change_crbwindow_128M(struct netxen_adapter *adapter, u32 wndw) |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 1021 | { |
| 1022 | void __iomem *offset; |
| 1023 | u32 tmp; |
| 1024 | int count = 0; |
Dhananjay Phadke | e4c93c8 | 2008-07-21 19:44:02 -0700 | [diff] [blame] | 1025 | uint8_t func = adapter->ahw.pci_func; |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 1026 | |
| 1027 | if (adapter->curr_window == wndw) |
| 1028 | return; |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 1029 | /* |
| 1030 | * Move the CRB window. |
| 1031 | * We need to write to the "direct access" region of PCI |
| 1032 | * to avoid a race condition where the window register has |
| 1033 | * not been successfully written across CRB before the target |
| 1034 | * register address is received by PCI. The direct region bypasses |
| 1035 | * the CRB bus. |
| 1036 | */ |
Dhananjay Phadke | e4c93c8 | 2008-07-21 19:44:02 -0700 | [diff] [blame] | 1037 | offset = PCI_OFFSET_SECOND_RANGE(adapter, |
| 1038 | NETXEN_PCIX_PH_REG(PCIE_CRB_WINDOW_REG(func))); |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 1039 | |
| 1040 | if (wndw & 0x1) |
| 1041 | wndw = NETXEN_WINDOW_ONE; |
| 1042 | |
| 1043 | writel(wndw, offset); |
| 1044 | |
| 1045 | /* MUST make sure window is set before we forge on... */ |
| 1046 | while ((tmp = readl(offset)) != wndw) { |
| 1047 | printk(KERN_WARNING "%s: %s WARNING: CRB window value not " |
| 1048 | "registered properly: 0x%08x.\n", |
Dhananjay Phadke | 3ce06a3 | 2008-07-21 19:44:03 -0700 | [diff] [blame] | 1049 | netxen_nic_driver_name, __func__, tmp); |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 1050 | mdelay(1); |
| 1051 | if (count >= 10) |
| 1052 | break; |
| 1053 | count++; |
| 1054 | } |
| 1055 | |
Mithlesh Thukral | 6c80b18 | 2007-04-20 07:55:26 -0700 | [diff] [blame] | 1056 | if (wndw == NETXEN_WINDOW_ONE) |
| 1057 | adapter->curr_window = 1; |
| 1058 | else |
| 1059 | adapter->curr_window = 0; |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 1060 | } |
| 1061 | |
Dhananjay Phadke | 3ce06a3 | 2008-07-21 19:44:03 -0700 | [diff] [blame] | 1062 | /* |
| 1063 | * Return -1 if off is not valid, |
| 1064 | * 1 if window access is needed. 'off' is set to offset from |
| 1065 | * CRB space in 128M pci map |
| 1066 | * 0 if no window access is needed. 'off' is set to 2M addr |
| 1067 | * In: 'off' is offset from base in 128M pci map |
| 1068 | */ |
| 1069 | static int |
Dhananjay Phadke | 23b6cc4 | 2009-05-08 22:02:30 +0000 | [diff] [blame] | 1070 | netxen_nic_pci_get_crb_addr_2M(struct netxen_adapter *adapter, ulong *off) |
Dhananjay Phadke | 3ce06a3 | 2008-07-21 19:44:03 -0700 | [diff] [blame] | 1071 | { |
Dhananjay Phadke | 3ce06a3 | 2008-07-21 19:44:03 -0700 | [diff] [blame] | 1072 | crb_128M_2M_sub_block_map_t *m; |
| 1073 | |
| 1074 | |
| 1075 | if (*off >= NETXEN_CRB_MAX) |
| 1076 | return -1; |
| 1077 | |
Dhananjay Phadke | 23b6cc4 | 2009-05-08 22:02:30 +0000 | [diff] [blame] | 1078 | if (*off >= NETXEN_PCI_CAMQM && (*off < NETXEN_PCI_CAMQM_2M_END)) { |
Dhananjay Phadke | 3ce06a3 | 2008-07-21 19:44:03 -0700 | [diff] [blame] | 1079 | *off = (*off - NETXEN_PCI_CAMQM) + NETXEN_PCI_CAMQM_2M_BASE + |
| 1080 | (ulong)adapter->ahw.pci_base0; |
| 1081 | return 0; |
| 1082 | } |
| 1083 | |
| 1084 | if (*off < NETXEN_PCI_CRBSPACE) |
| 1085 | return -1; |
| 1086 | |
| 1087 | *off -= NETXEN_PCI_CRBSPACE; |
Dhananjay Phadke | 3ce06a3 | 2008-07-21 19:44:03 -0700 | [diff] [blame] | 1088 | |
| 1089 | /* |
| 1090 | * Try direct map |
| 1091 | */ |
| 1092 | m = &crb_128M_2M_map[CRB_BLK(*off)].sub_block[CRB_SUBBLK(*off)]; |
| 1093 | |
Dhananjay Phadke | 23b6cc4 | 2009-05-08 22:02:30 +0000 | [diff] [blame] | 1094 | if (m->valid && (m->start_128M <= *off) && (m->end_128M > *off)) { |
Dhananjay Phadke | 3ce06a3 | 2008-07-21 19:44:03 -0700 | [diff] [blame] | 1095 | *off = *off + m->start_2M - m->start_128M + |
| 1096 | (ulong)adapter->ahw.pci_base0; |
| 1097 | return 0; |
| 1098 | } |
| 1099 | |
| 1100 | /* |
| 1101 | * Not in direct map, use crb window |
| 1102 | */ |
| 1103 | return 1; |
| 1104 | } |
| 1105 | |
| 1106 | /* |
| 1107 | * In: 'off' is offset from CRB space in 128M pci map |
| 1108 | * Out: 'off' is 2M pci map addr |
| 1109 | * side effect: lock crb window |
| 1110 | */ |
| 1111 | static void |
| 1112 | netxen_nic_pci_set_crbwindow_2M(struct netxen_adapter *adapter, ulong *off) |
| 1113 | { |
| 1114 | u32 win_read; |
| 1115 | |
| 1116 | adapter->crb_win = CRB_HI(*off); |
Dhananjay Phadke | d8313ce | 2009-02-17 20:26:44 -0800 | [diff] [blame] | 1117 | writel(adapter->crb_win, (adapter->ahw.pci_base0 + CRB_WINDOW_2M)); |
Dhananjay Phadke | 3ce06a3 | 2008-07-21 19:44:03 -0700 | [diff] [blame] | 1118 | /* |
| 1119 | * Read back value to make sure write has gone through before trying |
| 1120 | * to use it. |
| 1121 | */ |
Dhananjay Phadke | d8313ce | 2009-02-17 20:26:44 -0800 | [diff] [blame] | 1122 | win_read = readl(adapter->ahw.pci_base0 + CRB_WINDOW_2M); |
Dhananjay Phadke | 3ce06a3 | 2008-07-21 19:44:03 -0700 | [diff] [blame] | 1123 | if (win_read != adapter->crb_win) { |
| 1124 | printk(KERN_ERR "%s: Written crbwin (0x%x) != " |
| 1125 | "Read crbwin (0x%x), off=0x%lx\n", |
| 1126 | __func__, adapter->crb_win, win_read, *off); |
| 1127 | } |
| 1128 | *off = (*off & MASK(16)) + CRB_INDIRECT_2M + |
| 1129 | (ulong)adapter->ahw.pci_base0; |
| 1130 | } |
| 1131 | |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 1132 | int |
Dhananjay Phadke | 1fbe632 | 2009-04-07 22:50:44 +0000 | [diff] [blame] | 1133 | netxen_nic_hw_write_wx_128M(struct netxen_adapter *adapter, ulong off, u32 data) |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 1134 | { |
| 1135 | void __iomem *addr; |
| 1136 | |
| 1137 | if (ADDR_IN_WINDOW1(off)) { |
| 1138 | addr = NETXEN_CRB_NORMALIZE(adapter, off); |
| 1139 | } else { /* Window 0 */ |
Amit S. Kale | cb8011a | 2006-11-29 09:00:10 -0800 | [diff] [blame] | 1140 | addr = pci_base_offset(adapter, off); |
Dhananjay Phadke | 3ce06a3 | 2008-07-21 19:44:03 -0700 | [diff] [blame] | 1141 | netxen_nic_pci_change_crbwindow_128M(adapter, 0); |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 1142 | } |
| 1143 | |
Amit S. Kale | cb8011a | 2006-11-29 09:00:10 -0800 | [diff] [blame] | 1144 | if (!addr) { |
Dhananjay Phadke | 3ce06a3 | 2008-07-21 19:44:03 -0700 | [diff] [blame] | 1145 | netxen_nic_pci_change_crbwindow_128M(adapter, 1); |
Amit S. Kale | cb8011a | 2006-11-29 09:00:10 -0800 | [diff] [blame] | 1146 | return 1; |
| 1147 | } |
| 1148 | |
Dhananjay Phadke | 1fbe632 | 2009-04-07 22:50:44 +0000 | [diff] [blame] | 1149 | writel(data, addr); |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 1150 | |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 1151 | if (!ADDR_IN_WINDOW1(off)) |
Dhananjay Phadke | 3ce06a3 | 2008-07-21 19:44:03 -0700 | [diff] [blame] | 1152 | netxen_nic_pci_change_crbwindow_128M(adapter, 1); |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 1153 | |
| 1154 | return 0; |
| 1155 | } |
| 1156 | |
Dhananjay Phadke | 1fbe632 | 2009-04-07 22:50:44 +0000 | [diff] [blame] | 1157 | u32 |
| 1158 | netxen_nic_hw_read_wx_128M(struct netxen_adapter *adapter, ulong off) |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 1159 | { |
| 1160 | void __iomem *addr; |
Dhananjay Phadke | 1fbe632 | 2009-04-07 22:50:44 +0000 | [diff] [blame] | 1161 | u32 data; |
Dhananjay Phadke | d8313ce | 2009-02-17 20:26:44 -0800 | [diff] [blame] | 1162 | |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 1163 | if (ADDR_IN_WINDOW1(off)) { /* Window 1 */ |
| 1164 | addr = NETXEN_CRB_NORMALIZE(adapter, off); |
| 1165 | } else { /* Window 0 */ |
Amit S. Kale | cb8011a | 2006-11-29 09:00:10 -0800 | [diff] [blame] | 1166 | addr = pci_base_offset(adapter, off); |
Dhananjay Phadke | 3ce06a3 | 2008-07-21 19:44:03 -0700 | [diff] [blame] | 1167 | netxen_nic_pci_change_crbwindow_128M(adapter, 0); |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 1168 | } |
| 1169 | |
Amit S. Kale | cb8011a | 2006-11-29 09:00:10 -0800 | [diff] [blame] | 1170 | if (!addr) { |
Dhananjay Phadke | 3ce06a3 | 2008-07-21 19:44:03 -0700 | [diff] [blame] | 1171 | netxen_nic_pci_change_crbwindow_128M(adapter, 1); |
Amit S. Kale | cb8011a | 2006-11-29 09:00:10 -0800 | [diff] [blame] | 1172 | return 1; |
| 1173 | } |
Dhananjay Phadke | d8313ce | 2009-02-17 20:26:44 -0800 | [diff] [blame] | 1174 | |
Dhananjay Phadke | 1fbe632 | 2009-04-07 22:50:44 +0000 | [diff] [blame] | 1175 | data = readl(addr); |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 1176 | |
| 1177 | if (!ADDR_IN_WINDOW1(off)) |
Dhananjay Phadke | 3ce06a3 | 2008-07-21 19:44:03 -0700 | [diff] [blame] | 1178 | netxen_nic_pci_change_crbwindow_128M(adapter, 1); |
| 1179 | |
Dhananjay Phadke | 1fbe632 | 2009-04-07 22:50:44 +0000 | [diff] [blame] | 1180 | return data; |
Dhananjay Phadke | 3ce06a3 | 2008-07-21 19:44:03 -0700 | [diff] [blame] | 1181 | } |
| 1182 | |
| 1183 | int |
Dhananjay Phadke | 1fbe632 | 2009-04-07 22:50:44 +0000 | [diff] [blame] | 1184 | netxen_nic_hw_write_wx_2M(struct netxen_adapter *adapter, ulong off, u32 data) |
Dhananjay Phadke | 3ce06a3 | 2008-07-21 19:44:03 -0700 | [diff] [blame] | 1185 | { |
| 1186 | unsigned long flags = 0; |
| 1187 | int rv; |
| 1188 | |
Dhananjay Phadke | 23b6cc4 | 2009-05-08 22:02:30 +0000 | [diff] [blame] | 1189 | rv = netxen_nic_pci_get_crb_addr_2M(adapter, &off); |
Dhananjay Phadke | 3ce06a3 | 2008-07-21 19:44:03 -0700 | [diff] [blame] | 1190 | |
| 1191 | if (rv == -1) { |
| 1192 | printk(KERN_ERR "%s: invalid offset: 0x%016lx\n", |
| 1193 | __func__, off); |
| 1194 | dump_stack(); |
| 1195 | return -1; |
| 1196 | } |
| 1197 | |
| 1198 | if (rv == 1) { |
| 1199 | write_lock_irqsave(&adapter->adapter_lock, flags); |
| 1200 | crb_win_lock(adapter); |
| 1201 | netxen_nic_pci_set_crbwindow_2M(adapter, &off); |
Dhananjay Phadke | 1fbe632 | 2009-04-07 22:50:44 +0000 | [diff] [blame] | 1202 | writel(data, (void __iomem *)off); |
Dhananjay Phadke | 3ce06a3 | 2008-07-21 19:44:03 -0700 | [diff] [blame] | 1203 | crb_win_unlock(adapter); |
| 1204 | write_unlock_irqrestore(&adapter->adapter_lock, flags); |
Dhananjay Phadke | d8313ce | 2009-02-17 20:26:44 -0800 | [diff] [blame] | 1205 | } else |
Dhananjay Phadke | 1fbe632 | 2009-04-07 22:50:44 +0000 | [diff] [blame] | 1206 | writel(data, (void __iomem *)off); |
Dhananjay Phadke | d8313ce | 2009-02-17 20:26:44 -0800 | [diff] [blame] | 1207 | |
Dhananjay Phadke | 3ce06a3 | 2008-07-21 19:44:03 -0700 | [diff] [blame] | 1208 | |
| 1209 | return 0; |
| 1210 | } |
| 1211 | |
Dhananjay Phadke | 1fbe632 | 2009-04-07 22:50:44 +0000 | [diff] [blame] | 1212 | u32 |
| 1213 | netxen_nic_hw_read_wx_2M(struct netxen_adapter *adapter, ulong off) |
Dhananjay Phadke | 3ce06a3 | 2008-07-21 19:44:03 -0700 | [diff] [blame] | 1214 | { |
| 1215 | unsigned long flags = 0; |
| 1216 | int rv; |
Dhananjay Phadke | 1fbe632 | 2009-04-07 22:50:44 +0000 | [diff] [blame] | 1217 | u32 data; |
Dhananjay Phadke | 3ce06a3 | 2008-07-21 19:44:03 -0700 | [diff] [blame] | 1218 | |
Dhananjay Phadke | 23b6cc4 | 2009-05-08 22:02:30 +0000 | [diff] [blame] | 1219 | rv = netxen_nic_pci_get_crb_addr_2M(adapter, &off); |
Dhananjay Phadke | 3ce06a3 | 2008-07-21 19:44:03 -0700 | [diff] [blame] | 1220 | |
| 1221 | if (rv == -1) { |
| 1222 | printk(KERN_ERR "%s: invalid offset: 0x%016lx\n", |
| 1223 | __func__, off); |
| 1224 | dump_stack(); |
| 1225 | return -1; |
| 1226 | } |
| 1227 | |
| 1228 | if (rv == 1) { |
| 1229 | write_lock_irqsave(&adapter->adapter_lock, flags); |
| 1230 | crb_win_lock(adapter); |
| 1231 | netxen_nic_pci_set_crbwindow_2M(adapter, &off); |
Dhananjay Phadke | 1fbe632 | 2009-04-07 22:50:44 +0000 | [diff] [blame] | 1232 | data = readl((void __iomem *)off); |
Dhananjay Phadke | 3ce06a3 | 2008-07-21 19:44:03 -0700 | [diff] [blame] | 1233 | crb_win_unlock(adapter); |
| 1234 | write_unlock_irqrestore(&adapter->adapter_lock, flags); |
Dhananjay Phadke | d8313ce | 2009-02-17 20:26:44 -0800 | [diff] [blame] | 1235 | } else |
Dhananjay Phadke | 1fbe632 | 2009-04-07 22:50:44 +0000 | [diff] [blame] | 1236 | data = readl((void __iomem *)off); |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 1237 | |
Dhananjay Phadke | 1fbe632 | 2009-04-07 22:50:44 +0000 | [diff] [blame] | 1238 | return data; |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 1239 | } |
| 1240 | |
Dhananjay Phadke | 3ce06a3 | 2008-07-21 19:44:03 -0700 | [diff] [blame] | 1241 | /* |
| 1242 | * check memory access boundary. |
| 1243 | * used by test agent. support ddr access only for now |
| 1244 | */ |
| 1245 | static unsigned long |
| 1246 | netxen_nic_pci_mem_bound_check(struct netxen_adapter *adapter, |
| 1247 | unsigned long long addr, int size) |
| 1248 | { |
| 1249 | if (!ADDR_IN_RANGE(addr, |
| 1250 | NETXEN_ADDR_DDR_NET, NETXEN_ADDR_DDR_NET_MAX) || |
| 1251 | !ADDR_IN_RANGE(addr+size-1, |
| 1252 | NETXEN_ADDR_DDR_NET, NETXEN_ADDR_DDR_NET_MAX) || |
| 1253 | ((size != 1) && (size != 2) && (size != 4) && (size != 8))) { |
| 1254 | return 0; |
| 1255 | } |
| 1256 | |
| 1257 | return 1; |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 1258 | } |
| 1259 | |
Jeff Garzik | 4790654 | 2007-11-23 21:23:36 -0500 | [diff] [blame] | 1260 | static int netxen_pci_set_window_warning_count; |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 1261 | |
Dhananjay Phadke | 3ce06a3 | 2008-07-21 19:44:03 -0700 | [diff] [blame] | 1262 | unsigned long |
| 1263 | netxen_nic_pci_set_window_128M(struct netxen_adapter *adapter, |
| 1264 | unsigned long long addr) |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 1265 | { |
Dhananjay Phadke | e4c93c8 | 2008-07-21 19:44:02 -0700 | [diff] [blame] | 1266 | void __iomem *offset; |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 1267 | int window; |
Dhananjay Phadke | 3ce06a3 | 2008-07-21 19:44:03 -0700 | [diff] [blame] | 1268 | unsigned long long qdr_max; |
Dhananjay Phadke | e4c93c8 | 2008-07-21 19:44:02 -0700 | [diff] [blame] | 1269 | uint8_t func = adapter->ahw.pci_func; |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 1270 | |
Dhananjay Phadke | 3ce06a3 | 2008-07-21 19:44:03 -0700 | [diff] [blame] | 1271 | if (NX_IS_REVISION_P2(adapter->ahw.revision_id)) { |
| 1272 | qdr_max = NETXEN_ADDR_QDR_NET_MAX_P2; |
| 1273 | } else { |
| 1274 | qdr_max = NETXEN_ADDR_QDR_NET_MAX_P3; |
| 1275 | } |
| 1276 | |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 1277 | if (ADDR_IN_RANGE(addr, NETXEN_ADDR_DDR_NET, NETXEN_ADDR_DDR_NET_MAX)) { |
| 1278 | /* DDR network side */ |
| 1279 | addr -= NETXEN_ADDR_DDR_NET; |
| 1280 | window = (addr >> 25) & 0x3ff; |
Dhananjay Phadke | 3ce06a3 | 2008-07-21 19:44:03 -0700 | [diff] [blame] | 1281 | if (adapter->ahw.ddr_mn_window != window) { |
| 1282 | adapter->ahw.ddr_mn_window = window; |
Dhananjay Phadke | e4c93c8 | 2008-07-21 19:44:02 -0700 | [diff] [blame] | 1283 | offset = PCI_OFFSET_SECOND_RANGE(adapter, |
| 1284 | NETXEN_PCIX_PH_REG(PCIE_MN_WINDOW_REG(func))); |
| 1285 | writel(window, offset); |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 1286 | /* MUST make sure window is set before we forge on... */ |
Dhananjay Phadke | e4c93c8 | 2008-07-21 19:44:02 -0700 | [diff] [blame] | 1287 | readl(offset); |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 1288 | } |
Amit S. Kale | cb8011a | 2006-11-29 09:00:10 -0800 | [diff] [blame] | 1289 | addr -= (window * NETXEN_WINDOW_ONE); |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 1290 | addr += NETXEN_PCI_DDR_NET; |
| 1291 | } else if (ADDR_IN_RANGE(addr, NETXEN_ADDR_OCM0, NETXEN_ADDR_OCM0_MAX)) { |
| 1292 | addr -= NETXEN_ADDR_OCM0; |
| 1293 | addr += NETXEN_PCI_OCM0; |
| 1294 | } else if (ADDR_IN_RANGE(addr, NETXEN_ADDR_OCM1, NETXEN_ADDR_OCM1_MAX)) { |
| 1295 | addr -= NETXEN_ADDR_OCM1; |
| 1296 | addr += NETXEN_PCI_OCM1; |
Dhananjay Phadke | 3ce06a3 | 2008-07-21 19:44:03 -0700 | [diff] [blame] | 1297 | } else if (ADDR_IN_RANGE(addr, NETXEN_ADDR_QDR_NET, qdr_max)) { |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 1298 | /* QDR network side */ |
| 1299 | addr -= NETXEN_ADDR_QDR_NET; |
| 1300 | window = (addr >> 22) & 0x3f; |
Dhananjay Phadke | 3ce06a3 | 2008-07-21 19:44:03 -0700 | [diff] [blame] | 1301 | if (adapter->ahw.qdr_sn_window != window) { |
| 1302 | adapter->ahw.qdr_sn_window = window; |
Dhananjay Phadke | e4c93c8 | 2008-07-21 19:44:02 -0700 | [diff] [blame] | 1303 | offset = PCI_OFFSET_SECOND_RANGE(adapter, |
| 1304 | NETXEN_PCIX_PH_REG(PCIE_SN_WINDOW_REG(func))); |
| 1305 | writel((window << 22), offset); |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 1306 | /* MUST make sure window is set before we forge on... */ |
Dhananjay Phadke | e4c93c8 | 2008-07-21 19:44:02 -0700 | [diff] [blame] | 1307 | readl(offset); |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 1308 | } |
| 1309 | addr -= (window * 0x400000); |
| 1310 | addr += NETXEN_PCI_QDR_NET; |
| 1311 | } else { |
| 1312 | /* |
| 1313 | * peg gdb frequently accesses memory that doesn't exist, |
| 1314 | * this limits the chit chat so debugging isn't slowed down. |
| 1315 | */ |
| 1316 | if ((netxen_pci_set_window_warning_count++ < 8) |
| 1317 | || (netxen_pci_set_window_warning_count % 64 == 0)) |
| 1318 | printk("%s: Warning:netxen_nic_pci_set_window()" |
| 1319 | " Unknown address range!\n", |
| 1320 | netxen_nic_driver_name); |
Dhananjay Phadke | 3ce06a3 | 2008-07-21 19:44:03 -0700 | [diff] [blame] | 1321 | addr = -1UL; |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 1322 | } |
| 1323 | return addr; |
| 1324 | } |
| 1325 | |
Dhananjay Phadke | 3ce06a3 | 2008-07-21 19:44:03 -0700 | [diff] [blame] | 1326 | /* |
| 1327 | * Note : only 32-bit writes! |
| 1328 | */ |
| 1329 | int netxen_nic_pci_write_immediate_128M(struct netxen_adapter *adapter, |
| 1330 | u64 off, u32 data) |
| 1331 | { |
| 1332 | writel(data, (void __iomem *)(PCI_OFFSET_SECOND_RANGE(adapter, off))); |
| 1333 | return 0; |
| 1334 | } |
| 1335 | |
| 1336 | u32 netxen_nic_pci_read_immediate_128M(struct netxen_adapter *adapter, u64 off) |
| 1337 | { |
| 1338 | return readl((void __iomem *)(pci_base_offset(adapter, off))); |
| 1339 | } |
| 1340 | |
Dhananjay Phadke | 3ce06a3 | 2008-07-21 19:44:03 -0700 | [diff] [blame] | 1341 | unsigned long |
| 1342 | netxen_nic_pci_set_window_2M(struct netxen_adapter *adapter, |
| 1343 | unsigned long long addr) |
| 1344 | { |
| 1345 | int window; |
| 1346 | u32 win_read; |
| 1347 | |
| 1348 | if (ADDR_IN_RANGE(addr, NETXEN_ADDR_DDR_NET, NETXEN_ADDR_DDR_NET_MAX)) { |
| 1349 | /* DDR network side */ |
| 1350 | window = MN_WIN(addr); |
| 1351 | adapter->ahw.ddr_mn_window = window; |
Dhananjay Phadke | f98a9f6 | 2009-04-07 22:50:45 +0000 | [diff] [blame] | 1352 | NXWR32(adapter, adapter->ahw.mn_win_crb | NETXEN_PCI_CRBSPACE, |
Dhananjay Phadke | 1fbe632 | 2009-04-07 22:50:44 +0000 | [diff] [blame] | 1353 | window); |
Dhananjay Phadke | f98a9f6 | 2009-04-07 22:50:45 +0000 | [diff] [blame] | 1354 | win_read = NXRD32(adapter, |
Dhananjay Phadke | 1fbe632 | 2009-04-07 22:50:44 +0000 | [diff] [blame] | 1355 | adapter->ahw.mn_win_crb | NETXEN_PCI_CRBSPACE); |
Dhananjay Phadke | 3ce06a3 | 2008-07-21 19:44:03 -0700 | [diff] [blame] | 1356 | if ((win_read << 17) != window) { |
| 1357 | printk(KERN_INFO "Written MNwin (0x%x) != " |
| 1358 | "Read MNwin (0x%x)\n", window, win_read); |
| 1359 | } |
| 1360 | addr = GET_MEM_OFFS_2M(addr) + NETXEN_PCI_DDR_NET; |
| 1361 | } else if (ADDR_IN_RANGE(addr, |
| 1362 | NETXEN_ADDR_OCM0, NETXEN_ADDR_OCM0_MAX)) { |
| 1363 | if ((addr & 0x00ff800) == 0xff800) { |
| 1364 | printk("%s: QM access not handled.\n", __func__); |
| 1365 | addr = -1UL; |
| 1366 | } |
| 1367 | |
| 1368 | window = OCM_WIN(addr); |
| 1369 | adapter->ahw.ddr_mn_window = window; |
Dhananjay Phadke | f98a9f6 | 2009-04-07 22:50:45 +0000 | [diff] [blame] | 1370 | NXWR32(adapter, adapter->ahw.mn_win_crb | NETXEN_PCI_CRBSPACE, |
Dhananjay Phadke | 1fbe632 | 2009-04-07 22:50:44 +0000 | [diff] [blame] | 1371 | window); |
Dhananjay Phadke | f98a9f6 | 2009-04-07 22:50:45 +0000 | [diff] [blame] | 1372 | win_read = NXRD32(adapter, |
Dhananjay Phadke | 1fbe632 | 2009-04-07 22:50:44 +0000 | [diff] [blame] | 1373 | adapter->ahw.mn_win_crb | NETXEN_PCI_CRBSPACE); |
Dhananjay Phadke | 3ce06a3 | 2008-07-21 19:44:03 -0700 | [diff] [blame] | 1374 | if ((win_read >> 7) != window) { |
| 1375 | printk(KERN_INFO "%s: Written OCMwin (0x%x) != " |
| 1376 | "Read OCMwin (0x%x)\n", |
| 1377 | __func__, window, win_read); |
| 1378 | } |
| 1379 | addr = GET_MEM_OFFS_2M(addr) + NETXEN_PCI_OCM0_2M; |
| 1380 | |
| 1381 | } else if (ADDR_IN_RANGE(addr, |
| 1382 | NETXEN_ADDR_QDR_NET, NETXEN_ADDR_QDR_NET_MAX_P3)) { |
| 1383 | /* QDR network side */ |
| 1384 | window = MS_WIN(addr); |
| 1385 | adapter->ahw.qdr_sn_window = window; |
Dhananjay Phadke | f98a9f6 | 2009-04-07 22:50:45 +0000 | [diff] [blame] | 1386 | NXWR32(adapter, adapter->ahw.ms_win_crb | NETXEN_PCI_CRBSPACE, |
Dhananjay Phadke | 1fbe632 | 2009-04-07 22:50:44 +0000 | [diff] [blame] | 1387 | window); |
Dhananjay Phadke | f98a9f6 | 2009-04-07 22:50:45 +0000 | [diff] [blame] | 1388 | win_read = NXRD32(adapter, |
Dhananjay Phadke | 1fbe632 | 2009-04-07 22:50:44 +0000 | [diff] [blame] | 1389 | adapter->ahw.ms_win_crb | NETXEN_PCI_CRBSPACE); |
Dhananjay Phadke | 3ce06a3 | 2008-07-21 19:44:03 -0700 | [diff] [blame] | 1390 | if (win_read != window) { |
| 1391 | printk(KERN_INFO "%s: Written MSwin (0x%x) != " |
| 1392 | "Read MSwin (0x%x)\n", |
| 1393 | __func__, window, win_read); |
| 1394 | } |
| 1395 | addr = GET_MEM_OFFS_2M(addr) + NETXEN_PCI_QDR_NET; |
| 1396 | |
| 1397 | } else { |
| 1398 | /* |
| 1399 | * peg gdb frequently accesses memory that doesn't exist, |
| 1400 | * this limits the chit chat so debugging isn't slowed down. |
| 1401 | */ |
| 1402 | if ((netxen_pci_set_window_warning_count++ < 8) |
| 1403 | || (netxen_pci_set_window_warning_count%64 == 0)) { |
| 1404 | printk("%s: Warning:%s Unknown address range!\n", |
| 1405 | __func__, netxen_nic_driver_name); |
| 1406 | } |
| 1407 | addr = -1UL; |
| 1408 | } |
| 1409 | return addr; |
| 1410 | } |
| 1411 | |
| 1412 | static int netxen_nic_pci_is_same_window(struct netxen_adapter *adapter, |
| 1413 | unsigned long long addr) |
| 1414 | { |
| 1415 | int window; |
| 1416 | unsigned long long qdr_max; |
| 1417 | |
| 1418 | if (NX_IS_REVISION_P2(adapter->ahw.revision_id)) |
| 1419 | qdr_max = NETXEN_ADDR_QDR_NET_MAX_P2; |
| 1420 | else |
| 1421 | qdr_max = NETXEN_ADDR_QDR_NET_MAX_P3; |
| 1422 | |
| 1423 | if (ADDR_IN_RANGE(addr, |
| 1424 | NETXEN_ADDR_DDR_NET, NETXEN_ADDR_DDR_NET_MAX)) { |
| 1425 | /* DDR network side */ |
| 1426 | BUG(); /* MN access can not come here */ |
| 1427 | } else if (ADDR_IN_RANGE(addr, |
| 1428 | NETXEN_ADDR_OCM0, NETXEN_ADDR_OCM0_MAX)) { |
| 1429 | return 1; |
| 1430 | } else if (ADDR_IN_RANGE(addr, |
| 1431 | NETXEN_ADDR_OCM1, NETXEN_ADDR_OCM1_MAX)) { |
| 1432 | return 1; |
| 1433 | } else if (ADDR_IN_RANGE(addr, NETXEN_ADDR_QDR_NET, qdr_max)) { |
| 1434 | /* QDR network side */ |
| 1435 | window = ((addr - NETXEN_ADDR_QDR_NET) >> 22) & 0x3f; |
| 1436 | if (adapter->ahw.qdr_sn_window == window) |
| 1437 | return 1; |
| 1438 | } |
| 1439 | |
| 1440 | return 0; |
| 1441 | } |
| 1442 | |
| 1443 | static int netxen_nic_pci_mem_read_direct(struct netxen_adapter *adapter, |
| 1444 | u64 off, void *data, int size) |
| 1445 | { |
| 1446 | unsigned long flags; |
Dhananjay Phadke | d8313ce | 2009-02-17 20:26:44 -0800 | [diff] [blame] | 1447 | void __iomem *addr, *mem_ptr = NULL; |
Dhananjay Phadke | 3ce06a3 | 2008-07-21 19:44:03 -0700 | [diff] [blame] | 1448 | int ret = 0; |
| 1449 | u64 start; |
Dhananjay Phadke | 3ce06a3 | 2008-07-21 19:44:03 -0700 | [diff] [blame] | 1450 | unsigned long mem_base; |
| 1451 | unsigned long mem_page; |
| 1452 | |
| 1453 | write_lock_irqsave(&adapter->adapter_lock, flags); |
| 1454 | |
| 1455 | /* |
| 1456 | * If attempting to access unknown address or straddle hw windows, |
| 1457 | * do not access. |
| 1458 | */ |
| 1459 | start = adapter->pci_set_window(adapter, off); |
| 1460 | if ((start == -1UL) || |
| 1461 | (netxen_nic_pci_is_same_window(adapter, off+size-1) == 0)) { |
| 1462 | write_unlock_irqrestore(&adapter->adapter_lock, flags); |
| 1463 | printk(KERN_ERR "%s out of bound pci memory access. " |
Andrew Morton | 11a859e | 2008-07-30 12:50:12 -0700 | [diff] [blame] | 1464 | "offset is 0x%llx\n", netxen_nic_driver_name, |
| 1465 | (unsigned long long)off); |
Dhananjay Phadke | 3ce06a3 | 2008-07-21 19:44:03 -0700 | [diff] [blame] | 1466 | return -1; |
| 1467 | } |
| 1468 | |
Dhananjay Phadke | d8313ce | 2009-02-17 20:26:44 -0800 | [diff] [blame] | 1469 | addr = pci_base_offset(adapter, start); |
Dhananjay Phadke | 3ce06a3 | 2008-07-21 19:44:03 -0700 | [diff] [blame] | 1470 | if (!addr) { |
| 1471 | write_unlock_irqrestore(&adapter->adapter_lock, flags); |
| 1472 | mem_base = pci_resource_start(adapter->pdev, 0); |
| 1473 | mem_page = start & PAGE_MASK; |
| 1474 | /* Map two pages whenever user tries to access addresses in two |
| 1475 | consecutive pages. |
| 1476 | */ |
| 1477 | if (mem_page != ((start + size - 1) & PAGE_MASK)) |
| 1478 | mem_ptr = ioremap(mem_base + mem_page, PAGE_SIZE * 2); |
| 1479 | else |
| 1480 | mem_ptr = ioremap(mem_base + mem_page, PAGE_SIZE); |
Hannes Eder | f8057b7 | 2008-12-26 00:04:26 -0800 | [diff] [blame] | 1481 | if (mem_ptr == NULL) { |
Dhananjay Phadke | 3ce06a3 | 2008-07-21 19:44:03 -0700 | [diff] [blame] | 1482 | *(uint8_t *)data = 0; |
| 1483 | return -1; |
| 1484 | } |
| 1485 | addr = mem_ptr; |
| 1486 | addr += start & (PAGE_SIZE - 1); |
| 1487 | write_lock_irqsave(&adapter->adapter_lock, flags); |
| 1488 | } |
| 1489 | |
| 1490 | switch (size) { |
| 1491 | case 1: |
| 1492 | *(uint8_t *)data = readb(addr); |
| 1493 | break; |
| 1494 | case 2: |
| 1495 | *(uint16_t *)data = readw(addr); |
| 1496 | break; |
| 1497 | case 4: |
| 1498 | *(uint32_t *)data = readl(addr); |
| 1499 | break; |
| 1500 | case 8: |
| 1501 | *(uint64_t *)data = readq(addr); |
| 1502 | break; |
| 1503 | default: |
| 1504 | ret = -1; |
| 1505 | break; |
| 1506 | } |
| 1507 | write_unlock_irqrestore(&adapter->adapter_lock, flags); |
Dhananjay Phadke | 3ce06a3 | 2008-07-21 19:44:03 -0700 | [diff] [blame] | 1508 | |
| 1509 | if (mem_ptr) |
| 1510 | iounmap(mem_ptr); |
| 1511 | return ret; |
| 1512 | } |
| 1513 | |
| 1514 | static int |
| 1515 | netxen_nic_pci_mem_write_direct(struct netxen_adapter *adapter, u64 off, |
| 1516 | void *data, int size) |
| 1517 | { |
| 1518 | unsigned long flags; |
Dhananjay Phadke | d8313ce | 2009-02-17 20:26:44 -0800 | [diff] [blame] | 1519 | void __iomem *addr, *mem_ptr = NULL; |
Dhananjay Phadke | 3ce06a3 | 2008-07-21 19:44:03 -0700 | [diff] [blame] | 1520 | int ret = 0; |
| 1521 | u64 start; |
Dhananjay Phadke | 3ce06a3 | 2008-07-21 19:44:03 -0700 | [diff] [blame] | 1522 | unsigned long mem_base; |
| 1523 | unsigned long mem_page; |
| 1524 | |
| 1525 | write_lock_irqsave(&adapter->adapter_lock, flags); |
| 1526 | |
| 1527 | /* |
| 1528 | * If attempting to access unknown address or straddle hw windows, |
| 1529 | * do not access. |
| 1530 | */ |
| 1531 | start = adapter->pci_set_window(adapter, off); |
| 1532 | if ((start == -1UL) || |
| 1533 | (netxen_nic_pci_is_same_window(adapter, off+size-1) == 0)) { |
| 1534 | write_unlock_irqrestore(&adapter->adapter_lock, flags); |
| 1535 | printk(KERN_ERR "%s out of bound pci memory access. " |
Andrew Morton | 11a859e | 2008-07-30 12:50:12 -0700 | [diff] [blame] | 1536 | "offset is 0x%llx\n", netxen_nic_driver_name, |
| 1537 | (unsigned long long)off); |
Dhananjay Phadke | 3ce06a3 | 2008-07-21 19:44:03 -0700 | [diff] [blame] | 1538 | return -1; |
| 1539 | } |
| 1540 | |
Dhananjay Phadke | d8313ce | 2009-02-17 20:26:44 -0800 | [diff] [blame] | 1541 | addr = pci_base_offset(adapter, start); |
Dhananjay Phadke | 3ce06a3 | 2008-07-21 19:44:03 -0700 | [diff] [blame] | 1542 | if (!addr) { |
| 1543 | write_unlock_irqrestore(&adapter->adapter_lock, flags); |
| 1544 | mem_base = pci_resource_start(adapter->pdev, 0); |
| 1545 | mem_page = start & PAGE_MASK; |
| 1546 | /* Map two pages whenever user tries to access addresses in two |
| 1547 | * consecutive pages. |
| 1548 | */ |
| 1549 | if (mem_page != ((start + size - 1) & PAGE_MASK)) |
| 1550 | mem_ptr = ioremap(mem_base + mem_page, PAGE_SIZE*2); |
| 1551 | else |
| 1552 | mem_ptr = ioremap(mem_base + mem_page, PAGE_SIZE); |
Hannes Eder | f8057b7 | 2008-12-26 00:04:26 -0800 | [diff] [blame] | 1553 | if (mem_ptr == NULL) |
Dhananjay Phadke | 3ce06a3 | 2008-07-21 19:44:03 -0700 | [diff] [blame] | 1554 | return -1; |
| 1555 | addr = mem_ptr; |
| 1556 | addr += start & (PAGE_SIZE - 1); |
| 1557 | write_lock_irqsave(&adapter->adapter_lock, flags); |
| 1558 | } |
| 1559 | |
| 1560 | switch (size) { |
| 1561 | case 1: |
| 1562 | writeb(*(uint8_t *)data, addr); |
| 1563 | break; |
| 1564 | case 2: |
| 1565 | writew(*(uint16_t *)data, addr); |
| 1566 | break; |
| 1567 | case 4: |
| 1568 | writel(*(uint32_t *)data, addr); |
| 1569 | break; |
| 1570 | case 8: |
| 1571 | writeq(*(uint64_t *)data, addr); |
| 1572 | break; |
| 1573 | default: |
| 1574 | ret = -1; |
| 1575 | break; |
| 1576 | } |
| 1577 | write_unlock_irqrestore(&adapter->adapter_lock, flags); |
Dhananjay Phadke | 3ce06a3 | 2008-07-21 19:44:03 -0700 | [diff] [blame] | 1578 | if (mem_ptr) |
| 1579 | iounmap(mem_ptr); |
| 1580 | return ret; |
| 1581 | } |
| 1582 | |
| 1583 | #define MAX_CTL_CHECK 1000 |
| 1584 | |
| 1585 | int |
| 1586 | netxen_nic_pci_mem_write_128M(struct netxen_adapter *adapter, |
| 1587 | u64 off, void *data, int size) |
| 1588 | { |
Dhananjay Phadke | d8313ce | 2009-02-17 20:26:44 -0800 | [diff] [blame] | 1589 | unsigned long flags; |
Dhananjay Phadke | 3ce06a3 | 2008-07-21 19:44:03 -0700 | [diff] [blame] | 1590 | int i, j, ret = 0, loop, sz[2], off0; |
| 1591 | uint32_t temp; |
| 1592 | uint64_t off8, tmpw, word[2] = {0, 0}; |
Dhananjay Phadke | d8313ce | 2009-02-17 20:26:44 -0800 | [diff] [blame] | 1593 | void __iomem *mem_crb; |
Dhananjay Phadke | 3ce06a3 | 2008-07-21 19:44:03 -0700 | [diff] [blame] | 1594 | |
| 1595 | /* |
| 1596 | * If not MN, go check for MS or invalid. |
| 1597 | */ |
| 1598 | if (netxen_nic_pci_mem_bound_check(adapter, off, size) == 0) |
| 1599 | return netxen_nic_pci_mem_write_direct(adapter, |
| 1600 | off, data, size); |
| 1601 | |
| 1602 | off8 = off & 0xfffffff8; |
| 1603 | off0 = off & 0x7; |
| 1604 | sz[0] = (size < (8 - off0)) ? size : (8 - off0); |
| 1605 | sz[1] = size - sz[0]; |
| 1606 | loop = ((off0 + size - 1) >> 3) + 1; |
Dhananjay Phadke | d8313ce | 2009-02-17 20:26:44 -0800 | [diff] [blame] | 1607 | mem_crb = pci_base_offset(adapter, NETXEN_CRB_DDR_NET); |
Dhananjay Phadke | 3ce06a3 | 2008-07-21 19:44:03 -0700 | [diff] [blame] | 1608 | |
| 1609 | if ((size != 8) || (off0 != 0)) { |
| 1610 | for (i = 0; i < loop; i++) { |
| 1611 | if (adapter->pci_mem_read(adapter, |
| 1612 | off8 + (i << 3), &word[i], 8)) |
| 1613 | return -1; |
| 1614 | } |
| 1615 | } |
| 1616 | |
| 1617 | switch (size) { |
| 1618 | case 1: |
| 1619 | tmpw = *((uint8_t *)data); |
| 1620 | break; |
| 1621 | case 2: |
| 1622 | tmpw = *((uint16_t *)data); |
| 1623 | break; |
| 1624 | case 4: |
| 1625 | tmpw = *((uint32_t *)data); |
| 1626 | break; |
| 1627 | case 8: |
| 1628 | default: |
| 1629 | tmpw = *((uint64_t *)data); |
| 1630 | break; |
| 1631 | } |
| 1632 | word[0] &= ~((~(~0ULL << (sz[0] * 8))) << (off0 * 8)); |
| 1633 | word[0] |= tmpw << (off0 * 8); |
| 1634 | |
| 1635 | if (loop == 2) { |
| 1636 | word[1] &= ~(~0ULL << (sz[1] * 8)); |
| 1637 | word[1] |= tmpw >> (sz[0] * 8); |
| 1638 | } |
| 1639 | |
| 1640 | write_lock_irqsave(&adapter->adapter_lock, flags); |
| 1641 | netxen_nic_pci_change_crbwindow_128M(adapter, 0); |
| 1642 | |
| 1643 | for (i = 0; i < loop; i++) { |
| 1644 | writel((uint32_t)(off8 + (i << 3)), |
Dhananjay Phadke | d8313ce | 2009-02-17 20:26:44 -0800 | [diff] [blame] | 1645 | (mem_crb+MIU_TEST_AGT_ADDR_LO)); |
Dhananjay Phadke | 3ce06a3 | 2008-07-21 19:44:03 -0700 | [diff] [blame] | 1646 | writel(0, |
Dhananjay Phadke | d8313ce | 2009-02-17 20:26:44 -0800 | [diff] [blame] | 1647 | (mem_crb+MIU_TEST_AGT_ADDR_HI)); |
Dhananjay Phadke | 3ce06a3 | 2008-07-21 19:44:03 -0700 | [diff] [blame] | 1648 | writel(word[i] & 0xffffffff, |
Dhananjay Phadke | d8313ce | 2009-02-17 20:26:44 -0800 | [diff] [blame] | 1649 | (mem_crb+MIU_TEST_AGT_WRDATA_LO)); |
Dhananjay Phadke | 3ce06a3 | 2008-07-21 19:44:03 -0700 | [diff] [blame] | 1650 | writel((word[i] >> 32) & 0xffffffff, |
Dhananjay Phadke | d8313ce | 2009-02-17 20:26:44 -0800 | [diff] [blame] | 1651 | (mem_crb+MIU_TEST_AGT_WRDATA_HI)); |
Dhananjay Phadke | 3ce06a3 | 2008-07-21 19:44:03 -0700 | [diff] [blame] | 1652 | writel(MIU_TA_CTL_ENABLE|MIU_TA_CTL_WRITE, |
Dhananjay Phadke | d8313ce | 2009-02-17 20:26:44 -0800 | [diff] [blame] | 1653 | (mem_crb+MIU_TEST_AGT_CTRL)); |
Dhananjay Phadke | 3ce06a3 | 2008-07-21 19:44:03 -0700 | [diff] [blame] | 1654 | writel(MIU_TA_CTL_START|MIU_TA_CTL_ENABLE|MIU_TA_CTL_WRITE, |
Dhananjay Phadke | d8313ce | 2009-02-17 20:26:44 -0800 | [diff] [blame] | 1655 | (mem_crb+MIU_TEST_AGT_CTRL)); |
Dhananjay Phadke | 3ce06a3 | 2008-07-21 19:44:03 -0700 | [diff] [blame] | 1656 | |
| 1657 | for (j = 0; j < MAX_CTL_CHECK; j++) { |
| 1658 | temp = readl( |
Dhananjay Phadke | d8313ce | 2009-02-17 20:26:44 -0800 | [diff] [blame] | 1659 | (mem_crb+MIU_TEST_AGT_CTRL)); |
Dhananjay Phadke | 3ce06a3 | 2008-07-21 19:44:03 -0700 | [diff] [blame] | 1660 | if ((temp & MIU_TA_CTL_BUSY) == 0) |
| 1661 | break; |
| 1662 | } |
| 1663 | |
| 1664 | if (j >= MAX_CTL_CHECK) { |
Dhananjay Phadke | 39754f4 | 2009-02-17 20:27:02 -0800 | [diff] [blame] | 1665 | if (printk_ratelimit()) |
| 1666 | dev_err(&adapter->pdev->dev, |
| 1667 | "failed to write through agent\n"); |
Dhananjay Phadke | 3ce06a3 | 2008-07-21 19:44:03 -0700 | [diff] [blame] | 1668 | ret = -1; |
| 1669 | break; |
| 1670 | } |
| 1671 | } |
| 1672 | |
| 1673 | netxen_nic_pci_change_crbwindow_128M(adapter, 1); |
| 1674 | write_unlock_irqrestore(&adapter->adapter_lock, flags); |
| 1675 | return ret; |
| 1676 | } |
| 1677 | |
| 1678 | int |
| 1679 | netxen_nic_pci_mem_read_128M(struct netxen_adapter *adapter, |
| 1680 | u64 off, void *data, int size) |
| 1681 | { |
Dhananjay Phadke | d8313ce | 2009-02-17 20:26:44 -0800 | [diff] [blame] | 1682 | unsigned long flags; |
Dhananjay Phadke | 3ce06a3 | 2008-07-21 19:44:03 -0700 | [diff] [blame] | 1683 | int i, j = 0, k, start, end, loop, sz[2], off0[2]; |
| 1684 | uint32_t temp; |
| 1685 | uint64_t off8, val, word[2] = {0, 0}; |
Dhananjay Phadke | d8313ce | 2009-02-17 20:26:44 -0800 | [diff] [blame] | 1686 | void __iomem *mem_crb; |
Dhananjay Phadke | 3ce06a3 | 2008-07-21 19:44:03 -0700 | [diff] [blame] | 1687 | |
| 1688 | |
| 1689 | /* |
| 1690 | * If not MN, go check for MS or invalid. |
| 1691 | */ |
| 1692 | if (netxen_nic_pci_mem_bound_check(adapter, off, size) == 0) |
| 1693 | return netxen_nic_pci_mem_read_direct(adapter, off, data, size); |
| 1694 | |
| 1695 | off8 = off & 0xfffffff8; |
| 1696 | off0[0] = off & 0x7; |
| 1697 | off0[1] = 0; |
| 1698 | sz[0] = (size < (8 - off0[0])) ? size : (8 - off0[0]); |
| 1699 | sz[1] = size - sz[0]; |
| 1700 | loop = ((off0[0] + size - 1) >> 3) + 1; |
Dhananjay Phadke | d8313ce | 2009-02-17 20:26:44 -0800 | [diff] [blame] | 1701 | mem_crb = pci_base_offset(adapter, NETXEN_CRB_DDR_NET); |
Dhananjay Phadke | 3ce06a3 | 2008-07-21 19:44:03 -0700 | [diff] [blame] | 1702 | |
| 1703 | write_lock_irqsave(&adapter->adapter_lock, flags); |
| 1704 | netxen_nic_pci_change_crbwindow_128M(adapter, 0); |
| 1705 | |
| 1706 | for (i = 0; i < loop; i++) { |
| 1707 | writel((uint32_t)(off8 + (i << 3)), |
Dhananjay Phadke | d8313ce | 2009-02-17 20:26:44 -0800 | [diff] [blame] | 1708 | (mem_crb+MIU_TEST_AGT_ADDR_LO)); |
Dhananjay Phadke | 3ce06a3 | 2008-07-21 19:44:03 -0700 | [diff] [blame] | 1709 | writel(0, |
Dhananjay Phadke | d8313ce | 2009-02-17 20:26:44 -0800 | [diff] [blame] | 1710 | (mem_crb+MIU_TEST_AGT_ADDR_HI)); |
Dhananjay Phadke | 3ce06a3 | 2008-07-21 19:44:03 -0700 | [diff] [blame] | 1711 | writel(MIU_TA_CTL_ENABLE, |
Dhananjay Phadke | d8313ce | 2009-02-17 20:26:44 -0800 | [diff] [blame] | 1712 | (mem_crb+MIU_TEST_AGT_CTRL)); |
Dhananjay Phadke | 3ce06a3 | 2008-07-21 19:44:03 -0700 | [diff] [blame] | 1713 | writel(MIU_TA_CTL_START|MIU_TA_CTL_ENABLE, |
Dhananjay Phadke | d8313ce | 2009-02-17 20:26:44 -0800 | [diff] [blame] | 1714 | (mem_crb+MIU_TEST_AGT_CTRL)); |
Dhananjay Phadke | 3ce06a3 | 2008-07-21 19:44:03 -0700 | [diff] [blame] | 1715 | |
| 1716 | for (j = 0; j < MAX_CTL_CHECK; j++) { |
| 1717 | temp = readl( |
Dhananjay Phadke | d8313ce | 2009-02-17 20:26:44 -0800 | [diff] [blame] | 1718 | (mem_crb+MIU_TEST_AGT_CTRL)); |
Dhananjay Phadke | 3ce06a3 | 2008-07-21 19:44:03 -0700 | [diff] [blame] | 1719 | if ((temp & MIU_TA_CTL_BUSY) == 0) |
| 1720 | break; |
| 1721 | } |
| 1722 | |
| 1723 | if (j >= MAX_CTL_CHECK) { |
Dhananjay Phadke | 39754f4 | 2009-02-17 20:27:02 -0800 | [diff] [blame] | 1724 | if (printk_ratelimit()) |
| 1725 | dev_err(&adapter->pdev->dev, |
| 1726 | "failed to read through agent\n"); |
Dhananjay Phadke | 3ce06a3 | 2008-07-21 19:44:03 -0700 | [diff] [blame] | 1727 | break; |
| 1728 | } |
| 1729 | |
| 1730 | start = off0[i] >> 2; |
| 1731 | end = (off0[i] + sz[i] - 1) >> 2; |
| 1732 | for (k = start; k <= end; k++) { |
| 1733 | word[i] |= ((uint64_t) readl( |
Dhananjay Phadke | d8313ce | 2009-02-17 20:26:44 -0800 | [diff] [blame] | 1734 | (mem_crb + |
Dhananjay Phadke | 3ce06a3 | 2008-07-21 19:44:03 -0700 | [diff] [blame] | 1735 | MIU_TEST_AGT_RDDATA(k))) << (32*k)); |
| 1736 | } |
| 1737 | } |
| 1738 | |
| 1739 | netxen_nic_pci_change_crbwindow_128M(adapter, 1); |
| 1740 | write_unlock_irqrestore(&adapter->adapter_lock, flags); |
| 1741 | |
| 1742 | if (j >= MAX_CTL_CHECK) |
| 1743 | return -1; |
| 1744 | |
| 1745 | if (sz[0] == 8) { |
| 1746 | val = word[0]; |
| 1747 | } else { |
| 1748 | val = ((word[0] >> (off0[0] * 8)) & (~(~0ULL << (sz[0] * 8)))) | |
| 1749 | ((word[1] & (~(~0ULL << (sz[1] * 8)))) << (sz[0] * 8)); |
| 1750 | } |
| 1751 | |
| 1752 | switch (size) { |
| 1753 | case 1: |
| 1754 | *(uint8_t *)data = val; |
| 1755 | break; |
| 1756 | case 2: |
| 1757 | *(uint16_t *)data = val; |
| 1758 | break; |
| 1759 | case 4: |
| 1760 | *(uint32_t *)data = val; |
| 1761 | break; |
| 1762 | case 8: |
| 1763 | *(uint64_t *)data = val; |
| 1764 | break; |
| 1765 | } |
Dhananjay Phadke | 3ce06a3 | 2008-07-21 19:44:03 -0700 | [diff] [blame] | 1766 | return 0; |
| 1767 | } |
| 1768 | |
| 1769 | int |
| 1770 | netxen_nic_pci_mem_write_2M(struct netxen_adapter *adapter, |
| 1771 | u64 off, void *data, int size) |
| 1772 | { |
| 1773 | int i, j, ret = 0, loop, sz[2], off0; |
| 1774 | uint32_t temp; |
| 1775 | uint64_t off8, mem_crb, tmpw, word[2] = {0, 0}; |
| 1776 | |
| 1777 | /* |
| 1778 | * If not MN, go check for MS or invalid. |
| 1779 | */ |
| 1780 | if (off >= NETXEN_ADDR_QDR_NET && off <= NETXEN_ADDR_QDR_NET_MAX_P3) |
| 1781 | mem_crb = NETXEN_CRB_QDR_NET; |
| 1782 | else { |
| 1783 | mem_crb = NETXEN_CRB_DDR_NET; |
| 1784 | if (netxen_nic_pci_mem_bound_check(adapter, off, size) == 0) |
| 1785 | return netxen_nic_pci_mem_write_direct(adapter, |
| 1786 | off, data, size); |
| 1787 | } |
| 1788 | |
| 1789 | off8 = off & 0xfffffff8; |
| 1790 | off0 = off & 0x7; |
| 1791 | sz[0] = (size < (8 - off0)) ? size : (8 - off0); |
| 1792 | sz[1] = size - sz[0]; |
| 1793 | loop = ((off0 + size - 1) >> 3) + 1; |
| 1794 | |
| 1795 | if ((size != 8) || (off0 != 0)) { |
| 1796 | for (i = 0; i < loop; i++) { |
| 1797 | if (adapter->pci_mem_read(adapter, off8 + (i << 3), |
| 1798 | &word[i], 8)) |
| 1799 | return -1; |
| 1800 | } |
| 1801 | } |
| 1802 | |
| 1803 | switch (size) { |
| 1804 | case 1: |
| 1805 | tmpw = *((uint8_t *)data); |
| 1806 | break; |
| 1807 | case 2: |
| 1808 | tmpw = *((uint16_t *)data); |
| 1809 | break; |
| 1810 | case 4: |
| 1811 | tmpw = *((uint32_t *)data); |
| 1812 | break; |
| 1813 | case 8: |
| 1814 | default: |
| 1815 | tmpw = *((uint64_t *)data); |
| 1816 | break; |
| 1817 | } |
| 1818 | |
| 1819 | word[0] &= ~((~(~0ULL << (sz[0] * 8))) << (off0 * 8)); |
| 1820 | word[0] |= tmpw << (off0 * 8); |
| 1821 | |
| 1822 | if (loop == 2) { |
| 1823 | word[1] &= ~(~0ULL << (sz[1] * 8)); |
| 1824 | word[1] |= tmpw >> (sz[0] * 8); |
| 1825 | } |
| 1826 | |
| 1827 | /* |
| 1828 | * don't lock here - write_wx gets the lock if each time |
| 1829 | * write_lock_irqsave(&adapter->adapter_lock, flags); |
| 1830 | * netxen_nic_pci_change_crbwindow_128M(adapter, 0); |
| 1831 | */ |
| 1832 | |
| 1833 | for (i = 0; i < loop; i++) { |
| 1834 | temp = off8 + (i << 3); |
Dhananjay Phadke | f98a9f6 | 2009-04-07 22:50:45 +0000 | [diff] [blame] | 1835 | NXWR32(adapter, mem_crb+MIU_TEST_AGT_ADDR_LO, temp); |
Dhananjay Phadke | 3ce06a3 | 2008-07-21 19:44:03 -0700 | [diff] [blame] | 1836 | temp = 0; |
Dhananjay Phadke | f98a9f6 | 2009-04-07 22:50:45 +0000 | [diff] [blame] | 1837 | NXWR32(adapter, mem_crb+MIU_TEST_AGT_ADDR_HI, temp); |
Dhananjay Phadke | 3ce06a3 | 2008-07-21 19:44:03 -0700 | [diff] [blame] | 1838 | temp = word[i] & 0xffffffff; |
Dhananjay Phadke | f98a9f6 | 2009-04-07 22:50:45 +0000 | [diff] [blame] | 1839 | NXWR32(adapter, mem_crb+MIU_TEST_AGT_WRDATA_LO, temp); |
Dhananjay Phadke | 3ce06a3 | 2008-07-21 19:44:03 -0700 | [diff] [blame] | 1840 | temp = (word[i] >> 32) & 0xffffffff; |
Dhananjay Phadke | f98a9f6 | 2009-04-07 22:50:45 +0000 | [diff] [blame] | 1841 | NXWR32(adapter, mem_crb+MIU_TEST_AGT_WRDATA_HI, temp); |
Dhananjay Phadke | 3ce06a3 | 2008-07-21 19:44:03 -0700 | [diff] [blame] | 1842 | temp = MIU_TA_CTL_ENABLE | MIU_TA_CTL_WRITE; |
Dhananjay Phadke | f98a9f6 | 2009-04-07 22:50:45 +0000 | [diff] [blame] | 1843 | NXWR32(adapter, mem_crb+MIU_TEST_AGT_CTRL, temp); |
Dhananjay Phadke | 3ce06a3 | 2008-07-21 19:44:03 -0700 | [diff] [blame] | 1844 | temp = MIU_TA_CTL_START | MIU_TA_CTL_ENABLE | MIU_TA_CTL_WRITE; |
Dhananjay Phadke | f98a9f6 | 2009-04-07 22:50:45 +0000 | [diff] [blame] | 1845 | NXWR32(adapter, mem_crb+MIU_TEST_AGT_CTRL, temp); |
Dhananjay Phadke | 3ce06a3 | 2008-07-21 19:44:03 -0700 | [diff] [blame] | 1846 | |
| 1847 | for (j = 0; j < MAX_CTL_CHECK; j++) { |
Dhananjay Phadke | f98a9f6 | 2009-04-07 22:50:45 +0000 | [diff] [blame] | 1848 | temp = NXRD32(adapter, mem_crb + MIU_TEST_AGT_CTRL); |
Dhananjay Phadke | 3ce06a3 | 2008-07-21 19:44:03 -0700 | [diff] [blame] | 1849 | if ((temp & MIU_TA_CTL_BUSY) == 0) |
| 1850 | break; |
| 1851 | } |
| 1852 | |
| 1853 | if (j >= MAX_CTL_CHECK) { |
Dhananjay Phadke | 39754f4 | 2009-02-17 20:27:02 -0800 | [diff] [blame] | 1854 | if (printk_ratelimit()) |
| 1855 | dev_err(&adapter->pdev->dev, |
| 1856 | "failed to write through agent\n"); |
Dhananjay Phadke | 3ce06a3 | 2008-07-21 19:44:03 -0700 | [diff] [blame] | 1857 | ret = -1; |
| 1858 | break; |
| 1859 | } |
| 1860 | } |
| 1861 | |
| 1862 | /* |
| 1863 | * netxen_nic_pci_change_crbwindow_128M(adapter, 1); |
| 1864 | * write_unlock_irqrestore(&adapter->adapter_lock, flags); |
| 1865 | */ |
| 1866 | return ret; |
| 1867 | } |
| 1868 | |
| 1869 | int |
| 1870 | netxen_nic_pci_mem_read_2M(struct netxen_adapter *adapter, |
| 1871 | u64 off, void *data, int size) |
| 1872 | { |
| 1873 | int i, j = 0, k, start, end, loop, sz[2], off0[2]; |
| 1874 | uint32_t temp; |
| 1875 | uint64_t off8, val, mem_crb, word[2] = {0, 0}; |
| 1876 | |
| 1877 | /* |
| 1878 | * If not MN, go check for MS or invalid. |
| 1879 | */ |
| 1880 | |
| 1881 | if (off >= NETXEN_ADDR_QDR_NET && off <= NETXEN_ADDR_QDR_NET_MAX_P3) |
| 1882 | mem_crb = NETXEN_CRB_QDR_NET; |
| 1883 | else { |
| 1884 | mem_crb = NETXEN_CRB_DDR_NET; |
| 1885 | if (netxen_nic_pci_mem_bound_check(adapter, off, size) == 0) |
| 1886 | return netxen_nic_pci_mem_read_direct(adapter, |
| 1887 | off, data, size); |
| 1888 | } |
| 1889 | |
| 1890 | off8 = off & 0xfffffff8; |
| 1891 | off0[0] = off & 0x7; |
| 1892 | off0[1] = 0; |
| 1893 | sz[0] = (size < (8 - off0[0])) ? size : (8 - off0[0]); |
| 1894 | sz[1] = size - sz[0]; |
| 1895 | loop = ((off0[0] + size - 1) >> 3) + 1; |
| 1896 | |
| 1897 | /* |
| 1898 | * don't lock here - write_wx gets the lock if each time |
| 1899 | * write_lock_irqsave(&adapter->adapter_lock, flags); |
| 1900 | * netxen_nic_pci_change_crbwindow_128M(adapter, 0); |
| 1901 | */ |
| 1902 | |
| 1903 | for (i = 0; i < loop; i++) { |
| 1904 | temp = off8 + (i << 3); |
Dhananjay Phadke | f98a9f6 | 2009-04-07 22:50:45 +0000 | [diff] [blame] | 1905 | NXWR32(adapter, mem_crb + MIU_TEST_AGT_ADDR_LO, temp); |
Dhananjay Phadke | 3ce06a3 | 2008-07-21 19:44:03 -0700 | [diff] [blame] | 1906 | temp = 0; |
Dhananjay Phadke | f98a9f6 | 2009-04-07 22:50:45 +0000 | [diff] [blame] | 1907 | NXWR32(adapter, mem_crb + MIU_TEST_AGT_ADDR_HI, temp); |
Dhananjay Phadke | 3ce06a3 | 2008-07-21 19:44:03 -0700 | [diff] [blame] | 1908 | temp = MIU_TA_CTL_ENABLE; |
Dhananjay Phadke | f98a9f6 | 2009-04-07 22:50:45 +0000 | [diff] [blame] | 1909 | NXWR32(adapter, mem_crb + MIU_TEST_AGT_CTRL, temp); |
Dhananjay Phadke | 3ce06a3 | 2008-07-21 19:44:03 -0700 | [diff] [blame] | 1910 | temp = MIU_TA_CTL_START | MIU_TA_CTL_ENABLE; |
Dhananjay Phadke | f98a9f6 | 2009-04-07 22:50:45 +0000 | [diff] [blame] | 1911 | NXWR32(adapter, mem_crb + MIU_TEST_AGT_CTRL, temp); |
Dhananjay Phadke | 3ce06a3 | 2008-07-21 19:44:03 -0700 | [diff] [blame] | 1912 | |
| 1913 | for (j = 0; j < MAX_CTL_CHECK; j++) { |
Dhananjay Phadke | f98a9f6 | 2009-04-07 22:50:45 +0000 | [diff] [blame] | 1914 | temp = NXRD32(adapter, mem_crb + MIU_TEST_AGT_CTRL); |
Dhananjay Phadke | 3ce06a3 | 2008-07-21 19:44:03 -0700 | [diff] [blame] | 1915 | if ((temp & MIU_TA_CTL_BUSY) == 0) |
| 1916 | break; |
| 1917 | } |
| 1918 | |
| 1919 | if (j >= MAX_CTL_CHECK) { |
Dhananjay Phadke | 39754f4 | 2009-02-17 20:27:02 -0800 | [diff] [blame] | 1920 | if (printk_ratelimit()) |
| 1921 | dev_err(&adapter->pdev->dev, |
| 1922 | "failed to read through agent\n"); |
Dhananjay Phadke | 3ce06a3 | 2008-07-21 19:44:03 -0700 | [diff] [blame] | 1923 | break; |
| 1924 | } |
| 1925 | |
| 1926 | start = off0[i] >> 2; |
| 1927 | end = (off0[i] + sz[i] - 1) >> 2; |
| 1928 | for (k = start; k <= end; k++) { |
Dhananjay Phadke | f98a9f6 | 2009-04-07 22:50:45 +0000 | [diff] [blame] | 1929 | temp = NXRD32(adapter, |
Dhananjay Phadke | 1fbe632 | 2009-04-07 22:50:44 +0000 | [diff] [blame] | 1930 | mem_crb + MIU_TEST_AGT_RDDATA(k)); |
Dhananjay Phadke | 3ce06a3 | 2008-07-21 19:44:03 -0700 | [diff] [blame] | 1931 | word[i] |= ((uint64_t)temp << (32 * k)); |
| 1932 | } |
| 1933 | } |
| 1934 | |
| 1935 | /* |
| 1936 | * netxen_nic_pci_change_crbwindow_128M(adapter, 1); |
| 1937 | * write_unlock_irqrestore(&adapter->adapter_lock, flags); |
| 1938 | */ |
| 1939 | |
| 1940 | if (j >= MAX_CTL_CHECK) |
| 1941 | return -1; |
| 1942 | |
| 1943 | if (sz[0] == 8) { |
| 1944 | val = word[0]; |
| 1945 | } else { |
| 1946 | val = ((word[0] >> (off0[0] * 8)) & (~(~0ULL << (sz[0] * 8)))) | |
| 1947 | ((word[1] & (~(~0ULL << (sz[1] * 8)))) << (sz[0] * 8)); |
| 1948 | } |
| 1949 | |
| 1950 | switch (size) { |
| 1951 | case 1: |
| 1952 | *(uint8_t *)data = val; |
| 1953 | break; |
| 1954 | case 2: |
| 1955 | *(uint16_t *)data = val; |
| 1956 | break; |
| 1957 | case 4: |
| 1958 | *(uint32_t *)data = val; |
| 1959 | break; |
| 1960 | case 8: |
| 1961 | *(uint64_t *)data = val; |
| 1962 | break; |
| 1963 | } |
Dhananjay Phadke | 3ce06a3 | 2008-07-21 19:44:03 -0700 | [diff] [blame] | 1964 | return 0; |
| 1965 | } |
| 1966 | |
| 1967 | /* |
| 1968 | * Note : only 32-bit writes! |
| 1969 | */ |
| 1970 | int netxen_nic_pci_write_immediate_2M(struct netxen_adapter *adapter, |
| 1971 | u64 off, u32 data) |
| 1972 | { |
Dhananjay Phadke | f98a9f6 | 2009-04-07 22:50:45 +0000 | [diff] [blame] | 1973 | NXWR32(adapter, off, data); |
Dhananjay Phadke | 3ce06a3 | 2008-07-21 19:44:03 -0700 | [diff] [blame] | 1974 | |
| 1975 | return 0; |
| 1976 | } |
| 1977 | |
| 1978 | u32 netxen_nic_pci_read_immediate_2M(struct netxen_adapter *adapter, u64 off) |
| 1979 | { |
Dhananjay Phadke | f98a9f6 | 2009-04-07 22:50:45 +0000 | [diff] [blame] | 1980 | return NXRD32(adapter, off); |
Dhananjay Phadke | 3ce06a3 | 2008-07-21 19:44:03 -0700 | [diff] [blame] | 1981 | } |
| 1982 | |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 1983 | int netxen_nic_get_board_info(struct netxen_adapter *adapter) |
| 1984 | { |
Dhananjay Phadke | 1e2d005 | 2009-03-09 08:50:56 +0000 | [diff] [blame] | 1985 | int offset, board_type, magic, header_version; |
| 1986 | struct pci_dev *pdev = adapter->pdev; |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 1987 | |
Dhananjay Phadke | 06db58c | 2009-08-05 07:34:08 +0000 | [diff] [blame] | 1988 | offset = NX_FW_MAGIC_OFFSET; |
Dhananjay Phadke | 1e2d005 | 2009-03-09 08:50:56 +0000 | [diff] [blame] | 1989 | if (netxen_rom_fast_read(adapter, offset, &magic)) |
| 1990 | return -EIO; |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 1991 | |
Dhananjay Phadke | 06db58c | 2009-08-05 07:34:08 +0000 | [diff] [blame] | 1992 | offset = NX_HDR_VERSION_OFFSET; |
Dhananjay Phadke | 1e2d005 | 2009-03-09 08:50:56 +0000 | [diff] [blame] | 1993 | if (netxen_rom_fast_read(adapter, offset, &header_version)) |
| 1994 | return -EIO; |
| 1995 | |
| 1996 | if (magic != NETXEN_BDINFO_MAGIC || |
| 1997 | header_version != NETXEN_BDINFO_VERSION) { |
| 1998 | dev_err(&pdev->dev, |
| 1999 | "invalid board config, magic=%08x, version=%08x\n", |
| 2000 | magic, header_version); |
| 2001 | return -EIO; |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 2002 | } |
| 2003 | |
Dhananjay Phadke | 06db58c | 2009-08-05 07:34:08 +0000 | [diff] [blame] | 2004 | offset = NX_BRDTYPE_OFFSET; |
Dhananjay Phadke | 1e2d005 | 2009-03-09 08:50:56 +0000 | [diff] [blame] | 2005 | if (netxen_rom_fast_read(adapter, offset, &board_type)) |
| 2006 | return -EIO; |
| 2007 | |
| 2008 | adapter->ahw.board_type = board_type; |
| 2009 | |
| 2010 | if (board_type == NETXEN_BRDTYPE_P3_4_GB_MM) { |
Dhananjay Phadke | f98a9f6 | 2009-04-07 22:50:45 +0000 | [diff] [blame] | 2011 | u32 gpio = NXRD32(adapter, NETXEN_ROMUSB_GLB_PAD_GPIO_I); |
Dhananjay Phadke | c7860a2 | 2009-01-14 20:48:32 -0800 | [diff] [blame] | 2012 | if ((gpio & 0x8000) == 0) |
Dhananjay Phadke | 1e2d005 | 2009-03-09 08:50:56 +0000 | [diff] [blame] | 2013 | board_type = NETXEN_BRDTYPE_P3_10G_TP; |
Dhananjay Phadke | c7860a2 | 2009-01-14 20:48:32 -0800 | [diff] [blame] | 2014 | } |
| 2015 | |
Dhananjay Phadke | e98e335 | 2009-04-07 22:50:38 +0000 | [diff] [blame] | 2016 | switch (board_type) { |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 2017 | case NETXEN_BRDTYPE_P2_SB35_4G: |
Dhananjay Phadke | 1e2d005 | 2009-03-09 08:50:56 +0000 | [diff] [blame] | 2018 | adapter->ahw.port_type = NETXEN_NIC_GBE; |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 2019 | break; |
| 2020 | case NETXEN_BRDTYPE_P2_SB31_10G: |
| 2021 | case NETXEN_BRDTYPE_P2_SB31_10G_IMEZ: |
| 2022 | case NETXEN_BRDTYPE_P2_SB31_10G_HMEZ: |
| 2023 | case NETXEN_BRDTYPE_P2_SB31_10G_CX4: |
Dhananjay Phadke | e4c93c8 | 2008-07-21 19:44:02 -0700 | [diff] [blame] | 2024 | case NETXEN_BRDTYPE_P3_HMEZ: |
| 2025 | case NETXEN_BRDTYPE_P3_XG_LOM: |
| 2026 | case NETXEN_BRDTYPE_P3_10G_CX4: |
| 2027 | case NETXEN_BRDTYPE_P3_10G_CX4_LP: |
| 2028 | case NETXEN_BRDTYPE_P3_IMEZ: |
| 2029 | case NETXEN_BRDTYPE_P3_10G_SFP_PLUS: |
Dhananjay Phadke | a70f939 | 2008-08-01 03:14:56 -0700 | [diff] [blame] | 2030 | case NETXEN_BRDTYPE_P3_10G_SFP_CT: |
| 2031 | case NETXEN_BRDTYPE_P3_10G_SFP_QT: |
Dhananjay Phadke | e4c93c8 | 2008-07-21 19:44:02 -0700 | [diff] [blame] | 2032 | case NETXEN_BRDTYPE_P3_10G_XFP: |
| 2033 | case NETXEN_BRDTYPE_P3_10000_BASE_T: |
Dhananjay Phadke | 1e2d005 | 2009-03-09 08:50:56 +0000 | [diff] [blame] | 2034 | adapter->ahw.port_type = NETXEN_NIC_XGBE; |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 2035 | break; |
| 2036 | case NETXEN_BRDTYPE_P1_BD: |
| 2037 | case NETXEN_BRDTYPE_P1_SB: |
| 2038 | case NETXEN_BRDTYPE_P1_SMAX: |
| 2039 | case NETXEN_BRDTYPE_P1_SOCK: |
Dhananjay Phadke | e4c93c8 | 2008-07-21 19:44:02 -0700 | [diff] [blame] | 2040 | case NETXEN_BRDTYPE_P3_REF_QG: |
| 2041 | case NETXEN_BRDTYPE_P3_4_GB: |
| 2042 | case NETXEN_BRDTYPE_P3_4_GB_MM: |
Dhananjay Phadke | 1e2d005 | 2009-03-09 08:50:56 +0000 | [diff] [blame] | 2043 | adapter->ahw.port_type = NETXEN_NIC_GBE; |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 2044 | break; |
Dhananjay Phadke | c7860a2 | 2009-01-14 20:48:32 -0800 | [diff] [blame] | 2045 | case NETXEN_BRDTYPE_P3_10G_TP: |
Dhananjay Phadke | 1e2d005 | 2009-03-09 08:50:56 +0000 | [diff] [blame] | 2046 | adapter->ahw.port_type = (adapter->portnum < 2) ? |
Dhananjay Phadke | c7860a2 | 2009-01-14 20:48:32 -0800 | [diff] [blame] | 2047 | NETXEN_NIC_XGBE : NETXEN_NIC_GBE; |
| 2048 | break; |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 2049 | default: |
Dhananjay Phadke | 1e2d005 | 2009-03-09 08:50:56 +0000 | [diff] [blame] | 2050 | dev_err(&pdev->dev, "unknown board type %x\n", board_type); |
| 2051 | adapter->ahw.port_type = NETXEN_NIC_XGBE; |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 2052 | break; |
| 2053 | } |
| 2054 | |
Dhananjay Phadke | 1e2d005 | 2009-03-09 08:50:56 +0000 | [diff] [blame] | 2055 | return 0; |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 2056 | } |
| 2057 | |
| 2058 | /* NIU access sections */ |
| 2059 | |
Mithlesh Thukral | 3176ff3 | 2007-04-20 07:52:37 -0700 | [diff] [blame] | 2060 | int netxen_nic_set_mtu_gb(struct netxen_adapter *adapter, int new_mtu) |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 2061 | { |
Dhananjay Phadke | 9ad2764 | 2008-08-01 03:14:59 -0700 | [diff] [blame] | 2062 | new_mtu += MTU_FUDGE_FACTOR; |
Dhananjay Phadke | f98a9f6 | 2009-04-07 22:50:45 +0000 | [diff] [blame] | 2063 | NXWR32(adapter, NETXEN_NIU_GB_MAX_FRAME_SIZE(adapter->physical_port), |
Dhananjay Phadke | 3276fba | 2008-06-15 22:59:44 -0700 | [diff] [blame] | 2064 | new_mtu); |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 2065 | return 0; |
| 2066 | } |
| 2067 | |
Mithlesh Thukral | 3176ff3 | 2007-04-20 07:52:37 -0700 | [diff] [blame] | 2068 | int netxen_nic_set_mtu_xgb(struct netxen_adapter *adapter, int new_mtu) |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 2069 | { |
Dhananjay Phadke | 9ad2764 | 2008-08-01 03:14:59 -0700 | [diff] [blame] | 2070 | new_mtu += MTU_FUDGE_FACTOR; |
Dhananjay Phadke | 3276fba | 2008-06-15 22:59:44 -0700 | [diff] [blame] | 2071 | if (adapter->physical_port == 0) |
Dhananjay Phadke | f98a9f6 | 2009-04-07 22:50:45 +0000 | [diff] [blame] | 2072 | NXWR32(adapter, NETXEN_NIU_XGE_MAX_FRAME_SIZE, new_mtu); |
Jeff Garzik | 4790654 | 2007-11-23 21:23:36 -0500 | [diff] [blame] | 2073 | else |
Dhananjay Phadke | f98a9f6 | 2009-04-07 22:50:45 +0000 | [diff] [blame] | 2074 | NXWR32(adapter, NETXEN_NIU_XG1_MAX_FRAME_SIZE, new_mtu); |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 2075 | return 0; |
| 2076 | } |
| 2077 | |
Mithlesh Thukral | 3176ff3 | 2007-04-20 07:52:37 -0700 | [diff] [blame] | 2078 | void netxen_nic_set_link_parameters(struct netxen_adapter *adapter) |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 2079 | { |
Al Viro | a608ab9c | 2007-01-02 10:39:10 +0000 | [diff] [blame] | 2080 | __u32 status; |
| 2081 | __u32 autoneg; |
Dhananjay Phadke | 24a7a45 | 2008-08-01 03:14:55 -0700 | [diff] [blame] | 2082 | __u32 port_mode; |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 2083 | |
Dhananjay Phadke | c7860a2 | 2009-01-14 20:48:32 -0800 | [diff] [blame] | 2084 | if (!netif_carrier_ok(adapter->netdev)) { |
| 2085 | adapter->link_speed = 0; |
| 2086 | adapter->link_duplex = -1; |
| 2087 | adapter->link_autoneg = AUTONEG_ENABLE; |
| 2088 | return; |
| 2089 | } |
Dhananjay Phadke | 24a7a45 | 2008-08-01 03:14:55 -0700 | [diff] [blame] | 2090 | |
Dhananjay Phadke | 1e2d005 | 2009-03-09 08:50:56 +0000 | [diff] [blame] | 2091 | if (adapter->ahw.port_type == NETXEN_NIC_GBE) { |
Dhananjay Phadke | f98a9f6 | 2009-04-07 22:50:45 +0000 | [diff] [blame] | 2092 | port_mode = NXRD32(adapter, NETXEN_PORT_MODE_ADDR); |
Dhananjay Phadke | 24a7a45 | 2008-08-01 03:14:55 -0700 | [diff] [blame] | 2093 | if (port_mode == NETXEN_PORT_MODE_802_3_AP) { |
| 2094 | adapter->link_speed = SPEED_1000; |
| 2095 | adapter->link_duplex = DUPLEX_FULL; |
| 2096 | adapter->link_autoneg = AUTONEG_DISABLE; |
| 2097 | return; |
| 2098 | } |
| 2099 | |
Amit S. Kale | 80922fb | 2006-12-04 09:18:00 -0800 | [diff] [blame] | 2100 | if (adapter->phy_read |
Dhananjay Phadke | 24a7a45 | 2008-08-01 03:14:55 -0700 | [diff] [blame] | 2101 | && adapter->phy_read(adapter, |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 2102 | NETXEN_NIU_GB_MII_MGMT_ADDR_PHY_STATUS, |
| 2103 | &status) == 0) { |
| 2104 | if (netxen_get_phy_link(status)) { |
| 2105 | switch (netxen_get_phy_speed(status)) { |
| 2106 | case 0: |
Mithlesh Thukral | 3176ff3 | 2007-04-20 07:52:37 -0700 | [diff] [blame] | 2107 | adapter->link_speed = SPEED_10; |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 2108 | break; |
| 2109 | case 1: |
Mithlesh Thukral | 3176ff3 | 2007-04-20 07:52:37 -0700 | [diff] [blame] | 2110 | adapter->link_speed = SPEED_100; |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 2111 | break; |
| 2112 | case 2: |
Mithlesh Thukral | 3176ff3 | 2007-04-20 07:52:37 -0700 | [diff] [blame] | 2113 | adapter->link_speed = SPEED_1000; |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 2114 | break; |
| 2115 | default: |
Dhananjay Phadke | c7860a2 | 2009-01-14 20:48:32 -0800 | [diff] [blame] | 2116 | adapter->link_speed = 0; |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 2117 | break; |
| 2118 | } |
| 2119 | switch (netxen_get_phy_duplex(status)) { |
| 2120 | case 0: |
Mithlesh Thukral | 3176ff3 | 2007-04-20 07:52:37 -0700 | [diff] [blame] | 2121 | adapter->link_duplex = DUPLEX_HALF; |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 2122 | break; |
| 2123 | case 1: |
Mithlesh Thukral | 3176ff3 | 2007-04-20 07:52:37 -0700 | [diff] [blame] | 2124 | adapter->link_duplex = DUPLEX_FULL; |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 2125 | break; |
| 2126 | default: |
Mithlesh Thukral | 3176ff3 | 2007-04-20 07:52:37 -0700 | [diff] [blame] | 2127 | adapter->link_duplex = -1; |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 2128 | break; |
| 2129 | } |
Amit S. Kale | 80922fb | 2006-12-04 09:18:00 -0800 | [diff] [blame] | 2130 | if (adapter->phy_read |
Dhananjay Phadke | 24a7a45 | 2008-08-01 03:14:55 -0700 | [diff] [blame] | 2131 | && adapter->phy_read(adapter, |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 2132 | NETXEN_NIU_GB_MII_MGMT_ADDR_AUTONEG, |
Amit S. Kale | ed25ffa | 2006-12-04 09:23:25 -0800 | [diff] [blame] | 2133 | &autoneg) != 0) |
Mithlesh Thukral | 3176ff3 | 2007-04-20 07:52:37 -0700 | [diff] [blame] | 2134 | adapter->link_autoneg = autoneg; |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 2135 | } else |
| 2136 | goto link_down; |
| 2137 | } else { |
| 2138 | link_down: |
Dhananjay Phadke | c7860a2 | 2009-01-14 20:48:32 -0800 | [diff] [blame] | 2139 | adapter->link_speed = 0; |
Mithlesh Thukral | 3176ff3 | 2007-04-20 07:52:37 -0700 | [diff] [blame] | 2140 | adapter->link_duplex = -1; |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 2141 | } |
| 2142 | } |
| 2143 | } |
| 2144 | |
Dhananjay Phadke | 1e2d005 | 2009-03-09 08:50:56 +0000 | [diff] [blame] | 2145 | void netxen_nic_get_firmware_info(struct netxen_adapter *adapter) |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 2146 | { |
Dhananjay Phadke | 1e2d005 | 2009-03-09 08:50:56 +0000 | [diff] [blame] | 2147 | u32 fw_major, fw_minor, fw_build; |
Amit S. Kale | cb8011a | 2006-11-29 09:00:10 -0800 | [diff] [blame] | 2148 | char brd_name[NETXEN_MAX_SHORT_NAME]; |
Harvey Harrison | 8d74849 | 2008-04-22 11:48:35 -0700 | [diff] [blame] | 2149 | char serial_num[32]; |
Dhananjay Phadke | 06db58c | 2009-08-05 07:34:08 +0000 | [diff] [blame] | 2150 | int i, offset, val; |
Dhananjay Phadke | d8313ce | 2009-02-17 20:26:44 -0800 | [diff] [blame] | 2151 | int *ptr32; |
Dhananjay Phadke | 1e2d005 | 2009-03-09 08:50:56 +0000 | [diff] [blame] | 2152 | struct pci_dev *pdev = adapter->pdev; |
Harvey Harrison | 8d74849 | 2008-04-22 11:48:35 -0700 | [diff] [blame] | 2153 | |
Dhananjay Phadke | dcd56fd | 2008-06-15 22:59:45 -0700 | [diff] [blame] | 2154 | adapter->driver_mismatch = 0; |
| 2155 | |
Dhananjay Phadke | d8313ce | 2009-02-17 20:26:44 -0800 | [diff] [blame] | 2156 | ptr32 = (int *)&serial_num; |
Dhananjay Phadke | 06db58c | 2009-08-05 07:34:08 +0000 | [diff] [blame] | 2157 | offset = NX_FW_SERIAL_NUM_OFFSET; |
Dhananjay Phadke | dcd56fd | 2008-06-15 22:59:45 -0700 | [diff] [blame] | 2158 | for (i = 0; i < 8; i++) { |
Dhananjay Phadke | 06db58c | 2009-08-05 07:34:08 +0000 | [diff] [blame] | 2159 | if (netxen_rom_fast_read(adapter, offset, &val) == -1) { |
Dhananjay Phadke | fbb52f2 | 2009-03-13 14:52:01 +0000 | [diff] [blame] | 2160 | dev_err(&pdev->dev, "error reading board info\n"); |
Dhananjay Phadke | dcd56fd | 2008-06-15 22:59:45 -0700 | [diff] [blame] | 2161 | adapter->driver_mismatch = 1; |
| 2162 | return; |
| 2163 | } |
Dhananjay Phadke | fbb52f2 | 2009-03-13 14:52:01 +0000 | [diff] [blame] | 2164 | ptr32[i] = cpu_to_le32(val); |
Dhananjay Phadke | 06db58c | 2009-08-05 07:34:08 +0000 | [diff] [blame] | 2165 | offset += sizeof(u32); |
Dhananjay Phadke | dcd56fd | 2008-06-15 22:59:45 -0700 | [diff] [blame] | 2166 | } |
| 2167 | |
Dhananjay Phadke | f98a9f6 | 2009-04-07 22:50:45 +0000 | [diff] [blame] | 2168 | fw_major = NXRD32(adapter, NETXEN_FW_VERSION_MAJOR); |
| 2169 | fw_minor = NXRD32(adapter, NETXEN_FW_VERSION_MINOR); |
| 2170 | fw_build = NXRD32(adapter, NETXEN_FW_VERSION_SUB); |
Dhananjay Phadke | dcd56fd | 2008-06-15 22:59:45 -0700 | [diff] [blame] | 2171 | |
Dhananjay Phadke | 1e2d005 | 2009-03-09 08:50:56 +0000 | [diff] [blame] | 2172 | adapter->fw_version = NETXEN_VERSION_CODE(fw_major, fw_minor, fw_build); |
Dhananjay Phadke | 2956640 | 2008-07-21 19:44:04 -0700 | [diff] [blame] | 2173 | |
Dhananjay Phadke | dcd56fd | 2008-06-15 22:59:45 -0700 | [diff] [blame] | 2174 | if (adapter->portnum == 0) { |
Dhananjay Phadke | 1e2d005 | 2009-03-09 08:50:56 +0000 | [diff] [blame] | 2175 | get_brd_name_by_type(adapter->ahw.board_type, brd_name); |
Amit S. Kale | cb8011a | 2006-11-29 09:00:10 -0800 | [diff] [blame] | 2176 | |
Dhananjay Phadke | 11d89d6 | 2008-08-08 00:08:45 -0700 | [diff] [blame] | 2177 | printk(KERN_INFO "NetXen %s Board S/N %s Chip rev 0x%x\n", |
| 2178 | brd_name, serial_num, adapter->ahw.revision_id); |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 2179 | } |
Dhananjay Phadke | dcd56fd | 2008-06-15 22:59:45 -0700 | [diff] [blame] | 2180 | |
Dhananjay Phadke | 1e2d005 | 2009-03-09 08:50:56 +0000 | [diff] [blame] | 2181 | if (adapter->fw_version < NETXEN_VERSION_CODE(3, 4, 216)) { |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 2182 | adapter->driver_mismatch = 1; |
Dhananjay Phadke | 1e2d005 | 2009-03-09 08:50:56 +0000 | [diff] [blame] | 2183 | dev_warn(&pdev->dev, "firmware version %d.%d.%d unsupported\n", |
Dhananjay Phadke | 5873556 | 2008-07-21 19:44:10 -0700 | [diff] [blame] | 2184 | fw_major, fw_minor, fw_build); |
Dhananjay Phadke | dcd56fd | 2008-06-15 22:59:45 -0700 | [diff] [blame] | 2185 | return; |
| 2186 | } |
Dhananjay Phadke | 1e2d005 | 2009-03-09 08:50:56 +0000 | [diff] [blame] | 2187 | |
| 2188 | dev_info(&pdev->dev, "firmware version %d.%d.%d\n", |
| 2189 | fw_major, fw_minor, fw_build); |
| 2190 | |
| 2191 | if (NX_IS_REVISION_P3(adapter->ahw.revision_id)) { |
Dhananjay Phadke | d173346 | 2009-06-17 17:27:24 +0000 | [diff] [blame] | 2192 | i = NXRD32(adapter, NETXEN_SRE_MISC); |
| 2193 | adapter->ahw.cut_through = (i & 0x8000) ? 1 : 0; |
Dhananjay Phadke | 1e2d005 | 2009-03-09 08:50:56 +0000 | [diff] [blame] | 2194 | dev_info(&pdev->dev, "firmware running in %s mode\n", |
| 2195 | adapter->ahw.cut_through ? "cut-through" : "legacy"); |
| 2196 | } |
Dhananjay Phadke | 68b3cae | 2009-07-26 20:07:36 +0000 | [diff] [blame] | 2197 | |
| 2198 | if (adapter->fw_version >= NETXEN_VERSION_CODE(4, 0, 222)) |
| 2199 | adapter->capabilities = NXRD32(adapter, CRB_FW_CAPABILITIES_1); |
Narender Kumar | 1bb482f | 2009-08-23 08:35:09 +0000 | [diff] [blame] | 2200 | |
| 2201 | adapter->flags &= ~NETXEN_NIC_LRO_ENABLED; |
Amit S. Kale | 3d396eb | 2006-10-21 15:33:03 -0400 | [diff] [blame] | 2202 | } |
| 2203 | |
Dhananjay Phadke | 0b72e65 | 2009-03-13 14:52:02 +0000 | [diff] [blame] | 2204 | int |
| 2205 | netxen_nic_wol_supported(struct netxen_adapter *adapter) |
| 2206 | { |
| 2207 | u32 wol_cfg; |
| 2208 | |
| 2209 | if (NX_IS_REVISION_P2(adapter->ahw.revision_id)) |
| 2210 | return 0; |
| 2211 | |
Dhananjay Phadke | f98a9f6 | 2009-04-07 22:50:45 +0000 | [diff] [blame] | 2212 | wol_cfg = NXRD32(adapter, NETXEN_WOL_CONFIG_NV); |
Dhananjay Phadke | 0b72e65 | 2009-03-13 14:52:02 +0000 | [diff] [blame] | 2213 | if (wol_cfg & (1UL << adapter->portnum)) { |
Dhananjay Phadke | f98a9f6 | 2009-04-07 22:50:45 +0000 | [diff] [blame] | 2214 | wol_cfg = NXRD32(adapter, NETXEN_WOL_CONFIG); |
Dhananjay Phadke | 0b72e65 | 2009-03-13 14:52:02 +0000 | [diff] [blame] | 2215 | if (wol_cfg & (1 << adapter->portnum)) |
| 2216 | return 1; |
| 2217 | } |
| 2218 | |
| 2219 | return 0; |
| 2220 | } |