Browse Source

[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 years ago
parent
commit
f460a436ca
2 changed files with 42 additions and 23 deletions
  1. 14
    12
      src/drivers/net/intelxl.c
  2. 28
    11
      src/drivers/net/intelxl.h

+ 14
- 12
src/drivers/net/intelxl.c View File

1018
 	base_count = INTELXL_CTX_RX_BASE_COUNT ( address, INTELXL_RX_NUM_DESC );
1018
 	base_count = INTELXL_CTX_RX_BASE_COUNT ( address, INTELXL_RX_NUM_DESC );
1019
 	ctx.rx.base_count = cpu_to_le64 ( base_count );
1019
 	ctx.rx.base_count = cpu_to_le64 ( base_count );
1020
 	ctx.rx.len = cpu_to_le16 ( INTELXL_CTX_RX_LEN ( intelxl->mfs ) );
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
 	ctx.rx.mfs = cpu_to_le16 ( INTELXL_CTX_RX_MFS ( intelxl->mfs ) );
1022
 	ctx.rx.mfs = cpu_to_le16 ( INTELXL_CTX_RX_MFS ( intelxl->mfs ) );
1023
 
1023
 
1024
 	/* Program context */
1024
 	/* Program context */
1101
 	int rc;
1101
 	int rc;
1102
 
1102
 
1103
 	/* Allocate descriptor ring */
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
 		rc = -ENOMEM;
1106
 		rc = -ENOMEM;
1107
 		goto err_alloc;
1107
 		goto err_alloc;
1108
 	}
1108
 	}
1109
 
1109
 
1110
 	/* Initialise descriptor ring */
1110
 	/* Initialise descriptor ring */
1111
-	memset ( ring->desc, 0, ring->len );
1111
+	memset ( ring->desc.raw, 0, ring->len );
1112
 
1112
 
1113
 	/* Reset tail pointer */
1113
 	/* Reset tail pointer */
1114
 	writel ( 0, ( ring_regs + INTELXL_QXX_TAIL ) );
1114
 	writel ( 0, ( ring_regs + INTELXL_QXX_TAIL ) );
1115
 
1115
 
1116
 	/* Program queue context */
1116
 	/* Program queue context */
1117
-	address = virt_to_bus ( ring->desc );
1117
+	address = virt_to_bus ( ring->desc.raw );
1118
 	if ( ( rc = ring->context ( intelxl, address ) ) != 0 )
1118
 	if ( ( rc = ring->context ( intelxl, address ) ) != 0 )
1119
 		goto err_context;
1119
 		goto err_context;
1120
 
1120
 
1135
 	intelxl_disable_ring ( intelxl, ring );
1135
 	intelxl_disable_ring ( intelxl, ring );
1136
  err_enable:
1136
  err_enable:
1137
  err_context:
1137
  err_context:
1138
-	free_dma ( ring->desc, ring->len );
1138
+	free_dma ( ring->desc.raw, ring->len );
1139
  err_alloc:
1139
  err_alloc:
1140
 	return rc;
1140
 	return rc;
1141
 }
1141
 }
1157
 	}
1157
 	}
1158
 
1158
 
1159
 	/* Free descriptor ring */
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
 
1186
 
1187
 		/* Get next receive descriptor */
1187
 		/* Get next receive descriptor */
1188
 		rx_idx = ( intelxl->rx.prod++ % INTELXL_RX_NUM_DESC );
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
 		/* Populate receive descriptor */
1191
 		/* Populate receive descriptor */
1192
 		address = virt_to_bus ( iobuf->data );
1192
 		address = virt_to_bus ( iobuf->data );
1351
 	}
1351
 	}
1352
 	tx_idx = ( intelxl->tx.prod++ % INTELXL_TX_NUM_DESC );
1352
 	tx_idx = ( intelxl->tx.prod++ % INTELXL_TX_NUM_DESC );
1353
 	tx_tail = ( intelxl->tx.prod % INTELXL_TX_NUM_DESC );
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
 	/* Populate transmit descriptor */
1356
 	/* Populate transmit descriptor */
1357
 	address = virt_to_bus ( iobuf->data );
1357
 	address = virt_to_bus ( iobuf->data );
1387
 
1387
 
1388
 		/* Get next transmit descriptor */
1388
 		/* Get next transmit descriptor */
1389
 		tx_idx = ( intelxl->tx.cons % INTELXL_TX_NUM_DESC );
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
 		/* Stop if descriptor is still in use */
1392
 		/* Stop if descriptor is still in use */
1393
 		if ( ! ( tx_wb->flags & INTELXL_TX_WB_FL_DD ) )
1393
 		if ( ! ( tx_wb->flags & INTELXL_TX_WB_FL_DD ) )
1419
 
1419
 
1420
 		/* Get next receive descriptor */
1420
 		/* Get next receive descriptor */
1421
 		rx_idx = ( intelxl->rx.cons % INTELXL_RX_NUM_DESC );
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
 		/* Stop if descriptor is still in use */
1424
 		/* Stop if descriptor is still in use */
1425
 		if ( ! ( rx_wb->flags & cpu_to_le32 ( INTELXL_RX_WB_FL_DD ) ) )
1425
 		if ( ! ( rx_wb->flags & cpu_to_le32 ( INTELXL_RX_WB_FL_DD ) ) )
1544
 	intelxl_init_admin ( &intelxl->event, INTELXL_ADMIN_EVT,
1544
 	intelxl_init_admin ( &intelxl->event, INTELXL_ADMIN_EVT,
1545
 			     &intelxl_admin_offsets );
1545
 			     &intelxl_admin_offsets );
1546
 	intelxl_init_ring ( &intelxl->tx, INTELXL_TX_NUM_DESC,
1546
 	intelxl_init_ring ( &intelxl->tx, INTELXL_TX_NUM_DESC,
1547
+			    sizeof ( intelxl->tx.desc.tx[0] ),
1547
 			    intelxl_context_tx );
1548
 			    intelxl_context_tx );
1548
 	intelxl_init_ring ( &intelxl->rx, INTELXL_RX_NUM_DESC,
1549
 	intelxl_init_ring ( &intelxl->rx, INTELXL_RX_NUM_DESC,
1550
+			    sizeof ( intelxl->rx.desc.rx[0] ),
1549
 			    intelxl_context_rx );
1551
 			    intelxl_context_rx );
1550
 
1552
 
1551
 	/* Fix up PCI device */
1553
 	/* Fix up PCI device */

+ 28
- 11
src/drivers/net/intelxl.h View File

502
 /** Receive queue data buffer length */
502
 /** Receive queue data buffer length */
503
 #define INTELXL_CTX_RX_LEN( len ) ( (len) >> 1 )
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
 /** Strip CRC from received packets */
508
 /** Strip CRC from received packets */
506
 #define INTELXL_CTX_RX_FL_CRCSTRIP 0x20
509
 #define INTELXL_CTX_RX_FL_CRCSTRIP 0x20
507
 
510
 
605
 /** Transmit writeback descriptor complete */
608
 /** Transmit writeback descriptor complete */
606
 #define INTELXL_TX_WB_FL_DD 0x01
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
 /** Receive data descriptor */
619
 /** Receive data descriptor */
609
 struct intelxl_rx_data_descriptor {
620
 struct intelxl_rx_data_descriptor {
610
 	/** Buffer address */
621
 	/** Buffer address */
612
 	/** Flags */
623
 	/** Flags */
613
 	uint32_t flags;
624
 	uint32_t flags;
614
 	/** Reserved */
625
 	/** Reserved */
615
-	uint8_t reserved[4];
626
+	uint8_t reserved[20];
616
 } __attribute__ (( packed ));
627
 } __attribute__ (( packed ));
617
 
628
 
618
 /** Receive writeback descriptor */
629
 /** Receive writeback descriptor */
627
 	uint32_t flags;
638
 	uint32_t flags;
628
 	/** Length */
639
 	/** Length */
629
 	uint32_t len;
640
 	uint32_t len;
641
+	/** Reserved */
642
+	uint8_t reserved_c[16];
630
 } __attribute__ (( packed ));
643
 } __attribute__ (( packed ));
631
 
644
 
632
 /** Receive writeback descriptor complete */
645
 /** Receive writeback descriptor complete */
642
 #define INTELXL_RX_WB_LEN(len) ( ( (len) >> 6 ) & 0x3fff )
655
 #define INTELXL_RX_WB_LEN(len) ( ( (len) >> 6 ) & 0x3fff )
643
 
656
 
644
 /** Packet descriptor */
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
 	/** Receive data descriptor */
659
 	/** Receive data descriptor */
651
-	struct intelxl_rx_data_descriptor rx;
660
+	struct intelxl_rx_data_descriptor data;
652
 	/** Receive writeback descriptor */
661
 	/** Receive writeback descriptor */
653
-	struct intelxl_rx_writeback_descriptor rx_wb;
662
+	struct intelxl_rx_writeback_descriptor wb;
654
 };
663
 };
655
 
664
 
656
 /** Descriptor ring */
665
 /** Descriptor ring */
657
 struct intelxl_ring {
666
 struct intelxl_ring {
658
 	/** Descriptors */
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
 	/** Producer index */
676
 	/** Producer index */
661
 	unsigned int prod;
677
 	unsigned int prod;
662
 	/** Consumer index */
678
 	/** Consumer index */
679
  *
695
  *
680
  * @v ring		Descriptor ring
696
  * @v ring		Descriptor ring
681
  * @v count		Number of descriptors
697
  * @v count		Number of descriptors
698
+ * @v len		Length of a single descriptor
682
  * @v context		Method to program queue context
699
  * @v context		Method to program queue context
683
  */
700
  */
684
 static inline __attribute__ (( always_inline)) void
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
 		    int ( * context ) ( struct intelxl_nic *intelxl,
703
 		    int ( * context ) ( struct intelxl_nic *intelxl,
687
 					physaddr_t address ) ) {
704
 					physaddr_t address ) ) {
688
 
705
 
689
-	ring->len = ( count * sizeof ( ring->desc[0] ) );
706
+	ring->len = ( count * len );
690
 	ring->context = context;
707
 	ring->context = context;
691
 }
708
 }
692
 
709
 

Loading…
Cancel
Save