Преглед изворни кода

[intelxl] Use 32-byte receive descriptors

The physical function driver does not allow the virtual function to
request the use of 16-byte receive descriptors.  Switch to using
32-byte receive descriptors.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
tags/v1.20.1
Michael Brown пре 5 година
родитељ
комит
f460a436ca
2 измењених фајлова са 42 додато и 23 уклоњено
  1. 14
    12
      src/drivers/net/intelxl.c
  2. 28
    11
      src/drivers/net/intelxl.h

+ 14
- 12
src/drivers/net/intelxl.c Прегледај датотеку

@@ -1018,7 +1018,7 @@ static int intelxl_context_rx ( struct intelxl_nic *intelxl,
1018 1018
 	base_count = INTELXL_CTX_RX_BASE_COUNT ( address, INTELXL_RX_NUM_DESC );
1019 1019
 	ctx.rx.base_count = cpu_to_le64 ( base_count );
1020 1020
 	ctx.rx.len = cpu_to_le16 ( INTELXL_CTX_RX_LEN ( intelxl->mfs ) );
1021
-	ctx.rx.flags = INTELXL_CTX_RX_FL_CRCSTRIP;
1021
+	ctx.rx.flags = ( INTELXL_CTX_RX_FL_DSIZE | INTELXL_CTX_RX_FL_CRCSTRIP );
1022 1022
 	ctx.rx.mfs = cpu_to_le16 ( INTELXL_CTX_RX_MFS ( intelxl->mfs ) );
1023 1023
 
1024 1024
 	/* Program context */
@@ -1101,20 +1101,20 @@ static int intelxl_create_ring ( struct intelxl_nic *intelxl,
1101 1101
 	int rc;
1102 1102
 
1103 1103
 	/* Allocate descriptor ring */
1104
-	ring->desc = malloc_dma ( ring->len, INTELXL_ALIGN );
1105
-	if ( ! ring->desc ) {
1104
+	ring->desc.raw = malloc_dma ( ring->len, INTELXL_ALIGN );
1105
+	if ( ! ring->desc.raw ) {
1106 1106
 		rc = -ENOMEM;
1107 1107
 		goto err_alloc;
1108 1108
 	}
1109 1109
 
1110 1110
 	/* Initialise descriptor ring */
1111
-	memset ( ring->desc, 0, ring->len );
1111
+	memset ( ring->desc.raw, 0, ring->len );
1112 1112
 
1113 1113
 	/* Reset tail pointer */
1114 1114
 	writel ( 0, ( ring_regs + INTELXL_QXX_TAIL ) );
1115 1115
 
1116 1116
 	/* Program queue context */
1117
-	address = virt_to_bus ( ring->desc );
1117
+	address = virt_to_bus ( ring->desc.raw );
1118 1118
 	if ( ( rc = ring->context ( intelxl, address ) ) != 0 )
1119 1119
 		goto err_context;
1120 1120
 
@@ -1135,7 +1135,7 @@ static int intelxl_create_ring ( struct intelxl_nic *intelxl,
1135 1135
 	intelxl_disable_ring ( intelxl, ring );
1136 1136
  err_enable:
1137 1137
  err_context:
1138
-	free_dma ( ring->desc, ring->len );
1138
+	free_dma ( ring->desc.raw, ring->len );
1139 1139
  err_alloc:
1140 1140
 	return rc;
1141 1141
 }
@@ -1157,8 +1157,8 @@ static void intelxl_destroy_ring ( struct intelxl_nic *intelxl,
1157 1157
 	}
1158 1158
 
1159 1159
 	/* Free descriptor ring */
1160
-	free_dma ( ring->desc, ring->len );
1161
-	ring->desc = NULL;
1160
+	free_dma ( ring->desc.raw, ring->len );
1161
+	ring->desc.raw = NULL;
1162 1162
 }
1163 1163
 
1164 1164
 /**
@@ -1186,7 +1186,7 @@ static void intelxl_refill_rx ( struct intelxl_nic *intelxl ) {
1186 1186
 
1187 1187
 		/* Get next receive descriptor */
1188 1188
 		rx_idx = ( intelxl->rx.prod++ % INTELXL_RX_NUM_DESC );
1189
-		rx = &intelxl->rx.desc[rx_idx].rx;
1189
+		rx = &intelxl->rx.desc.rx[rx_idx].data;
1190 1190
 
1191 1191
 		/* Populate receive descriptor */
1192 1192
 		address = virt_to_bus ( iobuf->data );
@@ -1351,7 +1351,7 @@ static int intelxl_transmit ( struct net_device *netdev,
1351 1351
 	}
1352 1352
 	tx_idx = ( intelxl->tx.prod++ % INTELXL_TX_NUM_DESC );
1353 1353
 	tx_tail = ( intelxl->tx.prod % INTELXL_TX_NUM_DESC );
1354
-	tx = &intelxl->tx.desc[tx_idx].tx;
1354
+	tx = &intelxl->tx.desc.tx[tx_idx].data;
1355 1355
 
1356 1356
 	/* Populate transmit descriptor */
1357 1357
 	address = virt_to_bus ( iobuf->data );
@@ -1387,7 +1387,7 @@ static void intelxl_poll_tx ( struct net_device *netdev ) {
1387 1387
 
1388 1388
 		/* Get next transmit descriptor */
1389 1389
 		tx_idx = ( intelxl->tx.cons % INTELXL_TX_NUM_DESC );
1390
-		tx_wb = &intelxl->tx.desc[tx_idx].tx_wb;
1390
+		tx_wb = &intelxl->tx.desc.tx[tx_idx].wb;
1391 1391
 
1392 1392
 		/* Stop if descriptor is still in use */
1393 1393
 		if ( ! ( tx_wb->flags & INTELXL_TX_WB_FL_DD ) )
@@ -1419,7 +1419,7 @@ static void intelxl_poll_rx ( struct net_device *netdev ) {
1419 1419
 
1420 1420
 		/* Get next receive descriptor */
1421 1421
 		rx_idx = ( intelxl->rx.cons % INTELXL_RX_NUM_DESC );
1422
-		rx_wb = &intelxl->rx.desc[rx_idx].rx_wb;
1422
+		rx_wb = &intelxl->rx.desc.rx[rx_idx].wb;
1423 1423
 
1424 1424
 		/* Stop if descriptor is still in use */
1425 1425
 		if ( ! ( rx_wb->flags & cpu_to_le32 ( INTELXL_RX_WB_FL_DD ) ) )
@@ -1544,8 +1544,10 @@ static int intelxl_probe ( struct pci_device *pci ) {
1544 1544
 	intelxl_init_admin ( &intelxl->event, INTELXL_ADMIN_EVT,
1545 1545
 			     &intelxl_admin_offsets );
1546 1546
 	intelxl_init_ring ( &intelxl->tx, INTELXL_TX_NUM_DESC,
1547
+			    sizeof ( intelxl->tx.desc.tx[0] ),
1547 1548
 			    intelxl_context_tx );
1548 1549
 	intelxl_init_ring ( &intelxl->rx, INTELXL_RX_NUM_DESC,
1550
+			    sizeof ( intelxl->rx.desc.rx[0] ),
1549 1551
 			    intelxl_context_rx );
1550 1552
 
1551 1553
 	/* Fix up PCI device */

+ 28
- 11
src/drivers/net/intelxl.h Прегледај датотеку

@@ -502,6 +502,9 @@ struct intelxl_context_rx {
502 502
 /** Receive queue data buffer length */
503 503
 #define INTELXL_CTX_RX_LEN( len ) ( (len) >> 1 )
504 504
 
505
+/** Use 32-byte receive descriptors */
506
+#define INTELXL_CTX_RX_FL_DSIZE 0x10
507
+
505 508
 /** Strip CRC from received packets */
506 509
 #define INTELXL_CTX_RX_FL_CRCSTRIP 0x20
507 510
 
@@ -605,6 +608,14 @@ struct intelxl_tx_writeback_descriptor {
605 608
 /** Transmit writeback descriptor complete */
606 609
 #define INTELXL_TX_WB_FL_DD 0x01
607 610
 
611
+/** Transmit descriptor */
612
+union intelxl_tx_descriptor {
613
+	/** Transmit data descriptor */
614
+	struct intelxl_tx_data_descriptor data;
615
+	/** Transmit writeback descriptor */
616
+	struct intelxl_tx_writeback_descriptor wb;
617
+};
618
+
608 619
 /** Receive data descriptor */
609 620
 struct intelxl_rx_data_descriptor {
610 621
 	/** Buffer address */
@@ -612,7 +623,7 @@ struct intelxl_rx_data_descriptor {
612 623
 	/** Flags */
613 624
 	uint32_t flags;
614 625
 	/** Reserved */
615
-	uint8_t reserved[4];
626
+	uint8_t reserved[20];
616 627
 } __attribute__ (( packed ));
617 628
 
618 629
 /** Receive writeback descriptor */
@@ -627,6 +638,8 @@ struct intelxl_rx_writeback_descriptor {
627 638
 	uint32_t flags;
628 639
 	/** Length */
629 640
 	uint32_t len;
641
+	/** Reserved */
642
+	uint8_t reserved_c[16];
630 643
 } __attribute__ (( packed ));
631 644
 
632 645
 /** Receive writeback descriptor complete */
@@ -642,21 +655,24 @@ struct intelxl_rx_writeback_descriptor {
642 655
 #define INTELXL_RX_WB_LEN(len) ( ( (len) >> 6 ) & 0x3fff )
643 656
 
644 657
 /** Packet descriptor */
645
-union intelxl_descriptor {
646
-	/** Transmit data descriptor */
647
-	struct intelxl_tx_data_descriptor tx;
648
-	/** Transmit writeback descriptor */
649
-	struct intelxl_tx_writeback_descriptor tx_wb;
658
+union intelxl_rx_descriptor {
650 659
 	/** Receive data descriptor */
651
-	struct intelxl_rx_data_descriptor rx;
660
+	struct intelxl_rx_data_descriptor data;
652 661
 	/** Receive writeback descriptor */
653
-	struct intelxl_rx_writeback_descriptor rx_wb;
662
+	struct intelxl_rx_writeback_descriptor wb;
654 663
 };
655 664
 
656 665
 /** Descriptor ring */
657 666
 struct intelxl_ring {
658 667
 	/** Descriptors */
659
-	union intelxl_descriptor *desc;
668
+	union {
669
+		/** Transmit descriptors */
670
+		union intelxl_tx_descriptor *tx;
671
+		/** Receive descriptors */
672
+		union intelxl_rx_descriptor *rx;
673
+		/** Raw data */
674
+		void *raw;
675
+	} desc;
660 676
 	/** Producer index */
661 677
 	unsigned int prod;
662 678
 	/** Consumer index */
@@ -679,14 +695,15 @@ struct intelxl_ring {
679 695
  *
680 696
  * @v ring		Descriptor ring
681 697
  * @v count		Number of descriptors
698
+ * @v len		Length of a single descriptor
682 699
  * @v context		Method to program queue context
683 700
  */
684 701
 static inline __attribute__ (( always_inline)) void
685
-intelxl_init_ring ( struct intelxl_ring *ring, unsigned int count,
702
+intelxl_init_ring ( struct intelxl_ring *ring, unsigned int count, size_t len,
686 703
 		    int ( * context ) ( struct intelxl_nic *intelxl,
687 704
 					physaddr_t address ) ) {
688 705
 
689
-	ring->len = ( count * sizeof ( ring->desc[0] ) );
706
+	ring->len = ( count * len );
690 707
 	ring->context = context;
691 708
 }
692 709
 

Loading…
Откажи
Сачувај