annotate e1000_initialize_reception.patch @ 77:892b3bc7e43b

Wip on the RX init in the e1000 sample
author Louis Opter <louis@lse.epitech.net>
date Sun, 04 Mar 2012 18:35:43 +0100
parents 51bea596df7f
children 501bf9cf65dc
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
76
51bea596df7f Start a patch for the Rx init
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
1 # HG changeset patch
51bea596df7f Start a patch for the Rx init
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
2 # Parent 40e5b7402e64e301b898fa4da1056a5348522fbb
51bea596df7f Start a patch for the Rx init
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
3 rathaxes: initialize reception on the e1000 sample:
51bea596df7f Start a patch for the Rx init
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
4
51bea596df7f Start a patch for the Rx init
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
5 - This is documented in details in the sections 14.4 and 3.2 of the
51bea596df7f Start a patch for the Rx init
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
6 Intel Gigabit Controller Software Developer manual;
51bea596df7f Start a patch for the Rx init
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
7 - "Address filtering" is set up, address filters just tell the hardware
51bea596df7f Start a patch for the Rx init
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
8 which packets they should accept (unicast/multicast/vlan/promisc), we
51bea596df7f Start a patch for the Rx init
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
9 simply configure the hardware to accept packet for its own mac
51bea596df7f Start a patch for the Rx init
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
10 address (receive address);
51bea596df7f Start a patch for the Rx init
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
11 - It involves setting up a ring of receive descriptors (their format is
51bea596df7f Start a patch for the Rx init
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
12 documented in section 3.2.3) and an internal data structure to keep
51bea596df7f Start a patch for the Rx init
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
13 track of the ring;
51bea596df7f Start a patch for the Rx init
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
14 - Each descriptor of the ring correspond to an skbuff (skbuff are
51bea596df7f Start a patch for the Rx init
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
15 allocated individually).
51bea596df7f Start a patch for the Rx init
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
16
51bea596df7f Start a patch for the Rx init
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
17 diff --git a/rathaxes/samples/e1000/e1000.blt b/rathaxes/samples/e1000/e1000.blt
51bea596df7f Start a patch for the Rx init
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
18 --- a/rathaxes/samples/e1000/e1000.blt
51bea596df7f Start a patch for the Rx init
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
19 +++ b/rathaxes/samples/e1000/e1000.blt
77
892b3bc7e43b Wip on the RX init in the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents: 76
diff changeset
20 @@ -21,9 +21,12 @@
892b3bc7e43b Wip on the RX init in the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents: 76
diff changeset
21 */
892b3bc7e43b Wip on the RX init in the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents: 76
diff changeset
22 typedef struct rtx_e1000_ctx
892b3bc7e43b Wip on the RX init in the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents: 76
diff changeset
23 {
892b3bc7e43b Wip on the RX init in the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents: 76
diff changeset
24 - int bars;
892b3bc7e43b Wip on the RX init in the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents: 76
diff changeset
25 - unsigned char /* __iomem */ *ioaddr;
892b3bc7e43b Wip on the RX init in the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents: 76
diff changeset
26 - int irq;
892b3bc7e43b Wip on the RX init in the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents: 76
diff changeset
27 + int bars;
892b3bc7e43b Wip on the RX init in the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents: 76
diff changeset
28 + unsigned char /* __iomem */ *ioaddr;
892b3bc7e43b Wip on the RX init in the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents: 76
diff changeset
29 + int irq;
892b3bc7e43b Wip on the RX init in the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents: 76
diff changeset
30 +
892b3bc7e43b Wip on the RX init in the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents: 76
diff changeset
31 + /* we can't use the Rathaxes type here (#8) */
892b3bc7e43b Wip on the RX init in the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents: 76
diff changeset
32 + struct rtx_e1000_rx_ring rx_ring;
892b3bc7e43b Wip on the RX init in the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents: 76
diff changeset
33 } *rtx_e1000_ctx_p;
892b3bc7e43b Wip on the RX init in the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents: 76
diff changeset
34 }
892b3bc7e43b Wip on the RX init in the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents: 76
diff changeset
35
892b3bc7e43b Wip on the RX init in the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents: 76
diff changeset
36 @@ -36,6 +39,78 @@
76
51bea596df7f Start a patch for the Rx init
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
37 }
51bea596df7f Start a patch for the Rx init
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
38 }
51bea596df7f Start a patch for the Rx init
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
39
77
892b3bc7e43b Wip on the RX init in the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents: 76
diff changeset
40 + template type e1000::RxDescriptor()
76
51bea596df7f Start a patch for the Rx init
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
41 + {
51bea596df7f Start a patch for the Rx init
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
42 + chunk LKM::includes()
51bea596df7f Start a patch for the Rx init
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
43 + {
77
892b3bc7e43b Wip on the RX init in the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents: 76
diff changeset
44 + typedef int ${e1000::RxDescriptor};
892b3bc7e43b Wip on the RX init in the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents: 76
diff changeset
45 +
892b3bc7e43b Wip on the RX init in the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents: 76
diff changeset
46 + #include <linux/types.h>
76
51bea596df7f Start a patch for the Rx init
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
47 + }
51bea596df7f Start a patch for the Rx init
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
48 +
51bea596df7f Start a patch for the Rx init
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
49 + chunk ::decl()
51bea596df7f Start a patch for the Rx init
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
50 + {
77
892b3bc7e43b Wip on the RX init in the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents: 76
diff changeset
51 + typedef struct rtx_e1000_rx_descriptor
892b3bc7e43b Wip on the RX init in the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents: 76
diff changeset
52 + {
892b3bc7e43b Wip on the RX init in the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents: 76
diff changeset
53 + /* actual types are in comments */
892b3bc7e43b Wip on the RX init in the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents: 76
diff changeset
54 + unsigned long int /* __le64 */ buff_addr;
892b3bc7e43b Wip on the RX init in the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents: 76
diff changeset
55 + unsigned short /* __le16 */ length;
892b3bc7e43b Wip on the RX init in the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents: 76
diff changeset
56 + unsigned short /* __le16 */ csum;
892b3bc7e43b Wip on the RX init in the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents: 76
diff changeset
57 + unsigned char status;
892b3bc7e43b Wip on the RX init in the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents: 76
diff changeset
58 + unsigned char errors;
892b3bc7e43b Wip on the RX init in the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents: 76
diff changeset
59 + unsigned short /* __le16 */ special;
892b3bc7e43b Wip on the RX init in the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents: 76
diff changeset
60 + } *rtx_e1000_rx_descriptor_p;
892b3bc7e43b Wip on the RX init in the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents: 76
diff changeset
61 + }
892b3bc7e43b Wip on the RX init in the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents: 76
diff changeset
62 +
892b3bc7e43b Wip on the RX init in the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents: 76
diff changeset
63 + chunk ::init()
892b3bc7e43b Wip on the RX init in the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents: 76
diff changeset
64 + {
892b3bc7e43b Wip on the RX init in the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents: 76
diff changeset
65 + }
892b3bc7e43b Wip on the RX init in the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents: 76
diff changeset
66 +
892b3bc7e43b Wip on the RX init in the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents: 76
diff changeset
67 + map
892b3bc7e43b Wip on the RX init in the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents: 76
diff changeset
68 + {
892b3bc7e43b Wip on the RX init in the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents: 76
diff changeset
69 + }
892b3bc7e43b Wip on the RX init in the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents: 76
diff changeset
70 + }
892b3bc7e43b Wip on the RX init in the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents: 76
diff changeset
71 +
892b3bc7e43b Wip on the RX init in the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents: 76
diff changeset
72 + template type e1000::RxRing()
892b3bc7e43b Wip on the RX init in the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents: 76
diff changeset
73 + {
892b3bc7e43b Wip on the RX init in the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents: 76
diff changeset
74 + chunk LKM::includes()
892b3bc7e43b Wip on the RX init in the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents: 76
diff changeset
75 + {
892b3bc7e43b Wip on the RX init in the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents: 76
diff changeset
76 + typedef int ${e1000::RxRing};
892b3bc7e43b Wip on the RX init in the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents: 76
diff changeset
77 + }
892b3bc7e43b Wip on the RX init in the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents: 76
diff changeset
78 +
892b3bc7e43b Wip on the RX init in the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents: 76
diff changeset
79 + chunk ::decl()
892b3bc7e43b Wip on the RX init in the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents: 76
diff changeset
80 + {
892b3bc7e43b Wip on the RX init in the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents: 76
diff changeset
81 + /*
892b3bc7e43b Wip on the RX init in the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents: 76
diff changeset
82 + * - size: total size of the ring in bytes.
892b3bc7e43b Wip on the RX init in the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents: 76
diff changeset
83 + * - base: address of the ring;
892b3bc7e43b Wip on the RX init in the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents: 76
diff changeset
84 + * - dma_base: (physical) address of the ring where the device
892b3bc7e43b Wip on the RX init in the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents: 76
diff changeset
85 + * can access it;
892b3bc7e43b Wip on the RX init in the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents: 76
diff changeset
86 + * - skbuffs: array of the skbuffs associated with
892b3bc7e43b Wip on the RX init in the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents: 76
diff changeset
87 + * each descriptor;
892b3bc7e43b Wip on the RX init in the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents: 76
diff changeset
88 + * - dma_skbuffs: (physical) address of each skbuff
892b3bc7e43b Wip on the RX init in the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents: 76
diff changeset
89 + * where the device can write the received
892b3bc7e43b Wip on the RX init in the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents: 76
diff changeset
90 + * packets;
892b3bc7e43b Wip on the RX init in the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents: 76
diff changeset
91 + */
892b3bc7e43b Wip on the RX init in the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents: 76
diff changeset
92 + struct rtx_e1000_rx_ring
892b3bc7e43b Wip on the RX init in the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents: 76
diff changeset
93 + {
892b3bc7e43b Wip on the RX init in the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents: 76
diff changeset
94 + unsigned int size;
892b3bc7e43b Wip on the RX init in the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents: 76
diff changeset
95 + rtx_e1000_rx_descriptor_p base;
892b3bc7e43b Wip on the RX init in the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents: 76
diff changeset
96 + void *dma_base;
892b3bc7e43b Wip on the RX init in the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents: 76
diff changeset
97 +
892b3bc7e43b Wip on the RX init in the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents: 76
diff changeset
98 + struct sk_buff *skbuffs[256 /* ${config.rx_ring_size} */];
892b3bc7e43b Wip on the RX init in the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents: 76
diff changeset
99 + void *dma_skbuffs[256 /* ${config.rx_ring_size} */];
892b3bc7e43b Wip on the RX init in the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents: 76
diff changeset
100 + };
76
51bea596df7f Start a patch for the Rx init
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
101 + }
51bea596df7f Start a patch for the Rx init
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
102 +
51bea596df7f Start a patch for the Rx init
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
103 + chunk ::init()
51bea596df7f Start a patch for the Rx init
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
104 + {
51bea596df7f Start a patch for the Rx init
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
105 + }
51bea596df7f Start a patch for the Rx init
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
106 +
51bea596df7f Start a patch for the Rx init
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
107 + map
51bea596df7f Start a patch for the Rx init
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
108 + {
51bea596df7f Start a patch for the Rx init
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
109 + }
51bea596df7f Start a patch for the Rx init
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
110 + }
51bea596df7f Start a patch for the Rx init
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
111 +
51bea596df7f Start a patch for the Rx init
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
112 template type e1000::Register()
51bea596df7f Start a patch for the Rx init
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
113 {
51bea596df7f Start a patch for the Rx init
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
114 chunk LKM::includes()
77
892b3bc7e43b Wip on the RX init in the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents: 76
diff changeset
115 @@ -64,6 +139,9 @@
76
51bea596df7f Start a patch for the Rx init
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
116 E1000_FCT = 0x00030, /* Flow Control Type */
51bea596df7f Start a patch for the Rx init
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
117 E1000_FCTTV = 0x00170, /* Flow Control Transmit Timer Value */
51bea596df7f Start a patch for the Rx init
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
118 E1000_CRCERRS = 0x04000, /* CRC Error Count (base address of the statistic register spaces) */
51bea596df7f Start a patch for the Rx init
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
119 + E1000_RAL = 0x05400, /* Receive Address Low */
51bea596df7f Start a patch for the Rx init
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
120 + E1000_RAH = 0x05404, /* Receive Address High */
51bea596df7f Start a patch for the Rx init
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
121 + E1000_MTA = 0x05200, /* Multicast Table Array */
51bea596df7f Start a patch for the Rx init
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
122 };
51bea596df7f Start a patch for the Rx init
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
123 }
51bea596df7f Start a patch for the Rx init
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
124
77
892b3bc7e43b Wip on the RX init in the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents: 76
diff changeset
125 @@ -132,7 +210,8 @@
76
51bea596df7f Start a patch for the Rx init
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
126 E1000_INTR_RXDMT0 = 0x00000010, /* rx desc min. threshold (0) */
51bea596df7f Start a patch for the Rx init
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
127 E1000_INTR_RXO = 0x00000040, /* rx overrun */
51bea596df7f Start a patch for the Rx init
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
128 E1000_INTR_RXT0 = 0x00000080, /* rx timer intr (ring 0) */
51bea596df7f Start a patch for the Rx init
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
129 - E1000_INTR_MDAC = 0x00000200 /* MDIO access complete */
51bea596df7f Start a patch for the Rx init
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
130 + E1000_INTR_MDAC = 0x00000200, /* MDIO access complete */
51bea596df7f Start a patch for the Rx init
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
131 + E1000_RAH_AV = (1 << 31), /* Set the MAC Address as Valid */
51bea596df7f Start a patch for the Rx init
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
132 };
51bea596df7f Start a patch for the Rx init
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
133 }
51bea596df7f Start a patch for the Rx init
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
134
77
892b3bc7e43b Wip on the RX init in the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents: 76
diff changeset
135 @@ -458,14 +537,23 @@
892b3bc7e43b Wip on the RX init in the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents: 76
diff changeset
136 chunk ::CALL
892b3bc7e43b Wip on the RX init in the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents: 76
diff changeset
137 {
892b3bc7e43b Wip on the RX init in the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents: 76
diff changeset
138 /*
892b3bc7e43b Wip on the RX init in the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents: 76
diff changeset
139 - * This is documented in the Intel Gigabit Ethernet Controller
892b3bc7e43b Wip on the RX init in the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents: 76
diff changeset
140 - * Software Developper manual.
892b3bc7e43b Wip on the RX init in the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents: 76
diff changeset
141 + * This part is documented in the Intel Gigabit Ethernet Controller
892b3bc7e43b Wip on the RX init in the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents: 76
diff changeset
142 + * Software Developper manual. (You can find it in the doc/hardware
892b3bc7e43b Wip on the RX init in the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents: 76
diff changeset
143 + * directory).
892b3bc7e43b Wip on the RX init in the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents: 76
diff changeset
144 *
892b3bc7e43b Wip on the RX init in the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents: 76
diff changeset
145 * Since this part is actually completely device specific it should
892b3bc7e43b Wip on the RX init in the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents: 76
diff changeset
146 * not be written here. (but in the front-end).
892b3bc7e43b Wip on the RX init in the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents: 76
diff changeset
147 */
892b3bc7e43b Wip on the RX init in the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents: 76
diff changeset
148
892b3bc7e43b Wip on the RX init in the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents: 76
diff changeset
149 /*
892b3bc7e43b Wip on the RX init in the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents: 76
diff changeset
150 + * shortcut hw_ctx... maybe we should directly take an
892b3bc7e43b Wip on the RX init in the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents: 76
diff changeset
151 + * e1000::Context? (but we would need to make it point back to
892b3bc7e43b Wip on the RX init in the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents: 76
diff changeset
152 + * the struct net_device)
892b3bc7e43b Wip on the RX init in the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents: 76
diff changeset
153 + */
892b3bc7e43b Wip on the RX init in the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents: 76
diff changeset
154 + ${e1000::Context} hw_ctx;
892b3bc7e43b Wip on the RX init in the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents: 76
diff changeset
155 + hw_ctx = &${ctx}->hw_ctx;
892b3bc7e43b Wip on the RX init in the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents: 76
diff changeset
156 +
892b3bc7e43b Wip on the RX init in the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents: 76
diff changeset
157 + /*
892b3bc7e43b Wip on the RX init in the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents: 76
diff changeset
158 * "General Configuration" (section 14.3):
892b3bc7e43b Wip on the RX init in the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents: 76
diff changeset
159 *
892b3bc7e43b Wip on the RX init in the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents: 76
diff changeset
160 * - CTRL.ASDE/CTRL.SLU: Let the PHY handle the speed detection &
892b3bc7e43b Wip on the RX init in the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents: 76
diff changeset
161 @@ -478,22 +566,111 @@
892b3bc7e43b Wip on the RX init in the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents: 76
diff changeset
162 * - Finally, initialize all the statistic registers from
892b3bc7e43b Wip on the RX init in the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents: 76
diff changeset
163 * E1000_CRCERRS to E1000_TSCTFC.
892b3bc7e43b Wip on the RX init in the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents: 76
diff changeset
164 */
892b3bc7e43b Wip on the RX init in the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents: 76
diff changeset
165 - rtx_e1000_register_set32(&${ctx}->hw_ctx, E1000_CTRL,
892b3bc7e43b Wip on the RX init in the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents: 76
diff changeset
166 +
892b3bc7e43b Wip on the RX init in the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents: 76
diff changeset
167 + rtx_e1000_register_set32(hw_ctx, E1000_CTRL,
892b3bc7e43b Wip on the RX init in the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents: 76
diff changeset
168 E1000_CMD_ASDE |
892b3bc7e43b Wip on the RX init in the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents: 76
diff changeset
169 E1000_CMD_SLU);
892b3bc7e43b Wip on the RX init in the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents: 76
diff changeset
170 - rtx_e1000_register_unset32(&${ctx}->hw_ctx, E1000_CTRL,
892b3bc7e43b Wip on the RX init in the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents: 76
diff changeset
171 + rtx_e1000_register_unset32(hw_ctx, E1000_CTRL,
892b3bc7e43b Wip on the RX init in the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents: 76
diff changeset
172 E1000_CMD_LRST |
892b3bc7e43b Wip on the RX init in the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents: 76
diff changeset
173 E1000_CMD_FRCSPD |
892b3bc7e43b Wip on the RX init in the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents: 76
diff changeset
174 E1000_CMD_PHY_RST |
892b3bc7e43b Wip on the RX init in the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents: 76
diff changeset
175 E1000_CMD_ILOS |
892b3bc7e43b Wip on the RX init in the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents: 76
diff changeset
176 E1000_CMD_VME);
892b3bc7e43b Wip on the RX init in the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents: 76
diff changeset
177 - rtx_e1000_register_write32(&${ctx}->hw_ctx, E1000_FCAH, 0);
892b3bc7e43b Wip on the RX init in the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents: 76
diff changeset
178 - rtx_e1000_register_write32(&${ctx}->hw_ctx, E1000_FCAL, 0);
892b3bc7e43b Wip on the RX init in the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents: 76
diff changeset
179 - rtx_e1000_register_write32(&${ctx}->hw_ctx, E1000_FCT, 0);
892b3bc7e43b Wip on the RX init in the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents: 76
diff changeset
180 - rtx_e1000_register_write32(&${ctx}->hw_ctx, E1000_FCTTV, 0);
76
51bea596df7f Start a patch for the Rx init
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
181 - int i = 0;
77
892b3bc7e43b Wip on the RX init in the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents: 76
diff changeset
182 + rtx_e1000_register_write32(hw_ctx, E1000_FCAH, 0);
892b3bc7e43b Wip on the RX init in the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents: 76
diff changeset
183 + rtx_e1000_register_write32(hw_ctx, E1000_FCAL, 0);
892b3bc7e43b Wip on the RX init in the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents: 76
diff changeset
184 + rtx_e1000_register_write32(hw_ctx, E1000_FCT, 0);
892b3bc7e43b Wip on the RX init in the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents: 76
diff changeset
185 + rtx_e1000_register_write32(hw_ctx, E1000_FCTTV, 0);
76
51bea596df7f Start a patch for the Rx init
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
186 + int i = 0; /* CNorm workaround, the init part of for isn't generated */
51bea596df7f Start a patch for the Rx init
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
187 for (i = 0; i != 64; ++i)
77
892b3bc7e43b Wip on the RX init in the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents: 76
diff changeset
188 - rtx_e1000_register_write32(&${ctx}->hw_ctx, E1000_CRCERRS + i * 4, 0);
892b3bc7e43b Wip on the RX init in the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents: 76
diff changeset
189 + rtx_e1000_register_write32(hw_ctx, E1000_CRCERRS + i * 4, 0);
76
51bea596df7f Start a patch for the Rx init
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
190 +
51bea596df7f Start a patch for the Rx init
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
191 + /*
51bea596df7f Start a patch for the Rx init
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
192 + * Receive initialization
51bea596df7f Start a patch for the Rx init
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
193 + *
51bea596df7f Start a patch for the Rx init
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
194 + * - Program the receive address, in RAL/RAH;
51bea596df7f Start a patch for the Rx init
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
195 + * - Initialize the Multicast Table Array;
51bea596df7f Start a patch for the Rx init
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
196 + * - Program the interrupt mask register (done in
51bea596df7f Start a patch for the Rx init
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
197 + * e1000::activate_device_interruption);
77
892b3bc7e43b Wip on the RX init in the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents: 76
diff changeset
198 + * - Allocate the receive descriptor ring and map it to make it
892b3bc7e43b Wip on the RX init in the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents: 76
diff changeset
199 + * accessible by the device.
76
51bea596df7f Start a patch for the Rx init
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
200 + */
77
892b3bc7e43b Wip on the RX init in the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents: 76
diff changeset
201 +
892b3bc7e43b Wip on the RX init in the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents: 76
diff changeset
202 + /* (We should use uint{32,16}_t but CNorm doesn't know them yet) */
892b3bc7e43b Wip on the RX init in the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents: 76
diff changeset
203 + rtx_e1000_register_write32(hw_ctx, E1000_RAL,
76
51bea596df7f Start a patch for the Rx init
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
204 + *(unsigned int *)(${ctx}->net_dev->dev_addr));
51bea596df7f Start a patch for the Rx init
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
205 + /*
51bea596df7f Start a patch for the Rx init
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
206 + * The 16 upper bits of RAH also store the AS bits (which should be
51bea596df7f Start a patch for the Rx init
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
207 + * 0) and the AV bit (should be 1 to set the address as valid).
51bea596df7f Start a patch for the Rx init
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
208 + */
77
892b3bc7e43b Wip on the RX init in the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents: 76
diff changeset
209 + rtx_e1000_register_write32(hw_ctx, E1000_RAH,
76
51bea596df7f Start a patch for the Rx init
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
210 + *(unsigned short *)(&${ctx}->net_dev->dev_addr[4]));
77
892b3bc7e43b Wip on the RX init in the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents: 76
diff changeset
211 + rtx_e1000_register_set32(hw_ctx, E1000_RAH, E1000_RAH_AV);
892b3bc7e43b Wip on the RX init in the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents: 76
diff changeset
212 +
76
51bea596df7f Start a patch for the Rx init
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
213 + i = 0; /* CNorm workaround, the init part of for isn't generated */
51bea596df7f Start a patch for the Rx init
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
214 + for (i = 0; i != 128; ++i)
77
892b3bc7e43b Wip on the RX init in the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents: 76
diff changeset
215 + rtx_e1000_register_write32(hw_ctx, E1000_MTA + i * 4, 0);
892b3bc7e43b Wip on the RX init in the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents: 76
diff changeset
216 +
892b3bc7e43b Wip on the RX init in the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents: 76
diff changeset
217 + hw_ctx->rx_ring.size = ${config.rx_ring_size} * sizeof(*hw_ctx->rx_ring.base);
892b3bc7e43b Wip on the RX init in the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents: 76
diff changeset
218 + hw_ctx->rx_ring.size = ALIGN(hw_ctx->rx_ring.size, 4096);
892b3bc7e43b Wip on the RX init in the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents: 76
diff changeset
219 + hw_ctx->rx_ring.base = dma_alloc_coherent(&${ctx}->pci_dev->dev,
892b3bc7e43b Wip on the RX init in the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents: 76
diff changeset
220 + hw_ctx->rx_ring.size, &hw_ctx->rx_ring.dma_base, GFP_KERNEL);
892b3bc7e43b Wip on the RX init in the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents: 76
diff changeset
221 + if (!hw->ctx->rx_ring.base)
892b3bc7e43b Wip on the RX init in the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents: 76
diff changeset
222 + {
892b3bc7e43b Wip on the RX init in the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents: 76
diff changeset
223 + ${Log::info("cannot allocate the descriptors for the Rx ring")};
892b3bc7e43b Wip on the RX init in the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents: 76
diff changeset
224 + goto err_rx_ring_alloc;
892b3bc7e43b Wip on the RX init in the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents: 76
diff changeset
225 + }
892b3bc7e43b Wip on the RX init in the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents: 76
diff changeset
226 +
892b3bc7e43b Wip on the RX init in the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents: 76
diff changeset
227 + i = 0;
892b3bc7e43b Wip on the RX init in the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents: 76
diff changeset
228 + for (i = 0; i != ${config.rx_ring_size}; ++i)
892b3bc7e43b Wip on the RX init in the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents: 76
diff changeset
229 + {
892b3bc7e43b Wip on the RX init in the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents: 76
diff changeset
230 + hw_ctx->rx_ring.skbuffs[i] = netdev_allock_skb(${ctx}->net_device,
892b3bc7e43b Wip on the RX init in the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents: 76
diff changeset
231 + ${config.rx_buffer_len});
892b3bc7e43b Wip on the RX init in the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents: 76
diff changeset
232 + if (!hw_ctx->rx_ring.skbuffs[i])
892b3bc7e43b Wip on the RX init in the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents: 76
diff changeset
233 + {
892b3bc7e43b Wip on the RX init in the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents: 76
diff changeset
234 + ${Log::info("cannot allocate a skbuff for the Rx ring")};
892b3bc7e43b Wip on the RX init in the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents: 76
diff changeset
235 + goto err_skbuffs_alloc;
892b3bc7e43b Wip on the RX init in the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents: 76
diff changeset
236 + }
892b3bc7e43b Wip on the RX init in the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents: 76
diff changeset
237 + hw_ctx->rx_ring.dma_skbuffs[i] = dma_map_single(&${ctx}->pci_dev->dev,
892b3bc7e43b Wip on the RX init in the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents: 76
diff changeset
238 + hw_ctx->rx_ring.skbuffs[i]->data,
892b3bc7e43b Wip on the RX init in the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents: 76
diff changeset
239 + ${config.rx_buffer_len},
892b3bc7e43b Wip on the RX init in the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents: 76
diff changeset
240 + DMA_FROM_DEVICE);
892b3bc7e43b Wip on the RX init in the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents: 76
diff changeset
241 + if (dma_mapping_error(&${ctx}->pci_dev->dev,
892b3bc7e43b Wip on the RX init in the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents: 76
diff changeset
242 + hw_ctx->rx_ring.dma_skbuffs[i]))
892b3bc7e43b Wip on the RX init in the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents: 76
diff changeset
243 + {
892b3bc7e43b Wip on the RX init in the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents: 76
diff changeset
244 + ${Log::info("cannot dma-map a skbuff for the Rx ring")};
892b3bc7e43b Wip on the RX init in the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents: 76
diff changeset
245 + goto err_skbuffs_map;
892b3bc7e43b Wip on the RX init in the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents: 76
diff changeset
246 + }
892b3bc7e43b Wip on the RX init in the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents: 76
diff changeset
247 + hw_ctx->rx_ring.base[i].buff_addr = cpu_to_le64(hw_ctx->rx_ring.dma_skbuffs[i]);
892b3bc7e43b Wip on the RX init in the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents: 76
diff changeset
248 + }
892b3bc7e43b Wip on the RX init in the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents: 76
diff changeset
249 +
892b3bc7e43b Wip on the RX init in the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents: 76
diff changeset
250 + /*
892b3bc7e43b Wip on the RX init in the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents: 76
diff changeset
251 + * Always the same problem with error handling, we don't know where
892b3bc7e43b Wip on the RX init in the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents: 76
diff changeset
252 + * we are at in the "parent context":
892b3bc7e43b Wip on the RX init in the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents: 76
diff changeset
253 + */
892b3bc7e43b Wip on the RX init in the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents: 76
diff changeset
254 +
892b3bc7e43b Wip on the RX init in the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents: 76
diff changeset
255 + err_skbuffs_alloc:
892b3bc7e43b Wip on the RX init in the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents: 76
diff changeset
256 + while (i--)
892b3bc7e43b Wip on the RX init in the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents: 76
diff changeset
257 + {
892b3bc7e43b Wip on the RX init in the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents: 76
diff changeset
258 + dma_unmap_single(&${ctx}->pci_dev->dev,
892b3bc7e43b Wip on the RX init in the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents: 76
diff changeset
259 + hw_ctx->rx_ring.dma_skbuffs[i],
892b3bc7e43b Wip on the RX init in the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents: 76
diff changeset
260 + ${config.rx_buffer_len},
892b3bc7e43b Wip on the RX init in the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents: 76
diff changeset
261 + DMA_FROM_DEVICE);
892b3bc7e43b Wip on the RX init in the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents: 76
diff changeset
262 + err_skbuffs_map:
892b3bc7e43b Wip on the RX init in the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents: 76
diff changeset
263 + dev_kfree_skb(hw_ctx->rx_ring.skbuffs[i]);
892b3bc7e43b Wip on the RX init in the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents: 76
diff changeset
264 + }
892b3bc7e43b Wip on the RX init in the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents: 76
diff changeset
265 +
892b3bc7e43b Wip on the RX init in the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents: 76
diff changeset
266 + dma_free_coherent(&${ctx}->pci_dev->dev, hw_ctx->rx_ring.size,
892b3bc7e43b Wip on the RX init in the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents: 76
diff changeset
267 + hw_ctx->rx_ring.base, hw_ctx->rx_ring.dma_base);
892b3bc7e43b Wip on the RX init in the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents: 76
diff changeset
268 + err_rx_ring_alloc:
892b3bc7e43b Wip on the RX init in the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents: 76
diff changeset
269 + return -ENOMEM;
892b3bc7e43b Wip on the RX init in the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents: 76
diff changeset
270 + }
892b3bc7e43b Wip on the RX init in the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents: 76
diff changeset
271 + }
892b3bc7e43b Wip on the RX init in the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents: 76
diff changeset
272 +
892b3bc7e43b Wip on the RX init in the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents: 76
diff changeset
273 + template sequence e1000::free_rx_tx(Ethernet::Device ctx)
892b3bc7e43b Wip on the RX init in the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents: 76
diff changeset
274 + {
892b3bc7e43b Wip on the RX init in the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents: 76
diff changeset
275 + chunk ::CALL
892b3bc7e43b Wip on the RX init in the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents: 76
diff changeset
276 + {
892b3bc7e43b Wip on the RX init in the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents: 76
diff changeset
277 +
76
51bea596df7f Start a patch for the Rx init
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
278 }
51bea596df7f Start a patch for the Rx init
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
279 }
51bea596df7f Start a patch for the Rx init
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
280
51bea596df7f Start a patch for the Rx init
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
281 diff --git a/rathaxes/samples/e1000/e1000.rti b/rathaxes/samples/e1000/e1000.rti
51bea596df7f Start a patch for the Rx init
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
282 --- a/rathaxes/samples/e1000/e1000.rti
51bea596df7f Start a patch for the Rx init
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
283 +++ b/rathaxes/samples/e1000/e1000.rti
77
892b3bc7e43b Wip on the RX init in the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents: 76
diff changeset
284 @@ -1,6 +1,9 @@
76
51bea596df7f Start a patch for the Rx init
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
285 interface e1000 : Socket, Ethernet, PCI, LKM
51bea596df7f Start a patch for the Rx init
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
286 {
51bea596df7f Start a patch for the Rx init
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
287 provided type e1000::Context;
77
892b3bc7e43b Wip on the RX init in the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents: 76
diff changeset
288 + provided type e1000::RxDescriptor;
892b3bc7e43b Wip on the RX init in the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents: 76
diff changeset
289 + provided type e1000::RxRing;
76
51bea596df7f Start a patch for the Rx init
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
290 +
51bea596df7f Start a patch for the Rx init
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
291 /*
51bea596df7f Start a patch for the Rx init
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
292 * These two types should actually be registers definitions in the frontend:
51bea596df7f Start a patch for the Rx init
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
293 */
77
892b3bc7e43b Wip on the RX init in the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents: 76
diff changeset
294 @@ -57,6 +60,11 @@
892b3bc7e43b Wip on the RX init in the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents: 76
diff changeset
295 provided chunk ::CALL;
892b3bc7e43b Wip on the RX init in the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents: 76
diff changeset
296 }
892b3bc7e43b Wip on the RX init in the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents: 76
diff changeset
297
892b3bc7e43b Wip on the RX init in the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents: 76
diff changeset
298 + provided sequence e1000::free_rx_tx(Ethernet::Device dev)
892b3bc7e43b Wip on the RX init in the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents: 76
diff changeset
299 + {
892b3bc7e43b Wip on the RX init in the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents: 76
diff changeset
300 + provided chunk ::CALL;
892b3bc7e43b Wip on the RX init in the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents: 76
diff changeset
301 + }
892b3bc7e43b Wip on the RX init in the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents: 76
diff changeset
302 +
892b3bc7e43b Wip on the RX init in the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents: 76
diff changeset
303 provided sequence e1000::handle_interrupt(Ethernet::Device)
892b3bc7e43b Wip on the RX init in the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents: 76
diff changeset
304 {
892b3bc7e43b Wip on the RX init in the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents: 76
diff changeset
305 provided chunk ::CALL;
892b3bc7e43b Wip on the RX init in the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents: 76
diff changeset
306 diff --git a/rathaxes/samples/e1000/ethernet.blt b/rathaxes/samples/e1000/ethernet.blt
892b3bc7e43b Wip on the RX init in the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents: 76
diff changeset
307 --- a/rathaxes/samples/e1000/ethernet.blt
892b3bc7e43b Wip on the RX init in the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents: 76
diff changeset
308 +++ b/rathaxes/samples/e1000/ethernet.blt
892b3bc7e43b Wip on the RX init in the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents: 76
diff changeset
309 @@ -102,7 +102,7 @@
892b3bc7e43b Wip on the RX init in the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents: 76
diff changeset
310 {
892b3bc7e43b Wip on the RX init in the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents: 76
diff changeset
311 static int rtx_ethernet_close(struct net_device *dev)
892b3bc7e43b Wip on the RX init in the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents: 76
diff changeset
312 {
892b3bc7e43b Wip on the RX init in the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents: 76
diff changeset
313 - struct rtx_ethernet_dev* rtx_ether_dev = netdev_priv(dev);
892b3bc7e43b Wip on the RX init in the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents: 76
diff changeset
314 + struct rtx_ethernet_dev* rtx_ether_dev = netdev_priv(dev);
892b3bc7e43b Wip on the RX init in the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents: 76
diff changeset
315 struct rtx_e1000_ctx* ctx = &rtx_ether_dev->hw_ctx;
892b3bc7e43b Wip on the RX init in the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents: 76
diff changeset
316
892b3bc7e43b Wip on the RX init in the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents: 76
diff changeset
317 ${pointcut ::IMPLEMENTATION(local.rtx_ether_dev)};
892b3bc7e43b Wip on the RX init in the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents: 76
diff changeset
318 diff --git a/rathaxes/samples/e1000/lkm.rtx b/rathaxes/samples/e1000/lkm.rtx
892b3bc7e43b Wip on the RX init in the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents: 76
diff changeset
319 --- a/rathaxes/samples/e1000/lkm.rtx
892b3bc7e43b Wip on the RX init in the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents: 76
diff changeset
320 +++ b/rathaxes/samples/e1000/lkm.rtx
892b3bc7e43b Wip on the RX init in the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents: 76
diff changeset
321 @@ -24,7 +24,17 @@
892b3bc7e43b Wip on the RX init in the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents: 76
diff changeset
322 Ethernet::close(Ethernet::Device dev)
892b3bc7e43b Wip on the RX init in the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents: 76
diff changeset
323 {
892b3bc7e43b Wip on the RX init in the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents: 76
diff changeset
324 Log::info("closing the device");
892b3bc7e43b Wip on the RX init in the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents: 76
diff changeset
325 +
892b3bc7e43b Wip on the RX init in the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents: 76
diff changeset
326 + /*
892b3bc7e43b Wip on the RX init in the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents: 76
diff changeset
327 + * Note: some calls to release resources must be done when IRQs are
892b3bc7e43b Wip on the RX init in the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents: 76
diff changeset
328 + * enabled (dma_free_coherent() for example). So we have to cleanup our
892b3bc7e43b Wip on the RX init in the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents: 76
diff changeset
329 + * stuff before free_interrupt_handler().
892b3bc7e43b Wip on the RX init in the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents: 76
diff changeset
330 + */
892b3bc7e43b Wip on the RX init in the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents: 76
diff changeset
331 + e1000::free_rx_tx(dev);
892b3bc7e43b Wip on the RX init in the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents: 76
diff changeset
332 + Log::info("free'ed up skbuffs");
892b3bc7e43b Wip on the RX init in the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents: 76
diff changeset
333 +
892b3bc7e43b Wip on the RX init in the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents: 76
diff changeset
334 e1000::free_interrupt_handler(dev);
892b3bc7e43b Wip on the RX init in the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents: 76
diff changeset
335 + Log::info("interrupt handler free'ed");
892b3bc7e43b Wip on the RX init in the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents: 76
diff changeset
336 }
892b3bc7e43b Wip on the RX init in the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents: 76
diff changeset
337
892b3bc7e43b Wip on the RX init in the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents: 76
diff changeset
338 Ethernet::interrupt_handler(Ethernet::Device dev)
892b3bc7e43b Wip on the RX init in the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents: 76
diff changeset
339 @@ -61,4 +71,11 @@
892b3bc7e43b Wip on the RX init in the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents: 76
diff changeset
340 PCI::set_master = true;
892b3bc7e43b Wip on the RX init in the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents: 76
diff changeset
341
892b3bc7e43b Wip on the RX init in the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents: 76
diff changeset
342 Ethernet::ifname = "rtx%d";
892b3bc7e43b Wip on the RX init in the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents: 76
diff changeset
343 +
892b3bc7e43b Wip on the RX init in the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents: 76
diff changeset
344 + e1000::rx_ring_size = 256; /* Number of incoming packets we can buffer */
892b3bc7e43b Wip on the RX init in the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents: 76
diff changeset
345 + /*
892b3bc7e43b Wip on the RX init in the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents: 76
diff changeset
346 + * The e1000 supports seven receive buffer sizes: 256, 512, 1024, 2048,
892b3bc7e43b Wip on the RX init in the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents: 76
diff changeset
347 + * 4096, 8192 and 16384 bytes:
892b3bc7e43b Wip on the RX init in the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents: 76
diff changeset
348 + */
892b3bc7e43b Wip on the RX init in the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents: 76
diff changeset
349 + e1000::rx_buffer_len = 2048;
892b3bc7e43b Wip on the RX init in the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents: 76
diff changeset
350 }