|  | @@ -133,6 +133,9 @@ static int arbel_cmd ( struct arbel *arbel, unsigned long command,
 | 
		
	
		
			
			| 133 | 133 |  	unsigned int i;
 | 
		
	
		
			
			| 134 | 134 |  	int rc;
 | 
		
	
		
			
			| 135 | 135 |  
 | 
		
	
		
			
			|  | 136 | +	assert ( in_len <= ARBEL_MBOX_SIZE );
 | 
		
	
		
			
			|  | 137 | +	assert ( out_len <= ARBEL_MBOX_SIZE );
 | 
		
	
		
			
			|  | 138 | +
 | 
		
	
		
			
			| 136 | 139 |  	DBGC2 ( arbel, "Arbel %p command %02x in %zx%s out %zx%s\n",
 | 
		
	
		
			
			| 137 | 140 |  		arbel, opcode, in_len,
 | 
		
	
		
			
			| 138 | 141 |  		( ( command & ARBEL_HCR_IN_MBOX ) ? "(mbox)" : "" ), out_len,
 | 
		
	
	
		
			
			|  | @@ -210,11 +213,19 @@ static inline int
 | 
		
	
		
			
			| 210 | 213 |  arbel_cmd_query_dev_lim ( struct arbel *arbel,
 | 
		
	
		
			
			| 211 | 214 |  			  struct arbelprm_query_dev_lim *dev_lim ) {
 | 
		
	
		
			
			| 212 | 215 |  	return arbel_cmd ( arbel,
 | 
		
	
		
			
			| 213 |  | -			   ARBEL_HCR_OUT_CMD ( ARBEL_HCR_QUERY_DEV_LIM, 
 | 
		
	
		
			
			|  | 216 | +			   ARBEL_HCR_OUT_CMD ( ARBEL_HCR_QUERY_DEV_LIM,
 | 
		
	
		
			
			| 214 | 217 |  					       1, sizeof ( *dev_lim ) ),
 | 
		
	
		
			
			| 215 | 218 |  			   0, NULL, 0, dev_lim );
 | 
		
	
		
			
			| 216 | 219 |  }
 | 
		
	
		
			
			| 217 | 220 |  
 | 
		
	
		
			
			|  | 221 | +static inline int
 | 
		
	
		
			
			|  | 222 | +arbel_cmd_query_fw ( struct arbel *arbel, struct arbelprm_query_fw *fw ) {
 | 
		
	
		
			
			|  | 223 | +	return arbel_cmd ( arbel,
 | 
		
	
		
			
			|  | 224 | +			   ARBEL_HCR_OUT_CMD ( ARBEL_HCR_QUERY_FW, 
 | 
		
	
		
			
			|  | 225 | +					       1, sizeof ( *fw ) ),
 | 
		
	
		
			
			|  | 226 | +			   0, NULL, 0, fw );
 | 
		
	
		
			
			|  | 227 | +}
 | 
		
	
		
			
			|  | 228 | +
 | 
		
	
		
			
			| 218 | 229 |  static inline int
 | 
		
	
		
			
			| 219 | 230 |  arbel_cmd_sw2hw_cq ( struct arbel *arbel, unsigned long cqn,
 | 
		
	
		
			
			| 220 | 231 |  		     const struct arbelprm_completion_queue_context *cqctx ) {
 | 
		
	
	
		
			
			|  | @@ -1300,6 +1311,7 @@ static int arbel_get_pkey ( struct arbel *arbel, unsigned int *pkey ) {
 | 
		
	
		
			
			| 1300 | 1311 |  static int arbel_probe ( struct pci_device *pci,
 | 
		
	
		
			
			| 1301 | 1312 |  			 const struct pci_device_id *id __unused ) {
 | 
		
	
		
			
			| 1302 | 1313 |  	struct ib_device *ibdev;
 | 
		
	
		
			
			|  | 1314 | +	struct arbelprm_query_fw fw;
 | 
		
	
		
			
			| 1303 | 1315 |  	struct arbelprm_query_dev_lim dev_lim;
 | 
		
	
		
			
			| 1304 | 1316 |  	struct arbel *arbel;
 | 
		
	
		
			
			| 1305 | 1317 |  	udqp_t qph;
 | 
		
	
	
		
			
			|  | @@ -1307,26 +1319,59 @@ static int arbel_probe ( struct pci_device *pci,
 | 
		
	
		
			
			| 1307 | 1319 |  
 | 
		
	
		
			
			| 1308 | 1320 |  	/* Allocate Infiniband device */
 | 
		
	
		
			
			| 1309 | 1321 |  	ibdev = alloc_ibdev ( sizeof ( *arbel ) );
 | 
		
	
		
			
			| 1310 |  | -	if ( ! ibdev )
 | 
		
	
		
			
			| 1311 |  | -		return -ENOMEM;
 | 
		
	
		
			
			|  | 1322 | +	if ( ! ibdev ) {
 | 
		
	
		
			
			|  | 1323 | +		rc = -ENOMEM;
 | 
		
	
		
			
			|  | 1324 | +		goto err_ibdev;
 | 
		
	
		
			
			|  | 1325 | +	}
 | 
		
	
		
			
			| 1312 | 1326 |  	ibdev->op = &arbel_ib_operations;
 | 
		
	
		
			
			| 1313 | 1327 |  	pci_set_drvdata ( pci, ibdev );
 | 
		
	
		
			
			| 1314 | 1328 |  	ibdev->dev = &pci->dev;
 | 
		
	
		
			
			| 1315 | 1329 |  	arbel = ibdev->dev_priv;
 | 
		
	
		
			
			| 1316 | 1330 |  	memset ( arbel, 0, sizeof ( *arbel ) );
 | 
		
	
		
			
			| 1317 | 1331 |  
 | 
		
	
		
			
			|  | 1332 | +	/* Allocate space for mailboxes */
 | 
		
	
		
			
			|  | 1333 | +	arbel->mailbox_in = malloc_dma ( ARBEL_MBOX_SIZE, ARBEL_MBOX_ALIGN );
 | 
		
	
		
			
			|  | 1334 | +	if ( ! arbel->mailbox_in ) {
 | 
		
	
		
			
			|  | 1335 | +		rc = -ENOMEM;
 | 
		
	
		
			
			|  | 1336 | +		goto err_mailbox_in;
 | 
		
	
		
			
			|  | 1337 | +	}
 | 
		
	
		
			
			|  | 1338 | +	arbel->mailbox_out = malloc_dma ( ARBEL_MBOX_SIZE, ARBEL_MBOX_ALIGN );
 | 
		
	
		
			
			|  | 1339 | +	if ( ! arbel->mailbox_out ) {
 | 
		
	
		
			
			|  | 1340 | +		rc = -ENOMEM;
 | 
		
	
		
			
			|  | 1341 | +		goto err_mailbox_out;
 | 
		
	
		
			
			|  | 1342 | +	}
 | 
		
	
		
			
			|  | 1343 | +
 | 
		
	
		
			
			| 1318 | 1344 |  	/* Fix up PCI device */
 | 
		
	
		
			
			| 1319 | 1345 |  	adjust_pci_device ( pci );
 | 
		
	
		
			
			| 1320 | 1346 |  
 | 
		
	
		
			
			|  | 1347 | +	/* Get PCI BARs */
 | 
		
	
		
			
			|  | 1348 | +	arbel->config = ioremap ( pci_bar_start ( pci, ARBEL_PCI_CONFIG_BAR ),
 | 
		
	
		
			
			|  | 1349 | +				  ARBEL_PCI_CONFIG_BAR_SIZE );
 | 
		
	
		
			
			|  | 1350 | +	arbel->uar = ioremap ( ( pci_bar_start ( pci, ARBEL_PCI_UAR_BAR ) +
 | 
		
	
		
			
			|  | 1351 | +				 ARBEL_PCI_UAR_IDX * ARBEL_PCI_UAR_SIZE ),
 | 
		
	
		
			
			|  | 1352 | +			       ARBEL_PCI_UAR_SIZE );
 | 
		
	
		
			
			|  | 1353 | +
 | 
		
	
		
			
			|  | 1354 | +	/* Initialise firmware */
 | 
		
	
		
			
			|  | 1355 | +	if ( ( rc = arbel_cmd_query_fw ( arbel, &fw ) ) != 0 ) {
 | 
		
	
		
			
			|  | 1356 | +		DBGC ( arbel, "Arbel %p could not query firmware: %s\n",
 | 
		
	
		
			
			|  | 1357 | +		       arbel, strerror ( rc ) );
 | 
		
	
		
			
			|  | 1358 | +		goto err_query_fw;
 | 
		
	
		
			
			|  | 1359 | +	}
 | 
		
	
		
			
			|  | 1360 | +	DBGC ( arbel, "Arbel %p firmware version %ld.%ld.%ld\n", arbel,
 | 
		
	
		
			
			|  | 1361 | +	       MLX_GET ( &fw, fw_rev_major ), MLX_GET ( &fw, fw_rev_minor ),
 | 
		
	
		
			
			|  | 1362 | +	       MLX_GET ( &fw, fw_rev_subminor ) );
 | 
		
	
		
			
			|  | 1363 | +
 | 
		
	
		
			
			| 1321 | 1364 |  	/* Initialise hardware */
 | 
		
	
		
			
			| 1322 | 1365 |  	if ( ( rc = ib_driver_init ( pci, &qph ) ) != 0 )
 | 
		
	
		
			
			| 1323 | 1366 |  		goto err_ib_driver_init;
 | 
		
	
		
			
			| 1324 | 1367 |  
 | 
		
	
		
			
			| 1325 | 1368 |  	/* Hack up IB structures */
 | 
		
	
		
			
			|  | 1369 | +#if 0
 | 
		
	
		
			
			| 1326 | 1370 |  	arbel->config = memfree_pci_dev.cr_space;
 | 
		
	
		
			
			|  | 1371 | +	arbel->uar = memfree_pci_dev.uar;
 | 
		
	
		
			
			| 1327 | 1372 |  	arbel->mailbox_in = dev_buffers_p->inprm_buf;
 | 
		
	
		
			
			| 1328 | 1373 |  	arbel->mailbox_out = dev_buffers_p->outprm_buf;
 | 
		
	
		
			
			| 1329 |  | -	arbel->uar = memfree_pci_dev.uar;
 | 
		
	
		
			
			|  | 1374 | +#endif
 | 
		
	
		
			
			| 1330 | 1375 |  	arbel->db_rec = dev_ib_data.uar_context_base;
 | 
		
	
		
			
			| 1331 | 1376 |  	arbel->reserved_lkey = dev_ib_data.mkey;
 | 
		
	
		
			
			| 1332 | 1377 |  	arbel->eqn = dev_ib_data.eq.eqn;
 | 
		
	
	
		
			
			|  | @@ -1380,7 +1425,13 @@ static int arbel_probe ( struct pci_device *pci,
 | 
		
	
		
			
			| 1380 | 1425 |   err_query_dev_lim:
 | 
		
	
		
			
			| 1381 | 1426 |  	ib_driver_close ( 0 );
 | 
		
	
		
			
			| 1382 | 1427 |   err_ib_driver_init:
 | 
		
	
		
			
			|  | 1428 | + err_query_fw:
 | 
		
	
		
			
			|  | 1429 | +	free_dma ( arbel->mailbox_out, ARBEL_MBOX_SIZE );
 | 
		
	
		
			
			|  | 1430 | + err_mailbox_out:
 | 
		
	
		
			
			|  | 1431 | +	free_dma ( arbel->mailbox_in, ARBEL_MBOX_SIZE );
 | 
		
	
		
			
			|  | 1432 | + err_mailbox_in:
 | 
		
	
		
			
			| 1383 | 1433 |  	free_ibdev ( ibdev );
 | 
		
	
		
			
			|  | 1434 | + err_ibdev:
 | 
		
	
		
			
			| 1384 | 1435 |  	return rc;
 | 
		
	
		
			
			| 1385 | 1436 |  }
 | 
		
	
		
			
			| 1386 | 1437 |  
 | 
		
	
	
		
			
			|  | @@ -1391,9 +1442,13 @@ static int arbel_probe ( struct pci_device *pci,
 | 
		
	
		
			
			| 1391 | 1442 |   */
 | 
		
	
		
			
			| 1392 | 1443 |  static void arbel_remove ( struct pci_device *pci ) {
 | 
		
	
		
			
			| 1393 | 1444 |  	struct ib_device *ibdev = pci_get_drvdata ( pci );
 | 
		
	
		
			
			|  | 1445 | +	struct arbel *arbel = ibdev->dev_priv;
 | 
		
	
		
			
			| 1394 | 1446 |  
 | 
		
	
		
			
			| 1395 | 1447 |  	ipoib_remove ( ibdev );
 | 
		
	
		
			
			| 1396 | 1448 |  	ib_driver_close ( 0 );
 | 
		
	
		
			
			|  | 1449 | +	free_dma ( arbel->mailbox_out, ARBEL_MBOX_SIZE );
 | 
		
	
		
			
			|  | 1450 | +	free_dma ( arbel->mailbox_in, ARBEL_MBOX_SIZE );
 | 
		
	
		
			
			|  | 1451 | +	free_ibdev ( ibdev );
 | 
		
	
		
			
			| 1397 | 1452 |  }
 | 
		
	
		
			
			| 1398 | 1453 |  
 | 
		
	
		
			
			| 1399 | 1454 |  static struct pci_device_id arbel_nics[] = {
 |