|  | @@ -347,6 +347,67 @@ static void intel_check_link ( struct net_device *netdev ) {
 | 
		
	
		
			
			| 347 | 347 |  	}
 | 
		
	
		
			
			| 348 | 348 |  }
 | 
		
	
		
			
			| 349 | 349 |  
 | 
		
	
		
			
			|  | 350 | +/******************************************************************************
 | 
		
	
		
			
			|  | 351 | + *
 | 
		
	
		
			
			|  | 352 | + * Descriptors
 | 
		
	
		
			
			|  | 353 | + *
 | 
		
	
		
			
			|  | 354 | + ******************************************************************************
 | 
		
	
		
			
			|  | 355 | + */
 | 
		
	
		
			
			|  | 356 | +
 | 
		
	
		
			
			|  | 357 | +/**
 | 
		
	
		
			
			|  | 358 | + * Populate transmit descriptor
 | 
		
	
		
			
			|  | 359 | + *
 | 
		
	
		
			
			|  | 360 | + * @v tx		Transmit descriptor
 | 
		
	
		
			
			|  | 361 | + * @v addr		Data buffer address
 | 
		
	
		
			
			|  | 362 | + * @v len		Length of data
 | 
		
	
		
			
			|  | 363 | + */
 | 
		
	
		
			
			|  | 364 | +void intel_describe_tx ( struct intel_descriptor *tx, physaddr_t addr,
 | 
		
	
		
			
			|  | 365 | +			 size_t len ) {
 | 
		
	
		
			
			|  | 366 | +
 | 
		
	
		
			
			|  | 367 | +	/* Populate transmit descriptor */
 | 
		
	
		
			
			|  | 368 | +	tx->address = cpu_to_le64 ( addr );
 | 
		
	
		
			
			|  | 369 | +	tx->length = cpu_to_le16 ( len );
 | 
		
	
		
			
			|  | 370 | +	tx->flags = 0;
 | 
		
	
		
			
			|  | 371 | +	tx->command = ( INTEL_DESC_CMD_RS | INTEL_DESC_CMD_IFCS |
 | 
		
	
		
			
			|  | 372 | +			INTEL_DESC_CMD_EOP );
 | 
		
	
		
			
			|  | 373 | +	tx->status = 0;
 | 
		
	
		
			
			|  | 374 | +}
 | 
		
	
		
			
			|  | 375 | +
 | 
		
	
		
			
			|  | 376 | +/**
 | 
		
	
		
			
			|  | 377 | + * Populate advanced transmit descriptor
 | 
		
	
		
			
			|  | 378 | + *
 | 
		
	
		
			
			|  | 379 | + * @v tx		Transmit descriptor
 | 
		
	
		
			
			|  | 380 | + * @v addr		Data buffer address
 | 
		
	
		
			
			|  | 381 | + * @v len		Length of data
 | 
		
	
		
			
			|  | 382 | + */
 | 
		
	
		
			
			|  | 383 | +void intel_describe_tx_adv ( struct intel_descriptor *tx, physaddr_t addr,
 | 
		
	
		
			
			|  | 384 | +			     size_t len ) {
 | 
		
	
		
			
			|  | 385 | +
 | 
		
	
		
			
			|  | 386 | +	/* Populate advanced transmit descriptor */
 | 
		
	
		
			
			|  | 387 | +	tx->address = cpu_to_le64 ( addr );
 | 
		
	
		
			
			|  | 388 | +	tx->length = cpu_to_le16 ( len );
 | 
		
	
		
			
			|  | 389 | +	tx->flags = INTEL_DESC_FL_DTYP_DATA;
 | 
		
	
		
			
			|  | 390 | +	tx->command = ( INTEL_DESC_CMD_DEXT | INTEL_DESC_CMD_RS |
 | 
		
	
		
			
			|  | 391 | +			INTEL_DESC_CMD_IFCS | INTEL_DESC_CMD_EOP );
 | 
		
	
		
			
			|  | 392 | +	tx->status = cpu_to_le32 ( INTEL_DESC_STATUS_PAYLEN ( len ) );
 | 
		
	
		
			
			|  | 393 | +}
 | 
		
	
		
			
			|  | 394 | +
 | 
		
	
		
			
			|  | 395 | +/**
 | 
		
	
		
			
			|  | 396 | + * Populate receive descriptor
 | 
		
	
		
			
			|  | 397 | + *
 | 
		
	
		
			
			|  | 398 | + * @v rx		Receive descriptor
 | 
		
	
		
			
			|  | 399 | + * @v addr		Data buffer address
 | 
		
	
		
			
			|  | 400 | + * @v len		Length of data
 | 
		
	
		
			
			|  | 401 | + */
 | 
		
	
		
			
			|  | 402 | +void intel_describe_rx ( struct intel_descriptor *rx, physaddr_t addr,
 | 
		
	
		
			
			|  | 403 | +			 size_t len __unused ) {
 | 
		
	
		
			
			|  | 404 | +
 | 
		
	
		
			
			|  | 405 | +	/* Populate transmit descriptor */
 | 
		
	
		
			
			|  | 406 | +	rx->address = cpu_to_le64 ( addr );
 | 
		
	
		
			
			|  | 407 | +	rx->length = 0;
 | 
		
	
		
			
			|  | 408 | +	rx->status = 0;
 | 
		
	
		
			
			|  | 409 | +}
 | 
		
	
		
			
			|  | 410 | +
 | 
		
	
		
			
			| 350 | 411 |  /******************************************************************************
 | 
		
	
		
			
			| 351 | 412 |   *
 | 
		
	
		
			
			| 352 | 413 |   * Network device interface
 | 
		
	
	
		
			
			|  | @@ -457,10 +518,7 @@ void intel_refill_rx ( struct intel_nic *intel ) {
 | 
		
	
		
			
			| 457 | 518 |  
 | 
		
	
		
			
			| 458 | 519 |  		/* Populate receive descriptor */
 | 
		
	
		
			
			| 459 | 520 |  		address = virt_to_bus ( iobuf->data );
 | 
		
	
		
			
			| 460 |  | -		rx->address = cpu_to_le64 ( address );
 | 
		
	
		
			
			| 461 |  | -		rx->length = 0;
 | 
		
	
		
			
			| 462 |  | -		rx->status = 0;
 | 
		
	
		
			
			| 463 |  | -		rx->errors = 0;
 | 
		
	
		
			
			|  | 521 | +		intel->rx.describe ( rx, address, 0 );
 | 
		
	
		
			
			| 464 | 522 |  
 | 
		
	
		
			
			| 465 | 523 |  		/* Record I/O buffer */
 | 
		
	
		
			
			| 466 | 524 |  		assert ( intel->rx_iobuf[rx_idx] == NULL );
 | 
		
	
	
		
			
			|  | @@ -602,6 +660,7 @@ int intel_transmit ( struct net_device *netdev, struct io_buffer *iobuf ) {
 | 
		
	
		
			
			| 602 | 660 |  	unsigned int tx_idx;
 | 
		
	
		
			
			| 603 | 661 |  	unsigned int tx_tail;
 | 
		
	
		
			
			| 604 | 662 |  	physaddr_t address;
 | 
		
	
		
			
			|  | 663 | +	size_t len;
 | 
		
	
		
			
			| 605 | 664 |  
 | 
		
	
		
			
			| 606 | 665 |  	/* Get next transmit descriptor */
 | 
		
	
		
			
			| 607 | 666 |  	if ( ( intel->tx.prod - intel->tx.cons ) >= INTEL_TX_FILL ) {
 | 
		
	
	
		
			
			|  | @@ -614,11 +673,8 @@ int intel_transmit ( struct net_device *netdev, struct io_buffer *iobuf ) {
 | 
		
	
		
			
			| 614 | 673 |  
 | 
		
	
		
			
			| 615 | 674 |  	/* Populate transmit descriptor */
 | 
		
	
		
			
			| 616 | 675 |  	address = virt_to_bus ( iobuf->data );
 | 
		
	
		
			
			| 617 |  | -	tx->address = cpu_to_le64 ( address );
 | 
		
	
		
			
			| 618 |  | -	tx->length = cpu_to_le16 ( iob_len ( iobuf ) );
 | 
		
	
		
			
			| 619 |  | -	tx->command = ( INTEL_DESC_CMD_RS | INTEL_DESC_CMD_IFCS |
 | 
		
	
		
			
			| 620 |  | -			INTEL_DESC_CMD_EOP );
 | 
		
	
		
			
			| 621 |  | -	tx->status = 0;
 | 
		
	
		
			
			|  | 676 | +	len = iob_len ( iobuf );
 | 
		
	
		
			
			|  | 677 | +	intel->tx.describe ( tx, address, len );
 | 
		
	
		
			
			| 622 | 678 |  	wmb();
 | 
		
	
		
			
			| 623 | 679 |  
 | 
		
	
		
			
			| 624 | 680 |  	/* Notify card that there are packets ready to transmit */
 | 
		
	
	
		
			
			|  | @@ -629,7 +685,7 @@ int intel_transmit ( struct net_device *netdev, struct io_buffer *iobuf ) {
 | 
		
	
		
			
			| 629 | 685 |  
 | 
		
	
		
			
			| 630 | 686 |  	DBGC2 ( intel, "INTEL %p TX %d is [%llx,%llx)\n", intel, tx_idx,
 | 
		
	
		
			
			| 631 | 687 |  		( ( unsigned long long ) address ),
 | 
		
	
		
			
			| 632 |  | -		( ( unsigned long long ) address + iob_len ( iobuf ) ) );
 | 
		
	
		
			
			|  | 688 | +		( ( unsigned long long ) address + len ) );
 | 
		
	
		
			
			| 633 | 689 |  
 | 
		
	
		
			
			| 634 | 690 |  	return 0;
 | 
		
	
		
			
			| 635 | 691 |  }
 | 
		
	
	
		
			
			|  | @@ -652,7 +708,7 @@ void intel_poll_tx ( struct net_device *netdev ) {
 | 
		
	
		
			
			| 652 | 708 |  		tx = &intel->tx.desc[tx_idx];
 | 
		
	
		
			
			| 653 | 709 |  
 | 
		
	
		
			
			| 654 | 710 |  		/* Stop if descriptor is still in use */
 | 
		
	
		
			
			| 655 |  | -		if ( ! ( tx->status & INTEL_DESC_STATUS_DD ) )
 | 
		
	
		
			
			|  | 711 | +		if ( ! ( tx->status & cpu_to_le32 ( INTEL_DESC_STATUS_DD ) ) )
 | 
		
	
		
			
			| 656 | 712 |  			return;
 | 
		
	
		
			
			| 657 | 713 |  
 | 
		
	
		
			
			| 658 | 714 |  		DBGC2 ( intel, "INTEL %p TX %d complete\n", intel, tx_idx );
 | 
		
	
	
		
			
			|  | @@ -683,7 +739,7 @@ void intel_poll_rx ( struct net_device *netdev ) {
 | 
		
	
		
			
			| 683 | 739 |  		rx = &intel->rx.desc[rx_idx];
 | 
		
	
		
			
			| 684 | 740 |  
 | 
		
	
		
			
			| 685 | 741 |  		/* Stop if descriptor is still in use */
 | 
		
	
		
			
			| 686 |  | -		if ( ! ( rx->status & INTEL_DESC_STATUS_DD ) )
 | 
		
	
		
			
			|  | 742 | +		if ( ! ( rx->status & cpu_to_le32 ( INTEL_DESC_STATUS_DD ) ) )
 | 
		
	
		
			
			| 687 | 743 |  			return;
 | 
		
	
		
			
			| 688 | 744 |  
 | 
		
	
		
			
			| 689 | 745 |  		/* Populate I/O buffer */
 | 
		
	
	
		
			
			|  | @@ -693,10 +749,10 @@ void intel_poll_rx ( struct net_device *netdev ) {
 | 
		
	
		
			
			| 693 | 749 |  		iob_put ( iobuf, len );
 | 
		
	
		
			
			| 694 | 750 |  
 | 
		
	
		
			
			| 695 | 751 |  		/* Hand off to network stack */
 | 
		
	
		
			
			| 696 |  | -		if ( rx->errors ) {
 | 
		
	
		
			
			|  | 752 | +		if ( rx->status & cpu_to_le32 ( INTEL_DESC_STATUS_RXE ) ) {
 | 
		
	
		
			
			| 697 | 753 |  			DBGC ( intel, "INTEL %p RX %d error (length %zd, "
 | 
		
	
		
			
			| 698 |  | -			       "errors %02x)\n",
 | 
		
	
		
			
			| 699 |  | -			       intel, rx_idx, len, rx->errors );
 | 
		
	
		
			
			|  | 754 | +			       "status %08x)\n", intel, rx_idx, len,
 | 
		
	
		
			
			|  | 755 | +			       le32_to_cpu ( rx->status ) );
 | 
		
	
		
			
			| 700 | 756 |  			netdev_rx_err ( netdev, iobuf, -EIO );
 | 
		
	
		
			
			| 701 | 757 |  		} else {
 | 
		
	
		
			
			| 702 | 758 |  			DBGC2 ( intel, "INTEL %p RX %d complete (length %zd)\n",
 | 
		
	
	
		
			
			|  | @@ -811,8 +867,10 @@ static int intel_probe ( struct pci_device *pci ) {
 | 
		
	
		
			
			| 811 | 867 |  	memset ( intel, 0, sizeof ( *intel ) );
 | 
		
	
		
			
			| 812 | 868 |  	intel->port = PCI_FUNC ( pci->busdevfn );
 | 
		
	
		
			
			| 813 | 869 |  	intel->flags = pci->id->driver_data;
 | 
		
	
		
			
			| 814 |  | -	intel_init_ring ( &intel->tx, INTEL_NUM_TX_DESC, INTEL_TD );
 | 
		
	
		
			
			| 815 |  | -	intel_init_ring ( &intel->rx, INTEL_NUM_RX_DESC, INTEL_RD );
 | 
		
	
		
			
			|  | 870 | +	intel_init_ring ( &intel->tx, INTEL_NUM_TX_DESC, INTEL_TD,
 | 
		
	
		
			
			|  | 871 | +			  intel_describe_tx );
 | 
		
	
		
			
			|  | 872 | +	intel_init_ring ( &intel->rx, INTEL_NUM_RX_DESC, INTEL_RD,
 | 
		
	
		
			
			|  | 873 | +			  intel_describe_rx );
 | 
		
	
		
			
			| 816 | 874 |  
 | 
		
	
		
			
			| 817 | 875 |  	/* Fix up PCI device */
 | 
		
	
		
			
			| 818 | 876 |  	adjust_pci_device ( pci );
 |