aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/netxen/netxen_nic_hw.c
diff options
context:
space:
mode:
authorDhananjay Phadke <dhananjay@netxen.com>2009-03-09 04:50:56 -0400
committerDavid S. Miller <davem@davemloft.net>2009-03-10 08:10:04 -0400
commit1e2d0059fc24c84356721c16c2ad0590c38015a0 (patch)
treed968ab1ea6c4a7b3fe95cb75686576d57c0ab2e9 /drivers/net/netxen/netxen_nic_hw.c
parentbecf46a012db667c562bbbe589c14e100b62e5a4 (diff)
netxen: annotate board_config and board_type
Remove huge board config structure from each instance, read only necessary fields from flash. Replace board_type with port_type (1G/10G), there's another board_type field describing card type (SFP/XFP/CX4). Signed-off-by: Dhananjay Phadke <dhananjay@netxen.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/netxen/netxen_nic_hw.c')
-rw-r--r--drivers/net/netxen/netxen_nic_hw.c108
1 files changed, 54 insertions, 54 deletions
diff --git a/drivers/net/netxen/netxen_nic_hw.c b/drivers/net/netxen/netxen_nic_hw.c
index b564d69cfa45..a93ab589d9ce 100644
--- a/drivers/net/netxen/netxen_nic_hw.c
+++ b/drivers/net/netxen/netxen_nic_hw.c
@@ -728,9 +728,8 @@ int netxen_is_flash_supported(struct netxen_adapter *adapter)
728static int netxen_get_flash_block(struct netxen_adapter *adapter, int base, 728static int netxen_get_flash_block(struct netxen_adapter *adapter, int base,
729 int size, __le32 * buf) 729 int size, __le32 * buf)
730{ 730{
731 int i, addr; 731 int i, v, addr;
732 __le32 *ptr32; 732 __le32 *ptr32;
733 u32 v;
734 733
735 addr = base; 734 addr = base;
736 ptr32 = buf; 735 ptr32 = buf;
@@ -2089,47 +2088,44 @@ u32 netxen_nic_pci_read_normalize_2M(struct netxen_adapter *adapter, u64 off)
2089 2088
2090int netxen_nic_get_board_info(struct netxen_adapter *adapter) 2089int netxen_nic_get_board_info(struct netxen_adapter *adapter)
2091{ 2090{
2092 int rv = 0; 2091 int offset, board_type, magic, header_version;
2093 int addr = NETXEN_BRDCFG_START; 2092 struct pci_dev *pdev = adapter->pdev;
2094 struct netxen_board_info *boardinfo;
2095 int index;
2096 int *ptr32;
2097 2093
2098 boardinfo = &adapter->ahw.boardcfg; 2094 offset = NETXEN_BRDCFG_START +
2099 ptr32 = (int *) boardinfo; 2095 offsetof(struct netxen_board_info, magic);
2096 if (netxen_rom_fast_read(adapter, offset, &magic))
2097 return -EIO;
2100 2098
2101 for (index = 0; index < sizeof(struct netxen_board_info) / sizeof(u32); 2099 offset = NETXEN_BRDCFG_START +
2102 index++) { 2100 offsetof(struct netxen_board_info, header_version);
2103 if (netxen_rom_fast_read(adapter, addr, ptr32) == -1) { 2101 if (netxen_rom_fast_read(adapter, offset, &header_version))
2104 return -EIO; 2102 return -EIO;
2105 } 2103
2106 ptr32++; 2104 if (magic != NETXEN_BDINFO_MAGIC ||
2107 addr += sizeof(u32); 2105 header_version != NETXEN_BDINFO_VERSION) {
2108 } 2106 dev_err(&pdev->dev,
2109 if (boardinfo->magic != NETXEN_BDINFO_MAGIC) { 2107 "invalid board config, magic=%08x, version=%08x\n",
2110 printk("%s: ERROR reading %s board config." 2108 magic, header_version);
2111 " Read %x, expected %x\n", netxen_nic_driver_name, 2109 return -EIO;
2112 netxen_nic_driver_name,
2113 boardinfo->magic, NETXEN_BDINFO_MAGIC);
2114 rv = -1;
2115 }
2116 if (boardinfo->header_version != NETXEN_BDINFO_VERSION) {
2117 printk("%s: Unknown board config version."
2118 " Read %x, expected %x\n", netxen_nic_driver_name,
2119 boardinfo->header_version, NETXEN_BDINFO_VERSION);
2120 rv = -1;
2121 } 2110 }
2122 2111
2123 if (boardinfo->board_type == NETXEN_BRDTYPE_P3_4_GB_MM) { 2112 offset = NETXEN_BRDCFG_START +
2113 offsetof(struct netxen_board_info, board_type);
2114 if (netxen_rom_fast_read(adapter, offset, &board_type))
2115 return -EIO;
2116
2117 adapter->ahw.board_type = board_type;
2118
2119 if (board_type == NETXEN_BRDTYPE_P3_4_GB_MM) {
2124 u32 gpio = netxen_nic_reg_read(adapter, 2120 u32 gpio = netxen_nic_reg_read(adapter,
2125 NETXEN_ROMUSB_GLB_PAD_GPIO_I); 2121 NETXEN_ROMUSB_GLB_PAD_GPIO_I);
2126 if ((gpio & 0x8000) == 0) 2122 if ((gpio & 0x8000) == 0)
2127 boardinfo->board_type = NETXEN_BRDTYPE_P3_10G_TP; 2123 board_type = NETXEN_BRDTYPE_P3_10G_TP;
2128 } 2124 }
2129 2125
2130 switch ((netxen_brdtype_t) boardinfo->board_type) { 2126 switch ((netxen_brdtype_t)board_type) {
2131 case NETXEN_BRDTYPE_P2_SB35_4G: 2127 case NETXEN_BRDTYPE_P2_SB35_4G:
2132 adapter->ahw.board_type = NETXEN_NIC_GBE; 2128 adapter->ahw.port_type = NETXEN_NIC_GBE;
2133 break; 2129 break;
2134 case NETXEN_BRDTYPE_P2_SB31_10G: 2130 case NETXEN_BRDTYPE_P2_SB31_10G:
2135 case NETXEN_BRDTYPE_P2_SB31_10G_IMEZ: 2131 case NETXEN_BRDTYPE_P2_SB31_10G_IMEZ:
@@ -2145,7 +2141,7 @@ int netxen_nic_get_board_info(struct netxen_adapter *adapter)
2145 case NETXEN_BRDTYPE_P3_10G_SFP_QT: 2141 case NETXEN_BRDTYPE_P3_10G_SFP_QT:
2146 case NETXEN_BRDTYPE_P3_10G_XFP: 2142 case NETXEN_BRDTYPE_P3_10G_XFP:
2147 case NETXEN_BRDTYPE_P3_10000_BASE_T: 2143 case NETXEN_BRDTYPE_P3_10000_BASE_T:
2148 adapter->ahw.board_type = NETXEN_NIC_XGBE; 2144 adapter->ahw.port_type = NETXEN_NIC_XGBE;
2149 break; 2145 break;
2150 case NETXEN_BRDTYPE_P1_BD: 2146 case NETXEN_BRDTYPE_P1_BD:
2151 case NETXEN_BRDTYPE_P1_SB: 2147 case NETXEN_BRDTYPE_P1_SB:
@@ -2154,20 +2150,19 @@ int netxen_nic_get_board_info(struct netxen_adapter *adapter)
2154 case NETXEN_BRDTYPE_P3_REF_QG: 2150 case NETXEN_BRDTYPE_P3_REF_QG:
2155 case NETXEN_BRDTYPE_P3_4_GB: 2151 case NETXEN_BRDTYPE_P3_4_GB:
2156 case NETXEN_BRDTYPE_P3_4_GB_MM: 2152 case NETXEN_BRDTYPE_P3_4_GB_MM:
2157 adapter->ahw.board_type = NETXEN_NIC_GBE; 2153 adapter->ahw.port_type = NETXEN_NIC_GBE;
2158 break; 2154 break;
2159 case NETXEN_BRDTYPE_P3_10G_TP: 2155 case NETXEN_BRDTYPE_P3_10G_TP:
2160 adapter->ahw.board_type = (adapter->portnum < 2) ? 2156 adapter->ahw.port_type = (adapter->portnum < 2) ?
2161 NETXEN_NIC_XGBE : NETXEN_NIC_GBE; 2157 NETXEN_NIC_XGBE : NETXEN_NIC_GBE;
2162 break; 2158 break;
2163 default: 2159 default:
2164 printk("%s: Unknown(%x)\n", netxen_nic_driver_name, 2160 dev_err(&pdev->dev, "unknown board type %x\n", board_type);
2165 boardinfo->board_type); 2161 adapter->ahw.port_type = NETXEN_NIC_XGBE;
2166 rv = -ENODEV;
2167 break; 2162 break;
2168 } 2163 }
2169 2164
2170 return rv; 2165 return 0;
2171} 2166}
2172 2167
2173/* NIU access sections */ 2168/* NIU access sections */
@@ -2213,7 +2208,7 @@ void netxen_nic_set_link_parameters(struct netxen_adapter *adapter)
2213 return; 2208 return;
2214 } 2209 }
2215 2210
2216 if (adapter->ahw.board_type == NETXEN_NIC_GBE) { 2211 if (adapter->ahw.port_type == NETXEN_NIC_GBE) {
2217 adapter->hw_read_wx(adapter, 2212 adapter->hw_read_wx(adapter,
2218 NETXEN_PORT_MODE_ADDR, &port_mode, 4); 2213 NETXEN_PORT_MODE_ADDR, &port_mode, 4);
2219 if (port_mode == NETXEN_PORT_MODE_802_3_AP) { 2214 if (port_mode == NETXEN_PORT_MODE_802_3_AP) {
@@ -2268,17 +2263,14 @@ void netxen_nic_set_link_parameters(struct netxen_adapter *adapter)
2268 } 2263 }
2269} 2264}
2270 2265
2271void netxen_nic_flash_print(struct netxen_adapter *adapter) 2266void netxen_nic_get_firmware_info(struct netxen_adapter *adapter)
2272{ 2267{
2273 u32 fw_major = 0; 2268 u32 fw_major, fw_minor, fw_build;
2274 u32 fw_minor = 0;
2275 u32 fw_build = 0;
2276 char brd_name[NETXEN_MAX_SHORT_NAME]; 2269 char brd_name[NETXEN_MAX_SHORT_NAME];
2277 char serial_num[32]; 2270 char serial_num[32];
2278 int i, addr; 2271 int i, addr;
2279 int *ptr32; 2272 int *ptr32;
2280 2273 struct pci_dev *pdev = adapter->pdev;
2281 struct netxen_board_info *board_info = &(adapter->ahw.boardcfg);
2282 2274
2283 adapter->driver_mismatch = 0; 2275 adapter->driver_mismatch = 0;
2284 2276
@@ -2302,23 +2294,31 @@ void netxen_nic_flash_print(struct netxen_adapter *adapter)
2302 adapter->hw_read_wx(adapter, NETXEN_FW_VERSION_SUB, &fw_build, 4); 2294 adapter->hw_read_wx(adapter, NETXEN_FW_VERSION_SUB, &fw_build, 4);
2303 2295
2304 adapter->fw_major = fw_major; 2296 adapter->fw_major = fw_major;
2297 adapter->fw_version = NETXEN_VERSION_CODE(fw_major, fw_minor, fw_build);
2305 2298
2306 if (adapter->portnum == 0) { 2299 if (adapter->portnum == 0) {
2307 get_brd_name_by_type(board_info->board_type, brd_name); 2300 get_brd_name_by_type(adapter->ahw.board_type, brd_name);
2308 2301
2309 printk(KERN_INFO "NetXen %s Board S/N %s Chip rev 0x%x\n", 2302 printk(KERN_INFO "NetXen %s Board S/N %s Chip rev 0x%x\n",
2310 brd_name, serial_num, adapter->ahw.revision_id); 2303 brd_name, serial_num, adapter->ahw.revision_id);
2311 printk(KERN_INFO "NetXen Firmware version %d.%d.%d\n",
2312 fw_major, fw_minor, fw_build);
2313 } 2304 }
2314 2305
2315 if (NETXEN_VERSION_CODE(fw_major, fw_minor, fw_build) < 2306 if (adapter->fw_version < NETXEN_VERSION_CODE(3, 4, 216)) {
2316 NETXEN_VERSION_CODE(3, 4, 216)) {
2317 adapter->driver_mismatch = 1; 2307 adapter->driver_mismatch = 1;
2318 printk(KERN_ERR "%s: firmware version %d.%d.%d unsupported\n", 2308 dev_warn(&pdev->dev, "firmware version %d.%d.%d unsupported\n",
2319 netxen_nic_driver_name,
2320 fw_major, fw_minor, fw_build); 2309 fw_major, fw_minor, fw_build);
2321 return; 2310 return;
2322 } 2311 }
2312
2313 dev_info(&pdev->dev, "firmware version %d.%d.%d\n",
2314 fw_major, fw_minor, fw_build);
2315
2316 if (NX_IS_REVISION_P3(adapter->ahw.revision_id)) {
2317 adapter->hw_read_wx(adapter,
2318 NETXEN_MIU_MN_CONTROL, &i, 4);
2319 adapter->ahw.cut_through = (i & 0x4) ? 1 : 0;
2320 dev_info(&pdev->dev, "firmware running in %s mode\n",
2321 adapter->ahw.cut_through ? "cut-through" : "legacy");
2322 }
2323} 2323}
2324 2324