devices/ccat/module.h
branchstable-1.5
changeset 2569 720172a7563f
parent 2567 d70aad2f131f
child 2570 144e11d93e99
--- a/devices/ccat/module.h	Thu Jun 05 16:14:13 2014 +0200
+++ b/devices/ccat/module.h	Thu Jun 05 16:30:22 2014 +0200
@@ -25,7 +25,6 @@
 #include <linux/hrtimer.h>
 #include <linux/kernel.h>
 #include <linux/pci.h>
-#include "CCatDefinitions.h"
 #include "../ecdev.h"
 
 #define DRV_EXTRAVERSION "-ec"
@@ -36,6 +35,17 @@
 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
 
 /**
+ * CCAT function type identifiers (u16)
+ */
+enum ccat_info_t {
+	CCATINFO_NOTUSED = 0,
+	CCATINFO_EPCS_PROM = 0xf,
+	CCATINFO_ETHERCAT_MASTER_DMA = 0x14,
+	CCATINFO_COPY_BLOCK = 0x17,
+	CCATINFO_MAX
+};
+
+/**
  * struct ccat_bar - CCAT PCI Base Address Register(BAR) configuration
  * @start: start address of this BAR
  * @end: end address of this BAR
@@ -90,6 +100,7 @@
 	u32 reserved4:31;
 	u64 timestamp;
 	u8 data[0x800 - 3 * sizeof(u64)];
+#define CCAT_ETH_FRAME_HEAD_LEN offsetof(struct ccat_eth_frame, data)
 };
 
 /**
@@ -145,6 +156,21 @@
 	struct ccat_bar bar[3];	//TODO optimize this
 };
 
+struct ccat_info_block
+{
+	u16 type;
+	u16 rev;
+	union {
+		u32 config;
+		struct {
+			u8 tx_dma_chan;
+			u8 rx_dma_chan;
+		};
+	};
+	u32 addr;
+	u32 size;
+};
+
 /**
  * struct ccat_eth_priv - CCAT Ethernet/EtherCAT Master function (netdev)
  * @ccatdev: pointer to the parent struct ccat_device
@@ -164,7 +190,7 @@
 	const struct ccat_device *ccatdev;
 	struct net_device *netdev;
 	const struct ccat_eth_frame *next_tx_frame;
-	CCatInfoBlock info;
+	struct ccat_info_block info;
 	struct ccat_eth_register reg;
 	struct ccat_eth_dma_fifo rx_fifo;
 	struct ccat_eth_dma_fifo tx_fifo;
@@ -186,6 +212,47 @@
 };
 
 /**
+ * same as: typedef struct _CCatInfoBlockOffs from CCatDefinitions.h
+ * TODO add some checking facility outside of the linux tree
+ */
+struct ccat_mac_infoblock {
+	u32 reserved;
+	u32	mii;
+	u32	tx_fifo;
+	u32	mac;
+	u32	rx_mem;
+	u32	tx_mem;
+	u32	misc;
+};
+
+struct ccat_mac_register
+{
+	/** MAC error register     @+0x0 */
+	u8 frame_len_err;
+	u8 rx_err;
+	u8 crc_err;
+	u8 link_lost_err;
+	u32 reserved1;
+	/** Buffer overflow errors @+0x8 */
+	u8 rx_mem_full;
+	u8 reserved2[7];
+	/** MAC frame counter      @+0x10 */
+	u32 tx_frames;
+	u32 rx_frames;
+	u64 reserved3;
+	/** MAC fifo level         @+0x20 */
+	u8 tx_fifo_level : 7;
+	u8 reserved4 : 1;
+	u8 reserved5[7];
+	/** TX memory full error   @+0x28 */
+	u8 tx_mem_full;
+	u8 reserved6[7];
+	u64 reserved8[9];
+	/** Connection             @+0x78 */
+	u8 mii_connected;
+};
+
+/**
  * struct ccat_update - CCAT Update function (update)
  * @ccatdev: pointer to the parent struct ccat_device
  * @ioaddr: PCI base address of the CCAT Update function
@@ -200,6 +267,6 @@
 	dev_t dev;
 	struct cdev cdev;
 	struct class *class;
-	CCatInfoBlock info;
+	struct ccat_info_block info;
 };
 #endif /* #ifndef _CCAT_H_ */