|  | @@ -17,6 +17,7 @@ FILE_LICENCE(GPL2_ONLY);
 | 
		
	
		
			
			| 17 | 17 |  #include <stdlib.h>
 | 
		
	
		
			
			| 18 | 18 |  #include <stdio.h>
 | 
		
	
		
			
			| 19 | 19 |  #include <ipxe/malloc.h>
 | 
		
	
		
			
			|  | 20 | +#include <ipxe/pci.h>
 | 
		
	
		
			
			| 20 | 21 |  #include <ipxe/iobuf.h>
 | 
		
	
		
			
			| 21 | 22 |  #include <ipxe/ethernet.h>
 | 
		
	
		
			
			| 22 | 23 |  #include <byteswap.h>
 | 
		
	
	
		
			
			|  | @@ -186,28 +187,47 @@ __vxge_hw_device_vpath_reset_in_prog_check(u64 __iomem *vpath_rst_in_prog)
 | 
		
	
		
			
			| 186 | 187 |  	return status;
 | 
		
	
		
			
			| 187 | 188 |  }
 | 
		
	
		
			
			| 188 | 189 |  
 | 
		
	
		
			
			|  | 190 | +/*
 | 
		
	
		
			
			|  | 191 | + * __vxge_hw_device_get_legacy_reg
 | 
		
	
		
			
			|  | 192 | + * This routine gets the legacy register section's memory mapped address
 | 
		
	
		
			
			|  | 193 | + * and sets the swapper.
 | 
		
	
		
			
			|  | 194 | + */
 | 
		
	
		
			
			|  | 195 | +static struct vxge_hw_legacy_reg __iomem *
 | 
		
	
		
			
			|  | 196 | +__vxge_hw_device_get_legacy_reg(struct pci_device *pdev, void __iomem *bar0)
 | 
		
	
		
			
			|  | 197 | +{
 | 
		
	
		
			
			|  | 198 | +	enum vxge_hw_status status;
 | 
		
	
		
			
			|  | 199 | +	struct vxge_hw_legacy_reg __iomem *legacy_reg;
 | 
		
	
		
			
			|  | 200 | +	/*
 | 
		
	
		
			
			|  | 201 | +	 * If the length of Bar0 is 16MB, then assume that we are configured
 | 
		
	
		
			
			|  | 202 | +	 * in MF8P_VP2 mode and then add 8MB to the legacy_reg offsets
 | 
		
	
		
			
			|  | 203 | +	 */
 | 
		
	
		
			
			|  | 204 | +	if (pci_bar_size(pdev, PCI_BASE_ADDRESS_0) == 0x1000000)
 | 
		
	
		
			
			|  | 205 | +		legacy_reg = (struct vxge_hw_legacy_reg __iomem *)
 | 
		
	
		
			
			|  | 206 | +				(bar0 + 0x800000);
 | 
		
	
		
			
			|  | 207 | +	else
 | 
		
	
		
			
			|  | 208 | +		legacy_reg = (struct vxge_hw_legacy_reg __iomem *)bar0;
 | 
		
	
		
			
			|  | 209 | +
 | 
		
	
		
			
			|  | 210 | +	status = __vxge_hw_legacy_swapper_set(legacy_reg);
 | 
		
	
		
			
			|  | 211 | +	if (status != VXGE_HW_OK)
 | 
		
	
		
			
			|  | 212 | +		return NULL;
 | 
		
	
		
			
			|  | 213 | +
 | 
		
	
		
			
			|  | 214 | +	return legacy_reg;
 | 
		
	
		
			
			|  | 215 | +}
 | 
		
	
		
			
			| 189 | 216 |  /*
 | 
		
	
		
			
			| 190 | 217 |   * __vxge_hw_device_toc_get
 | 
		
	
		
			
			| 191 | 218 |   * This routine sets the swapper and reads the toc pointer and returns the
 | 
		
	
		
			
			| 192 | 219 |   * memory mapped address of the toc
 | 
		
	
		
			
			| 193 | 220 |   */
 | 
		
	
		
			
			| 194 | 221 |  struct vxge_hw_toc_reg __iomem *
 | 
		
	
		
			
			| 195 |  | -__vxge_hw_device_toc_get(void __iomem *bar0)
 | 
		
	
		
			
			|  | 222 | +__vxge_hw_device_toc_get(void __iomem *bar0,
 | 
		
	
		
			
			|  | 223 | +	struct vxge_hw_legacy_reg __iomem *legacy_reg)
 | 
		
	
		
			
			| 196 | 224 |  {
 | 
		
	
		
			
			| 197 | 225 |  	u64 val64;
 | 
		
	
		
			
			| 198 | 226 |  	struct vxge_hw_toc_reg __iomem *toc = NULL;
 | 
		
	
		
			
			| 199 |  | -	enum vxge_hw_status status;
 | 
		
	
		
			
			| 200 |  | -
 | 
		
	
		
			
			| 201 |  | -	struct vxge_hw_legacy_reg __iomem *legacy_reg =
 | 
		
	
		
			
			| 202 |  | -		(struct vxge_hw_legacy_reg __iomem *)bar0;
 | 
		
	
		
			
			| 203 |  | -
 | 
		
	
		
			
			| 204 |  | -	status = __vxge_hw_legacy_swapper_set(legacy_reg);
 | 
		
	
		
			
			| 205 |  | -	if (status != VXGE_HW_OK)
 | 
		
	
		
			
			| 206 |  | -		goto exit;
 | 
		
	
		
			
			| 207 | 227 |  
 | 
		
	
		
			
			| 208 | 228 |  	val64 =	readq(&legacy_reg->toc_first_pointer);
 | 
		
	
		
			
			| 209 | 229 |  	toc = (struct vxge_hw_toc_reg __iomem *)(bar0+val64);
 | 
		
	
		
			
			| 210 |  | -exit:
 | 
		
	
		
			
			|  | 230 | +
 | 
		
	
		
			
			| 211 | 231 |  	return toc;
 | 
		
	
		
			
			| 212 | 232 |  }
 | 
		
	
		
			
			| 213 | 233 |  
 | 
		
	
	
		
			
			|  | @@ -224,9 +244,15 @@ __vxge_hw_device_reg_addr_get(struct __vxge_hw_device *hldev)
 | 
		
	
		
			
			| 224 | 244 |  	u32 i;
 | 
		
	
		
			
			| 225 | 245 |  	enum vxge_hw_status status = VXGE_HW_OK;
 | 
		
	
		
			
			| 226 | 246 |  
 | 
		
	
		
			
			| 227 |  | -	hldev->legacy_reg = (struct vxge_hw_legacy_reg __iomem *)hldev->bar0;
 | 
		
	
		
			
			|  | 247 | +	hldev->legacy_reg = __vxge_hw_device_get_legacy_reg(hldev->pdev,
 | 
		
	
		
			
			|  | 248 | +					hldev->bar0);
 | 
		
	
		
			
			|  | 249 | +	if (hldev->legacy_reg  == NULL) {
 | 
		
	
		
			
			|  | 250 | +		status = VXGE_HW_FAIL;
 | 
		
	
		
			
			|  | 251 | +		goto exit;
 | 
		
	
		
			
			|  | 252 | +	}
 | 
		
	
		
			
			| 228 | 253 |  
 | 
		
	
		
			
			| 229 |  | -	hldev->toc_reg = __vxge_hw_device_toc_get(hldev->bar0);
 | 
		
	
		
			
			|  | 254 | +	hldev->toc_reg = __vxge_hw_device_toc_get(hldev->bar0,
 | 
		
	
		
			
			|  | 255 | +					hldev->legacy_reg);
 | 
		
	
		
			
			| 230 | 256 |  	if (hldev->toc_reg  == NULL) {
 | 
		
	
		
			
			| 231 | 257 |  		status = VXGE_HW_FAIL;
 | 
		
	
		
			
			| 232 | 258 |  		goto exit;
 | 
		
	
	
		
			
			|  | @@ -234,7 +260,7 @@ __vxge_hw_device_reg_addr_get(struct __vxge_hw_device *hldev)
 | 
		
	
		
			
			| 234 | 260 |  
 | 
		
	
		
			
			| 235 | 261 |  	val64 = readq(&hldev->toc_reg->toc_common_pointer);
 | 
		
	
		
			
			| 236 | 262 |  	hldev->common_reg =
 | 
		
	
		
			
			| 237 |  | -	(struct vxge_hw_common_reg __iomem *)(hldev->bar0 + val64);
 | 
		
	
		
			
			|  | 263 | +		(struct vxge_hw_common_reg __iomem *)(hldev->bar0 + val64);
 | 
		
	
		
			
			| 238 | 264 |  
 | 
		
	
		
			
			| 239 | 265 |  	val64 = readq(&hldev->toc_reg->toc_mrpcim_pointer);
 | 
		
	
		
			
			| 240 | 266 |  	hldev->mrpcim_reg =
 | 
		
	
	
		
			
			|  | @@ -355,7 +381,7 @@ void __vxge_hw_device_host_info_get(struct __vxge_hw_device *hldev)
 | 
		
	
		
			
			| 355 | 381 |   * each vpath
 | 
		
	
		
			
			| 356 | 382 |   */
 | 
		
	
		
			
			| 357 | 383 |  enum vxge_hw_status
 | 
		
	
		
			
			| 358 |  | -vxge_hw_device_hw_info_get(void __iomem *bar0,
 | 
		
	
		
			
			|  | 384 | +vxge_hw_device_hw_info_get(struct pci_device *pdev, void __iomem *bar0,
 | 
		
	
		
			
			| 359 | 385 |  				struct vxge_hw_device_hw_info *hw_info)
 | 
		
	
		
			
			| 360 | 386 |  {
 | 
		
	
		
			
			| 361 | 387 |  	u32 i;
 | 
		
	
	
		
			
			|  | @@ -365,13 +391,20 @@ vxge_hw_device_hw_info_get(void __iomem *bar0,
 | 
		
	
		
			
			| 365 | 391 |  	struct vxge_hw_common_reg __iomem *common_reg;
 | 
		
	
		
			
			| 366 | 392 |  	struct vxge_hw_vpath_reg __iomem *vpath_reg;
 | 
		
	
		
			
			| 367 | 393 |  	struct vxge_hw_vpmgmt_reg __iomem *vpmgmt_reg;
 | 
		
	
		
			
			|  | 394 | +	struct vxge_hw_legacy_reg __iomem *legacy_reg;
 | 
		
	
		
			
			| 368 | 395 |  	enum vxge_hw_status status;
 | 
		
	
		
			
			| 369 | 396 |  
 | 
		
	
		
			
			| 370 | 397 |  	vxge_trace();
 | 
		
	
		
			
			| 371 | 398 |  
 | 
		
	
		
			
			| 372 | 399 |  	memset(hw_info, 0, sizeof(struct vxge_hw_device_hw_info));
 | 
		
	
		
			
			| 373 | 400 |  
 | 
		
	
		
			
			| 374 |  | -	toc = __vxge_hw_device_toc_get(bar0);
 | 
		
	
		
			
			|  | 401 | +	legacy_reg = __vxge_hw_device_get_legacy_reg(pdev, bar0);
 | 
		
	
		
			
			|  | 402 | +	if (legacy_reg == NULL) {
 | 
		
	
		
			
			|  | 403 | +		status = VXGE_HW_ERR_CRITICAL;
 | 
		
	
		
			
			|  | 404 | +		goto exit;
 | 
		
	
		
			
			|  | 405 | +	}
 | 
		
	
		
			
			|  | 406 | +
 | 
		
	
		
			
			|  | 407 | +	toc = __vxge_hw_device_toc_get(bar0, legacy_reg);
 | 
		
	
		
			
			| 375 | 408 |  	if (toc == NULL) {
 | 
		
	
		
			
			| 376 | 409 |  		status = VXGE_HW_ERR_CRITICAL;
 | 
		
	
		
			
			| 377 | 410 |  		goto exit;
 |