aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlan Cox <alan@linux.intel.com>2009-11-18 09:07:58 -0500
committerGreg Kroah-Hartman <gregkh@suse.de>2009-12-11 15:23:21 -0500
commit99fd99f618daecae638550275cb132ab1ffe464c (patch)
tree368720fb2b8acf69ca799d90d3afd1a2191c158a
parent2e5e0b890d4f6f2e9e836c2c21157fbb085c3ed9 (diff)
Staging: et131x: clean up the avail fields in the rx registers
These have a wrap bit but again need little work to clean out. There are a couple of uglies left that want addressing in later clean up. Notably we should probably keep the local psr copy and wrap as two values. Signed-off-by: Alan Cox <alan@linux.intel.com> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
-rw-r--r--drivers/staging/et131x/et1310_address_map.h40
-rw-r--r--drivers/staging/et131x/et1310_rx.c28
-rw-r--r--drivers/staging/et131x/et1310_rx.h2
3 files changed, 26 insertions, 44 deletions
diff --git a/drivers/staging/et131x/et1310_address_map.h b/drivers/staging/et131x/et1310_address_map.h
index 019588d13127..6da843cc343c 100644
--- a/drivers/staging/et131x/et1310_address_map.h
+++ b/drivers/staging/et131x/et1310_address_map.h
@@ -393,40 +393,20 @@ typedef union _RXDMA_CSR_t {
393/* 393/*
394 * structure for packet status ring available offset reg in rxdma address map 394 * structure for packet status ring available offset reg in rxdma address map
395 * located at address 0x202C 395 * located at address 0x202C
396 *
397 * 31-13: unused
398 * 12: psr avail wrap
399 * 11-0: psr avail
396 */ 400 */
397typedef union _RXDMA_PSR_AVAIL_OFFSET_t {
398 u32 value;
399 struct {
400#ifdef _BIT_FIELDS_HTOL
401 u32 unused:19; /* bits 13-31 */
402 u32 psr_avail_wrap:1; /* bit 12 */
403 u32 psr_avail:12; /* bit 0-11 */
404#else
405 u32 psr_avail:12; /* bit 0-11 */
406 u32 psr_avail_wrap:1; /* bit 12 */
407 u32 unused:19; /* bits 13-31 */
408#endif
409 } bits;
410} RXDMA_PSR_AVAIL_OFFSET_t, *PRXDMA_PSR_AVAIL_OFFSET_t;
411 401
412/* 402/*
413 * structure for packet status ring full offset reg in rxdma address map 403 * structure for packet status ring full offset reg in rxdma address map
414 * located at address 0x2030 404 * located at address 0x2030
405 *
406 * 31-13: unused
407 * 12: psr full wrap
408 * 11-0: psr full
415 */ 409 */
416typedef union _RXDMA_PSR_FULL_OFFSET_t {
417 u32 value;
418 struct {
419#ifdef _BIT_FIELDS_HTOL
420 u32 unused:19; /* bits 13-31 */
421 u32 psr_full_wrap:1; /* bit 12 */
422 u32 psr_full:12; /* bit 0-11 */
423#else
424 u32 psr_full:12; /* bit 0-11 */
425 u32 psr_full_wrap:1; /* bit 12 */
426 u32 unused:19; /* bits 13-31 */
427#endif
428 } bits;
429} RXDMA_PSR_FULL_OFFSET_t, *PRXDMA_PSR_FULL_OFFSET_t;
430 410
431/* 411/*
432 * structure for packet status ring access index reg in rxdma address map 412 * structure for packet status ring access index reg in rxdma address map
@@ -556,8 +536,8 @@ typedef struct _RXDMA_t { /* Location: */
556 u32 psr_base_lo; /* 0x2020 */ 536 u32 psr_base_lo; /* 0x2020 */
557 u32 psr_base_hi; /* 0x2024 */ 537 u32 psr_base_hi; /* 0x2024 */
558 u32 psr_num_des; /* 0x2028 */ 538 u32 psr_num_des; /* 0x2028 */
559 RXDMA_PSR_AVAIL_OFFSET_t psr_avail_offset; /* 0x202C */ 539 u32 psr_avail_offset; /* 0x202C */
560 RXDMA_PSR_FULL_OFFSET_t psr_full_offset; /* 0x2030 */ 540 u32 psr_full_offset; /* 0x2030 */
561 u32 psr_access_index; /* 0x2034 */ 541 u32 psr_access_index; /* 0x2034 */
562 u32 psr_min_des; /* 0x2038 */ 542 u32 psr_min_des; /* 0x2038 */
563 u32 fbr0_base_lo; /* 0x203C */ 543 u32 fbr0_base_lo; /* 0x203C */
diff --git a/drivers/staging/et131x/et1310_rx.c b/drivers/staging/et131x/et1310_rx.c
index c3778d2c5df5..3ddc9b12b8db 100644
--- a/drivers/staging/et131x/et1310_rx.c
+++ b/drivers/staging/et131x/et1310_rx.c
@@ -624,7 +624,7 @@ void ConfigRxDmaRegs(struct et131x_adapter *etdev)
624 &rx_dma->psr_base_hi); 624 &rx_dma->psr_base_hi);
625 writel((u32) rx_local->pPSRingPa, &rx_dma->psr_base_lo); 625 writel((u32) rx_local->pPSRingPa, &rx_dma->psr_base_lo);
626 writel(rx_local->PsrNumEntries - 1, &rx_dma->psr_num_des); 626 writel(rx_local->PsrNumEntries - 1, &rx_dma->psr_num_des);
627 writel(0, &rx_dma->psr_full_offset.value); 627 writel(0, &rx_dma->psr_full_offset);
628 628
629 psr_num_des = readl(&rx_dma->psr_num_des) & 0xFFF; 629 psr_num_des = readl(&rx_dma->psr_num_des) & 0xFFF;
630 writel((psr_num_des * LO_MARK_PERCENT_FOR_PSR) / 100, 630 writel((psr_num_des * LO_MARK_PERCENT_FOR_PSR) / 100,
@@ -633,8 +633,7 @@ void ConfigRxDmaRegs(struct et131x_adapter *etdev)
633 spin_lock_irqsave(&etdev->RcvLock, flags); 633 spin_lock_irqsave(&etdev->RcvLock, flags);
634 634
635 /* These local variables track the PSR in the adapter structure */ 635 /* These local variables track the PSR in the adapter structure */
636 rx_local->local_psr_full.bits.psr_full = 0; 636 rx_local->local_psr_full = 0;
637 rx_local->local_psr_full.bits.psr_full_wrap = 0;
638 637
639 /* Now's the best time to initialize FBR1 contents */ 638 /* Now's the best time to initialize FBR1 contents */
640 fbr_entry = (PFBR_DESC_t) rx_local->pFbr1RingVa; 639 fbr_entry = (PFBR_DESC_t) rx_local->pFbr1RingVa;
@@ -808,17 +807,18 @@ PMP_RFD nic_rx_pkts(struct et131x_adapter *etdev)
808 */ 807 */
809 status = (PRX_STATUS_BLOCK_t) rx_local->pRxStatusVa; 808 status = (PRX_STATUS_BLOCK_t) rx_local->pRxStatusVa;
810 809
810 /* FIXME: tidy later when conversions complete */
811 if (status->Word1.bits.PSRoffset == 811 if (status->Word1.bits.PSRoffset ==
812 rx_local->local_psr_full.bits.psr_full && 812 (rx_local->local_psr_full & 0xFFF) &&
813 status->Word1.bits.PSRwrap == 813 status->Word1.bits.PSRwrap ==
814 rx_local->local_psr_full.bits.psr_full_wrap) { 814 ((rx_local->local_psr_full >> 12) & 1)) {
815 /* Looks like this ring is not updated yet */ 815 /* Looks like this ring is not updated yet */
816 return NULL; 816 return NULL;
817 } 817 }
818 818
819 /* The packet status ring indicates that data is available. */ 819 /* The packet status ring indicates that data is available. */
820 psr = (PPKT_STAT_DESC_t) (rx_local->pPSRingVa) + 820 psr = (PPKT_STAT_DESC_t) (rx_local->pPSRingVa) +
821 rx_local->local_psr_full.bits.psr_full; 821 (rx_local->local_psr_full & 0xFFF);
822 822
823 /* Grab any information that is required once the PSR is 823 /* Grab any information that is required once the PSR is
824 * advanced, since we can no longer rely on the memory being 824 * advanced, since we can no longer rely on the memory being
@@ -830,14 +830,16 @@ PMP_RFD nic_rx_pkts(struct et131x_adapter *etdev)
830 Word0 = psr->word0; 830 Word0 = psr->word0;
831 831
832 /* Indicate that we have used this PSR entry. */ 832 /* Indicate that we have used this PSR entry. */
833 if (++rx_local->local_psr_full.bits.psr_full > 833 /* FIXME wrap 12 */
834 rx_local->PsrNumEntries - 1) { 834 rx_local->local_psr_full = (rx_local->local_psr_full + 1) & 0xFFF;
835 rx_local->local_psr_full.bits.psr_full = 0; 835 if (rx_local->local_psr_full > rx_local->PsrNumEntries - 1) {
836 rx_local->local_psr_full.bits.psr_full_wrap ^= 1; 836 /* Clear psr full and toggle the wrap bit */
837 rx_local->local_psr_full &= 0xFFF;
838 rx_local->local_psr_full ^= 0x1000;
837 } 839 }
838 840
839 writel(rx_local->local_psr_full.value, 841 writel(rx_local->local_psr_full,
840 &etdev->regs->rxdma.psr_full_offset.value); 842 &etdev->regs->rxdma.psr_full_offset);
841 843
842#ifndef USE_FBR0 844#ifndef USE_FBR0
843 if (rindex != 1) { 845 if (rindex != 1) {
@@ -860,7 +862,7 @@ PMP_RFD nic_rx_pkts(struct et131x_adapter *etdev)
860 dev_err(&etdev->pdev->dev, 862 dev_err(&etdev->pdev->dev,
861 "NICRxPkts PSR Entry %d indicates " 863 "NICRxPkts PSR Entry %d indicates "
862 "length of %d and/or bad bi(%d)\n", 864 "length of %d and/or bad bi(%d)\n",
863 rx_local->local_psr_full.bits.psr_full, 865 rx_local->local_psr_full & 0xFFF,
864 len, bindex); 866 len, bindex);
865 return NULL; 867 return NULL;
866 } 868 }
diff --git a/drivers/staging/et131x/et1310_rx.h b/drivers/staging/et131x/et1310_rx.h
index a11bd8b0872e..69514593612c 100644
--- a/drivers/staging/et131x/et1310_rx.h
+++ b/drivers/staging/et131x/et1310_rx.h
@@ -300,7 +300,7 @@ typedef struct _rx_ring_t {
300 300
301 void *pPSRingVa; 301 void *pPSRingVa;
302 dma_addr_t pPSRingPa; 302 dma_addr_t pPSRingPa;
303 RXDMA_PSR_FULL_OFFSET_t local_psr_full; 303 u32 local_psr_full;
304 u32 PsrNumEntries; 304 u32 PsrNumEntries;
305 305
306 void *pRxStatusVa; 306 void *pRxStatusVa;