Pārlūkot izejas kodu

[intel] Expose functionality to be shared with intelx driver

The Intel 10 Gigabit NICs have a datapath that is almost
register-compatible with the Intel 1 Gigabit NICs.  Expose common
functionality to avoid duplication of code in the new "intelx" driver.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
tags/v1.20.1
Michael Brown 11 gadus atpakaļ
vecāks
revīzija
1dd4e51063
2 mainītis faili ar 33 papildinājumiem un 15 dzēšanām
  1. 22
    15
      src/drivers/net/intel.c
  2. 11
    0
      src/drivers/net/intel.h

+ 22
- 15
src/drivers/net/intel.c Parādīt failu

@@ -360,8 +360,7 @@ static void intel_check_link ( struct net_device *netdev ) {
360 360
  * @v ring		Descriptor ring
361 361
  * @ret rc		Return status code
362 362
  */
363
-static int intel_create_ring ( struct intel_nic *intel,
364
-			       struct intel_ring *ring ) {
363
+int intel_create_ring ( struct intel_nic *intel, struct intel_ring *ring ) {
365 364
 	physaddr_t address;
366 365
 	uint32_t dctl;
367 366
 
@@ -412,8 +411,7 @@ static int intel_create_ring ( struct intel_nic *intel,
412 411
  * @v intel		Intel device
413 412
  * @v ring		Descriptor ring
414 413
  */
415
-static void intel_destroy_ring ( struct intel_nic *intel,
416
-				 struct intel_ring *ring ) {
414
+void intel_destroy_ring ( struct intel_nic *intel, struct intel_ring *ring ) {
417 415
 
418 416
 	/* Clear ring length */
419 417
 	writel ( 0, ( intel->regs + ring->reg + INTEL_xDLEN ) );
@@ -434,7 +432,7 @@ static void intel_destroy_ring ( struct intel_nic *intel,
434 432
  *
435 433
  * @v intel		Intel device
436 434
  */
437
-static void intel_refill_rx ( struct intel_nic *intel ) {
435
+void intel_refill_rx ( struct intel_nic *intel ) {
438 436
 	struct intel_descriptor *rx;
439 437
 	struct io_buffer *iobuf;
440 438
 	unsigned int rx_idx;
@@ -476,6 +474,21 @@ static void intel_refill_rx ( struct intel_nic *intel ) {
476 474
 	}
477 475
 }
478 476
 
477
+/**
478
+ * Discard unused receive I/O buffers
479
+ *
480
+ * @v intel		Intel device
481
+ */
482
+void intel_empty_rx ( struct intel_nic *intel ) {
483
+	unsigned int i;
484
+
485
+	for ( i = 0 ; i < INTEL_NUM_RX_DESC ; i++ ) {
486
+		if ( intel->rx_iobuf[i] )
487
+			free_iob ( intel->rx_iobuf[i] );
488
+		intel->rx_iobuf[i] = NULL;
489
+	}
490
+}
491
+
479 492
 /**
480 493
  * Open network device
481 494
  *
@@ -540,7 +553,6 @@ static int intel_open ( struct net_device *netdev ) {
540 553
  */
541 554
 static void intel_close ( struct net_device *netdev ) {
542 555
 	struct intel_nic *intel = netdev->priv;
543
-	unsigned int i;
544 556
 
545 557
 	/* Disable receiver */
546 558
 	writel ( 0, intel->regs + INTEL_RCTL );
@@ -552,11 +564,7 @@ static void intel_close ( struct net_device *netdev ) {
552 564
 	intel_destroy_ring ( intel, &intel->rx );
553 565
 
554 566
 	/* Discard any unused receive buffers */
555
-	for ( i = 0 ; i < INTEL_NUM_RX_DESC ; i++ ) {
556
-		if ( intel->rx_iobuf[i] )
557
-			free_iob ( intel->rx_iobuf[i] );
558
-		intel->rx_iobuf[i] = NULL;
559
-	}
567
+	intel_empty_rx ( intel );
560 568
 
561 569
 	/* Destroy transmit descriptor ring */
562 570
 	intel_destroy_ring ( intel, &intel->tx );
@@ -572,8 +580,7 @@ static void intel_close ( struct net_device *netdev ) {
572 580
  * @v iobuf		I/O buffer
573 581
  * @ret rc		Return status code
574 582
  */
575
-static int intel_transmit ( struct net_device *netdev,
576
-			       struct io_buffer *iobuf ) {
583
+int intel_transmit ( struct net_device *netdev, struct io_buffer *iobuf ) {
577 584
 	struct intel_nic *intel = netdev->priv;
578 585
 	struct intel_descriptor *tx;
579 586
 	unsigned int tx_idx;
@@ -613,7 +620,7 @@ static int intel_transmit ( struct net_device *netdev,
613 620
  *
614 621
  * @v netdev		Network device
615 622
  */
616
-static void intel_poll_tx ( struct net_device *netdev ) {
623
+void intel_poll_tx ( struct net_device *netdev ) {
617 624
 	struct intel_nic *intel = netdev->priv;
618 625
 	struct intel_descriptor *tx;
619 626
 	unsigned int tx_idx;
@@ -642,7 +649,7 @@ static void intel_poll_tx ( struct net_device *netdev ) {
642 649
  *
643 650
  * @v netdev		Network device
644 651
  */
645
-static void intel_poll_rx ( struct net_device *netdev ) {
652
+void intel_poll_rx ( struct net_device *netdev ) {
646 653
 	struct intel_nic *intel = netdev->priv;
647 654
 	struct intel_descriptor *rx;
648 655
 	struct io_buffer *iobuf;

+ 11
- 0
src/drivers/net/intel.h Parādīt failu

@@ -242,4 +242,15 @@ struct intel_nic {
242 242
 	struct io_buffer *rx_iobuf[INTEL_NUM_RX_DESC];
243 243
 };
244 244
 
245
+extern int intel_create_ring ( struct intel_nic *intel,
246
+			       struct intel_ring *ring );
247
+extern void intel_destroy_ring ( struct intel_nic *intel,
248
+				 struct intel_ring *ring );
249
+extern void intel_refill_rx ( struct intel_nic *intel );
250
+extern void intel_empty_rx ( struct intel_nic *intel );
251
+extern int intel_transmit ( struct net_device *netdev,
252
+			    struct io_buffer *iobuf );
253
+extern void intel_poll_tx ( struct net_device *netdev );
254
+extern void intel_poll_rx ( struct net_device *netdev );
255
+
245 256
 #endif /* _INTEL_H */

Notiek ielāde…
Atcelt
Saglabāt