devices/e100-2.6.20-ethercat.c
changeset 1228 6d9c686f922e
parent 1227 471ceaf7f89d
child 1229 51d447754109
equal deleted inserted replaced
1227:471ceaf7f89d 1228:6d9c686f922e
  1882 	u16 rfd_status, actual_size;
  1882 	u16 rfd_status, actual_size;
  1883 
  1883 
  1884 	if(unlikely(work_done && *work_done >= work_to_do))
  1884 	if(unlikely(work_done && *work_done >= work_to_do))
  1885 		return -EAGAIN;
  1885 		return -EAGAIN;
  1886 
  1886 
  1887 	return -ENODATA; // FIXME
       
  1888 
       
  1889 	/* Need to sync before taking a peek at cb_complete bit */
  1887 	/* Need to sync before taking a peek at cb_complete bit */
  1890 	pci_dma_sync_single_for_cpu(nic->pdev, rx->dma_addr,
  1888 	pci_dma_sync_single_for_cpu(nic->pdev, rx->dma_addr,
  1891 		sizeof(struct rfd), PCI_DMA_FROMDEVICE);
  1889 		sizeof(struct rfd), PCI_DMA_FROMDEVICE);
  1892 	rfd_status = le16_to_cpu(rfd->status);
  1890 	rfd_status = le16_to_cpu(rfd->status);
  1893 
  1891 
  1899 
  1897 
  1900 	/* Get actual data size */
  1898 	/* Get actual data size */
  1901 	actual_size = le16_to_cpu(rfd->actual_size) & 0x3FFF;
  1899 	actual_size = le16_to_cpu(rfd->actual_size) & 0x3FFF;
  1902 	if(unlikely(actual_size > RFD_BUF_LEN - sizeof(struct rfd)))
  1900 	if(unlikely(actual_size > RFD_BUF_LEN - sizeof(struct rfd)))
  1903 		actual_size = RFD_BUF_LEN - sizeof(struct rfd);
  1901 		actual_size = RFD_BUF_LEN - sizeof(struct rfd);
  1904 
       
  1905 	printk(KERN_INFO "ec_e100 rx %p rec %u\n", rx, actual_size);
       
  1906 	msleep(500); // FIXME
       
  1907 
  1902 
  1908 	/* Get data */
  1903 	/* Get data */
  1909 	pci_unmap_single(nic->pdev, rx->dma_addr,
  1904 	pci_unmap_single(nic->pdev, rx->dma_addr,
  1910 		RFD_BUF_LEN, PCI_DMA_FROMDEVICE);
  1905 		RFD_BUF_LEN, PCI_DMA_FROMDEVICE);
  1911 
  1906 
  1933 	} else {
  1928 	} else {
  1934 		nic->net_stats.rx_packets++;
  1929 		nic->net_stats.rx_packets++;
  1935 		nic->net_stats.rx_bytes += actual_size;
  1930 		nic->net_stats.rx_bytes += actual_size;
  1936 		nic->netdev->last_rx = jiffies;
  1931 		nic->netdev->last_rx = jiffies;
  1937 		if (nic->ecdev) {
  1932 		if (nic->ecdev) {
  1938 #if 0
       
  1939 			ecdev_receive(nic->ecdev,
  1933 			ecdev_receive(nic->ecdev,
  1940 					skb->data + sizeof(struct rfd), actual_size);
  1934 					skb->data + sizeof(struct rfd), actual_size);
  1941 #endif
  1935 
  1942 			// No need to detect link status as
  1936 			// No need to detect link status as
  1943 			// long as frames are received: Reset watchdog.
  1937 			// long as frames are received: Reset watchdog.
  1944 #if 0
       
  1945 			nic->ec_watchdog_jiffies = jiffies;
  1938 			nic->ec_watchdog_jiffies = jiffies;
  1946 #endif
       
  1947 		} else {
  1939 		} else {
  1948 			netif_receive_skb(skb);
  1940 			netif_receive_skb(skb);
  1949 		}
  1941 		}
  1950 		if(work_done)
  1942 		if(work_done)
  1951 			(*work_done)++;
  1943 			(*work_done)++;
  1952 	}
  1944 	}
  1953 
  1945 
  1954 	if (!nic->ecdev)
  1946 	if (nic->ecdev) {
       
  1947 		// make receive frame descriptior usable again
       
  1948 		rfd->status = 0x0000;
       
  1949 		rfd->command = cpu_to_le16(cb_el);
       
  1950 		rx->dma_addr = pci_map_single(nic->pdev, rx->skb->data,
       
  1951 				RFD_BUF_LEN, PCI_DMA_BIDIRECTIONAL);
       
  1952 	} else {
  1955 		rx->skb = NULL;
  1953 		rx->skb = NULL;
       
  1954 	}
  1956 
  1955 
  1957 	return 0;
  1956 	return 0;
  1958 }
  1957 }
  1959 
  1958 
  1960 static void e100_rx_clean(struct nic *nic, unsigned int *work_done,
  1959 static void e100_rx_clean(struct nic *nic, unsigned int *work_done,