[phantom] Temporary workaround for bug in prototype (P3 B1) silicon
[people/mcb30/gpxe.git] / src / drivers / net / phantom / phantom.c
index 93675e3..8f0453c 100644 (file)
@@ -1445,9 +1445,20 @@ static void phantom_poll ( struct net_device *netdev ) {
 
                /* Check received opcode */
                sds_opcode = NX_GET ( sds, opcode );
-               switch ( sds_opcode ) {
-               case UNM_RXPKT_DESC:
-               case UNM_SYN_OFFLOAD:
+               if ( ( sds_opcode == UNM_RXPKT_DESC ) ||
+                    ( sds_opcode == UNM_SYN_OFFLOAD ) ) {
+
+                       /* Sanity check: ensure that all of the SDS
+                        * descriptor has been written.
+                        */
+                       if ( NX_GET ( sds, total_length ) == 0 ) {
+                               DBGC ( phantom, "Phantom %p port %d SDS %d "
+                                      "incomplete; deferring\n", phantom,
+                                      phantom_port->port, sds_consumer_idx );
+                               /* Leave for next poll() */
+                               break;
+                       }
+
                        /* Process received packet */
                        sds_handle = NX_GET ( sds, handle );
                        iobuf = phantom_port->rds_iobuf[sds_handle];
@@ -1459,25 +1470,27 @@ static void phantom_poll ( struct net_device *netdev ) {
                                phantom, phantom_port->port, sds_handle );
                        netdev_rx ( netdev, iobuf );
                        phantom_port->rds_iobuf[sds_handle] = NULL;
-                       break;
-               default:
+
+                       /* Update RDS consumer counter.  This is a
+                        * lower bound for the number of descriptors
+                        * that have been read by the hardware, since
+                        * the hardware must have read at least one
+                        * descriptor for each completion that we
+                        * receive.
+                        */
+                       rds_consumer_idx =
+                               ( ( rds_consumer_idx + 1 ) % PHN_NUM_RDS );
+                       phantom_port->rds_consumer_idx = rds_consumer_idx;
+
+               } else {
+
                        DBGC ( phantom, "Phantom %p port %d unexpected SDS "
                               "opcode %02x\n",
                               phantom, phantom_port->port, sds_opcode );
                        DBGC_HDA ( phantom, virt_to_bus ( sds ),
                                   sds, sizeof ( *sds ) );
-                       break;
                }
                        
-               /* Update RDS consumer counter.  This is a lower bound
-                * for the number of descriptors that have been read
-                * by the hardware, since the hardware must have read
-                * at least one descriptor for each completion that we
-                * receive.
-                */
-               rds_consumer_idx = ( ( rds_consumer_idx + 1 ) % PHN_NUM_RDS );
-               phantom_port->rds_consumer_idx = rds_consumer_idx;
-
                /* Clear status descriptor */
                memset ( sds, 0, sizeof ( *sds ) );
 
@@ -1621,6 +1634,7 @@ static int phantom_read_flash ( struct phantom_nic *phantom ) {
        /* Identify board type and number of ports */
        switch ( board_info.board_type ) {
        case UNM_BRDTYPE_P3_4_GB:
+       case UNM_BRDTYPE_P3_4_GB_MM:
                phantom->num_ports = 4;
                break;
        case UNM_BRDTYPE_P3_HMEZ:
@@ -1697,7 +1711,8 @@ static int phantom_init_cmdpeg ( struct phantom_nic *phantom ) {
                         UNM_NIC_REG_DUMMY_BUF );
 
        /* Tell the hardware that tuning is complete */
-       phantom_writel ( phantom, 1, UNM_ROMUSB_GLB_PEGTUNE_DONE );
+       phantom_writel ( phantom, UNM_ROMUSB_GLB_PEGTUNE_DONE_MAGIC,
+                        UNM_ROMUSB_GLB_PEGTUNE_DONE );
 
        /* Wait for command PEG to finish initialising */
        DBGC ( phantom, "Phantom %p initialising command PEG (will take up to "
@@ -1845,6 +1860,17 @@ static int phantom_probe ( struct pci_device *pci,
                phantom_port->port = i;
        }
 
+       /* BUG5945 - need to hack PCI config space on P3 B1 silicon.
+        * B2 will have this fixed; remove this hack when B1 is no
+        * longer in use.
+        */
+       {
+               uint32_t temp;
+               pci_read_config_dword ( pci, 0xc8, &temp );
+               pci_read_config_dword ( pci, 0xc8, &temp );
+               pci_write_config_dword ( pci, 0xc8, 0xf1000 );
+       }
+
        /* Allocate dummy DMA buffer and perform initial hardware handshake */
        phantom->dma_buf = malloc_dma ( sizeof ( *(phantom->dma_buf) ),
                                        UNM_DMA_BUFFER_ALIGN );