annotate e1000_initialize_reception.patch @ 80:0354cceee710

WIP on e1000, try to add the code to free the RX ring when shutting the interface down
author Louis Opter <louis@lse.epitech.net>
date Sun, 15 Apr 2012 02:53:38 +0200
parents f07f6c6d6cd4
children
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
80
0354cceee710 WIP on e1000, try to add the code to free the RX ring when shutting the interface down
Louis Opter <louis@lse.epitech.net>
parents: 79
diff changeset
2 # Parent d8fce7ee2b630bf8bd681fa4d66832b82c5e6de2
76
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
79
f07f6c6d6cd4 WIP on RX on e1000
Louis Opter <louis@lse.epitech.net>
parents: 78
diff changeset
20 @@ -1,5 +1,81 @@
f07f6c6d6cd4 WIP on RX on e1000
Louis Opter <louis@lse.epitech.net>
parents: 78
diff changeset
21 with e1000, Ethernet, Socket, PCI, LKM, Log
f07f6c6d6cd4 WIP on RX on e1000
Louis Opter <louis@lse.epitech.net>
parents: 78
diff changeset
22 {
77
892b3bc7e43b Wip on the RX init in the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents: 76
diff changeset
23 + template type e1000::RxDescriptor()
76
51bea596df7f Start a patch for the Rx init
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
24 + {
51bea596df7f Start a patch for the Rx init
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
25 + chunk LKM::includes()
51bea596df7f Start a patch for the Rx init
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
26 + {
77
892b3bc7e43b Wip on the RX init in the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents: 76
diff changeset
27 + typedef int ${e1000::RxDescriptor};
892b3bc7e43b Wip on the RX init in the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents: 76
diff changeset
28 +
892b3bc7e43b Wip on the RX init in the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents: 76
diff changeset
29 + #include <linux/types.h>
79
f07f6c6d6cd4 WIP on RX on e1000
Louis Opter <louis@lse.epitech.net>
parents: 78
diff changeset
30 +
f07f6c6d6cd4 WIP on RX on e1000
Louis Opter <louis@lse.epitech.net>
parents: 78
diff changeset
31 + static const ${e1000::RxDescriptor} force_rtx_e1000_rx_descriptor_decl;
76
51bea596df7f Start a patch for the Rx init
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
32 + }
51bea596df7f Start a patch for the Rx init
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
33 +
51bea596df7f Start a patch for the Rx init
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
34 + chunk ::decl()
51bea596df7f Start a patch for the Rx init
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
35 + {
77
892b3bc7e43b Wip on the RX init in the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents: 76
diff changeset
36 + 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
37 + {
892b3bc7e43b Wip on the RX init in the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents: 76
diff changeset
38 + /* 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
39 + 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
40 + unsigned short /* __le16 */ length;
892b3bc7e43b Wip on the RX init in the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents: 76
diff changeset
41 + unsigned short /* __le16 */ csum;
892b3bc7e43b Wip on the RX init in the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents: 76
diff changeset
42 + unsigned char status;
892b3bc7e43b Wip on the RX init in the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents: 76
diff changeset
43 + unsigned char errors;
892b3bc7e43b Wip on the RX init in the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents: 76
diff changeset
44 + unsigned short /* __le16 */ special;
892b3bc7e43b Wip on the RX init in the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents: 76
diff changeset
45 + } *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
46 + }
892b3bc7e43b Wip on the RX init in the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents: 76
diff changeset
47 +
892b3bc7e43b Wip on the RX init in the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents: 76
diff changeset
48 + chunk ::init()
892b3bc7e43b Wip on the RX init in the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents: 76
diff changeset
49 + {
892b3bc7e43b Wip on the RX init in the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents: 76
diff changeset
50 + }
892b3bc7e43b Wip on the RX init in the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents: 76
diff changeset
51 +
892b3bc7e43b Wip on the RX init in the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents: 76
diff changeset
52 + map
892b3bc7e43b Wip on the RX init in the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents: 76
diff changeset
53 + {
892b3bc7e43b Wip on the RX init in the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents: 76
diff changeset
54 + }
892b3bc7e43b Wip on the RX init in the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents: 76
diff changeset
55 + }
892b3bc7e43b Wip on the RX init in the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents: 76
diff changeset
56 +
79
f07f6c6d6cd4 WIP on RX on e1000
Louis Opter <louis@lse.epitech.net>
parents: 78
diff changeset
57 + /*
f07f6c6d6cd4 WIP on RX on e1000
Louis Opter <louis@lse.epitech.net>
parents: 78
diff changeset
58 + * Ring of e1000::RxDescriptors and their corresponding skbuffs.
f07f6c6d6cd4 WIP on RX on e1000
Louis Opter <louis@lse.epitech.net>
parents: 78
diff changeset
59 + *
f07f6c6d6cd4 WIP on RX on e1000
Louis Opter <louis@lse.epitech.net>
parents: 78
diff changeset
60 + * - size: total size of the ring in bytes.
f07f6c6d6cd4 WIP on RX on e1000
Louis Opter <louis@lse.epitech.net>
parents: 78
diff changeset
61 + * - base: address of the ring (we can't use the typedef here until we get
f07f6c6d6cd4 WIP on RX on e1000
Louis Opter <louis@lse.epitech.net>
parents: 78
diff changeset
62 + * CNorm unstrict);
f07f6c6d6cd4 WIP on RX on e1000
Louis Opter <louis@lse.epitech.net>
parents: 78
diff changeset
63 + * - dma_base: (physical) address of the ring where the device can access
f07f6c6d6cd4 WIP on RX on e1000
Louis Opter <louis@lse.epitech.net>
parents: 78
diff changeset
64 + * the different descriptors;
f07f6c6d6cd4 WIP on RX on e1000
Louis Opter <louis@lse.epitech.net>
parents: 78
diff changeset
65 + * - skbuffs: array of the skbuffs associated with each descriptor;
f07f6c6d6cd4 WIP on RX on e1000
Louis Opter <louis@lse.epitech.net>
parents: 78
diff changeset
66 + * - dma_skbuffs: (physical) address of each skbuff where the device can
f07f6c6d6cd4 WIP on RX on e1000
Louis Opter <louis@lse.epitech.net>
parents: 78
diff changeset
67 + * write the received packets;
f07f6c6d6cd4 WIP on RX on e1000
Louis Opter <louis@lse.epitech.net>
parents: 78
diff changeset
68 + */
77
892b3bc7e43b Wip on the RX init in the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents: 76
diff changeset
69 + template type e1000::RxRing()
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 + chunk LKM::includes()
892b3bc7e43b Wip on the RX init in the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents: 76
diff changeset
72 + {
892b3bc7e43b Wip on the RX init in the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents: 76
diff changeset
73 + typedef int ${e1000::RxRing};
79
f07f6c6d6cd4 WIP on RX on e1000
Louis Opter <louis@lse.epitech.net>
parents: 78
diff changeset
74 +
f07f6c6d6cd4 WIP on RX on e1000
Louis Opter <louis@lse.epitech.net>
parents: 78
diff changeset
75 + static const ${e1000::RxRing} force_rtx_e1000_rx_ring_decl;
77
892b3bc7e43b Wip on the RX init in the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents: 76
diff changeset
76 + }
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 + chunk ::decl()
892b3bc7e43b Wip on the RX init in the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents: 76
diff changeset
79 + {
892b3bc7e43b Wip on the RX init in the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents: 76
diff changeset
80 + 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
81 + {
79
f07f6c6d6cd4 WIP on RX on e1000
Louis Opter <louis@lse.epitech.net>
parents: 78
diff changeset
82 + unsigned int size;
f07f6c6d6cd4 WIP on RX on e1000
Louis Opter <louis@lse.epitech.net>
parents: 78
diff changeset
83 + struct rtx_e1000_rx_descriptor *base;
f07f6c6d6cd4 WIP on RX on e1000
Louis Opter <louis@lse.epitech.net>
parents: 78
diff changeset
84 + void* /* dma_addr_t */ dma_base;
f07f6c6d6cd4 WIP on RX on e1000
Louis Opter <louis@lse.epitech.net>
parents: 78
diff changeset
85 + struct sk_buff *skbuffs[256 /* ${config.rx_ring_size} */];
f07f6c6d6cd4 WIP on RX on e1000
Louis Opter <louis@lse.epitech.net>
parents: 78
diff changeset
86 + void* /* dma_addr_t */ dma_skbuffs[256 /* ${config.rx_ring_size} */];
77
892b3bc7e43b Wip on the RX init in the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents: 76
diff changeset
87 + };
76
51bea596df7f Start a patch for the Rx init
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
88 + }
51bea596df7f Start a patch for the Rx init
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
89 +
51bea596df7f Start a patch for the Rx init
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
90 + chunk ::init()
51bea596df7f Start a patch for the Rx init
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
91 + {
51bea596df7f Start a patch for the Rx init
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
92 + }
51bea596df7f Start a patch for the Rx init
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
93 +
51bea596df7f Start a patch for the Rx init
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
94 + map
51bea596df7f Start a patch for the Rx init
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
95 + {
51bea596df7f Start a patch for the Rx init
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
96 + }
51bea596df7f Start a patch for the Rx init
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
97 + }
51bea596df7f Start a patch for the Rx init
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
98 +
79
f07f6c6d6cd4 WIP on RX on e1000
Louis Opter <louis@lse.epitech.net>
parents: 78
diff changeset
99 template type e1000::Context()
76
51bea596df7f Start a patch for the Rx init
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
100 {
51bea596df7f Start a patch for the Rx init
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
101 chunk LKM::includes()
79
f07f6c6d6cd4 WIP on RX on e1000
Louis Opter <louis@lse.epitech.net>
parents: 78
diff changeset
102 @@ -21,9 +97,12 @@
f07f6c6d6cd4 WIP on RX on e1000
Louis Opter <louis@lse.epitech.net>
parents: 78
diff changeset
103 */
f07f6c6d6cd4 WIP on RX on e1000
Louis Opter <louis@lse.epitech.net>
parents: 78
diff changeset
104 typedef struct rtx_e1000_ctx
f07f6c6d6cd4 WIP on RX on e1000
Louis Opter <louis@lse.epitech.net>
parents: 78
diff changeset
105 {
f07f6c6d6cd4 WIP on RX on e1000
Louis Opter <louis@lse.epitech.net>
parents: 78
diff changeset
106 - int bars;
f07f6c6d6cd4 WIP on RX on e1000
Louis Opter <louis@lse.epitech.net>
parents: 78
diff changeset
107 - unsigned char /* __iomem */ *ioaddr;
f07f6c6d6cd4 WIP on RX on e1000
Louis Opter <louis@lse.epitech.net>
parents: 78
diff changeset
108 - int irq;
f07f6c6d6cd4 WIP on RX on e1000
Louis Opter <louis@lse.epitech.net>
parents: 78
diff changeset
109 + int bars;
f07f6c6d6cd4 WIP on RX on e1000
Louis Opter <louis@lse.epitech.net>
parents: 78
diff changeset
110 + unsigned char /* __iomem */ *ioaddr;
f07f6c6d6cd4 WIP on RX on e1000
Louis Opter <louis@lse.epitech.net>
parents: 78
diff changeset
111 + int irq;
f07f6c6d6cd4 WIP on RX on e1000
Louis Opter <louis@lse.epitech.net>
parents: 78
diff changeset
112 +
f07f6c6d6cd4 WIP on RX on e1000
Louis Opter <louis@lse.epitech.net>
parents: 78
diff changeset
113 + /* we can't use the Rathaxes type here (#8) */
f07f6c6d6cd4 WIP on RX on e1000
Louis Opter <louis@lse.epitech.net>
parents: 78
diff changeset
114 + struct rtx_e1000_rx_ring rx_ring;
f07f6c6d6cd4 WIP on RX on e1000
Louis Opter <louis@lse.epitech.net>
parents: 78
diff changeset
115 } *rtx_e1000_ctx_p;
f07f6c6d6cd4 WIP on RX on e1000
Louis Opter <louis@lse.epitech.net>
parents: 78
diff changeset
116 }
f07f6c6d6cd4 WIP on RX on e1000
Louis Opter <louis@lse.epitech.net>
parents: 78
diff changeset
117
f07f6c6d6cd4 WIP on RX on e1000
Louis Opter <louis@lse.epitech.net>
parents: 78
diff changeset
118 @@ -34,6 +113,7 @@
f07f6c6d6cd4 WIP on RX on e1000
Louis Opter <louis@lse.epitech.net>
parents: 78
diff changeset
119 map
f07f6c6d6cd4 WIP on RX on e1000
Louis Opter <louis@lse.epitech.net>
parents: 78
diff changeset
120 {
f07f6c6d6cd4 WIP on RX on e1000
Louis Opter <louis@lse.epitech.net>
parents: 78
diff changeset
121 }
f07f6c6d6cd4 WIP on RX on e1000
Louis Opter <louis@lse.epitech.net>
parents: 78
diff changeset
122 +
f07f6c6d6cd4 WIP on RX on e1000
Louis Opter <louis@lse.epitech.net>
parents: 78
diff changeset
123 }
f07f6c6d6cd4 WIP on RX on e1000
Louis Opter <louis@lse.epitech.net>
parents: 78
diff changeset
124
f07f6c6d6cd4 WIP on RX on e1000
Louis Opter <louis@lse.epitech.net>
parents: 78
diff changeset
125 template type e1000::Register()
f07f6c6d6cd4 WIP on RX on e1000
Louis Opter <louis@lse.epitech.net>
parents: 78
diff changeset
126 @@ -64,6 +144,9 @@
76
51bea596df7f Start a patch for the Rx init
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
127 E1000_FCT = 0x00030, /* Flow Control Type */
51bea596df7f Start a patch for the Rx init
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
128 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
129 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
130 + E1000_RAL = 0x05400, /* Receive Address Low */
51bea596df7f Start a patch for the Rx init
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
131 + E1000_RAH = 0x05404, /* Receive Address High */
51bea596df7f Start a patch for the Rx init
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
132 + E1000_MTA = 0x05200, /* Multicast Table Array */
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 }
51bea596df7f Start a patch for the Rx init
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
135
79
f07f6c6d6cd4 WIP on RX on e1000
Louis Opter <louis@lse.epitech.net>
parents: 78
diff changeset
136 @@ -132,7 +215,8 @@
76
51bea596df7f Start a patch for the Rx init
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
137 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
138 E1000_INTR_RXO = 0x00000040, /* rx overrun */
51bea596df7f Start a patch for the Rx init
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
139 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
140 - E1000_INTR_MDAC = 0x00000200 /* MDIO access complete */
51bea596df7f Start a patch for the Rx init
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
141 + E1000_INTR_MDAC = 0x00000200, /* MDIO access complete */
51bea596df7f Start a patch for the Rx init
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
142 + 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
143 };
51bea596df7f Start a patch for the Rx init
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
144 }
51bea596df7f Start a patch for the Rx init
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
145
79
f07f6c6d6cd4 WIP on RX on e1000
Louis Opter <louis@lse.epitech.net>
parents: 78
diff changeset
146 @@ -457,15 +541,27 @@
f07f6c6d6cd4 WIP on RX on e1000
Louis Opter <louis@lse.epitech.net>
parents: 78
diff changeset
147 {
78
501bf9cf65dc wip on e1000 add some fixes for the generation and check that it works on tip
Louis Opter <louis@lse.epitech.net>
parents: 77
diff changeset
148 chunk ::CALL()
77
892b3bc7e43b Wip on the RX init in the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents: 76
diff changeset
149 {
79
f07f6c6d6cd4 WIP on RX on e1000
Louis Opter <louis@lse.epitech.net>
parents: 78
diff changeset
150 + typedef unsigned long int dma_addr_t;
f07f6c6d6cd4 WIP on RX on e1000
Louis Opter <louis@lse.epitech.net>
parents: 78
diff changeset
151 +
77
892b3bc7e43b Wip on the RX init in the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents: 76
diff changeset
152 /*
892b3bc7e43b Wip on the RX init in the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents: 76
diff changeset
153 - * 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
154 - * Software Developper manual.
892b3bc7e43b Wip on the RX init in the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents: 76
diff changeset
155 + * 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
156 + * 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
157 + * directory).
892b3bc7e43b Wip on the RX init in the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents: 76
diff changeset
158 *
892b3bc7e43b Wip on the RX init in the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents: 76
diff changeset
159 * 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
160 * 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
161 */
892b3bc7e43b Wip on the RX init in the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents: 76
diff changeset
162
892b3bc7e43b Wip on the RX init in the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents: 76
diff changeset
163 /*
892b3bc7e43b Wip on the RX init in the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents: 76
diff changeset
164 + * 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
165 + * 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
166 + * the struct net_device)
892b3bc7e43b Wip on the RX init in the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents: 76
diff changeset
167 + */
78
501bf9cf65dc wip on e1000 add some fixes for the generation and check that it works on tip
Louis Opter <louis@lse.epitech.net>
parents: 77
diff changeset
168 + typedef int ${e1000::Context};
77
892b3bc7e43b Wip on the RX init in the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents: 76
diff changeset
169 + ${e1000::Context} hw_ctx;
892b3bc7e43b Wip on the RX init in the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents: 76
diff changeset
170 + 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
171 +
892b3bc7e43b Wip on the RX init in the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents: 76
diff changeset
172 + /*
892b3bc7e43b Wip on the RX init in the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents: 76
diff changeset
173 * "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
174 *
892b3bc7e43b Wip on the RX init in the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents: 76
diff changeset
175 * - CTRL.ASDE/CTRL.SLU: Let the PHY handle the speed detection &
80
0354cceee710 WIP on e1000, try to add the code to free the RX ring when shutting the interface down
Louis Opter <louis@lse.epitech.net>
parents: 79
diff changeset
176 @@ -478,22 +574,181 @@
77
892b3bc7e43b Wip on the RX init in the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents: 76
diff changeset
177 * - 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
178 * 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
179 */
892b3bc7e43b Wip on the RX init in the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents: 76
diff changeset
180 - 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
181 +
892b3bc7e43b Wip on the RX init in the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents: 76
diff changeset
182 + 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
183 E1000_CMD_ASDE |
892b3bc7e43b Wip on the RX init in the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents: 76
diff changeset
184 E1000_CMD_SLU);
892b3bc7e43b Wip on the RX init in the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents: 76
diff changeset
185 - 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
186 + 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
187 E1000_CMD_LRST |
892b3bc7e43b Wip on the RX init in the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents: 76
diff changeset
188 E1000_CMD_FRCSPD |
892b3bc7e43b Wip on the RX init in the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents: 76
diff changeset
189 E1000_CMD_PHY_RST |
892b3bc7e43b Wip on the RX init in the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents: 76
diff changeset
190 E1000_CMD_ILOS |
892b3bc7e43b Wip on the RX init in the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents: 76
diff changeset
191 E1000_CMD_VME);
892b3bc7e43b Wip on the RX init in the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents: 76
diff changeset
192 - 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
193 - 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
194 - 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
195 - rtx_e1000_register_write32(&${ctx}->hw_ctx, E1000_FCTTV, 0);
892b3bc7e43b Wip on the RX init in the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents: 76
diff changeset
196 + 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
197 + 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
198 + 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
199 + 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
200 + int i = 0; /* CNorm workaround, the init part of for isn't generated */
80
0354cceee710 WIP on e1000, try to add the code to free the RX ring when shutting the interface down
Louis Opter <louis@lse.epitech.net>
parents: 79
diff changeset
201 + 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
202 + 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
203 +
80
0354cceee710 WIP on e1000, try to add the code to free the RX ring when shutting the interface down
Louis Opter <louis@lse.epitech.net>
parents: 79
diff changeset
204 + {
0354cceee710 WIP on e1000, try to add the code to free the RX ring when shutting the interface down
Louis Opter <louis@lse.epitech.net>
parents: 79
diff changeset
205 + ${Log::info("setup_device: general configuration done")};
0354cceee710 WIP on e1000, try to add the code to free the RX ring when shutting the interface down
Louis Opter <louis@lse.epitech.net>
parents: 79
diff changeset
206 + }
79
f07f6c6d6cd4 WIP on RX on e1000
Louis Opter <louis@lse.epitech.net>
parents: 78
diff changeset
207 +
76
51bea596df7f Start a patch for the Rx init
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
208 + /*
79
f07f6c6d6cd4 WIP on RX on e1000
Louis Opter <louis@lse.epitech.net>
parents: 78
diff changeset
209 + * Receive initialization:
76
51bea596df7f Start a patch for the Rx init
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
210 + *
79
f07f6c6d6cd4 WIP on RX on e1000
Louis Opter <louis@lse.epitech.net>
parents: 78
diff changeset
211 + * 1. Program the receive address, in RAL/RAH;
f07f6c6d6cd4 WIP on RX on e1000
Louis Opter <louis@lse.epitech.net>
parents: 78
diff changeset
212 + * 2. Initialize the Multicast Table Array;
f07f6c6d6cd4 WIP on RX on e1000
Louis Opter <louis@lse.epitech.net>
parents: 78
diff changeset
213 + * 3. Program the interrupt mask register (done in
f07f6c6d6cd4 WIP on RX on e1000
Louis Opter <louis@lse.epitech.net>
parents: 78
diff changeset
214 + * e1000::activate_device_interruption);
f07f6c6d6cd4 WIP on RX on e1000
Louis Opter <louis@lse.epitech.net>
parents: 78
diff changeset
215 + * 4. Allocate the receive descriptor ring and map it to make it
f07f6c6d6cd4 WIP on RX on e1000
Louis Opter <louis@lse.epitech.net>
parents: 78
diff changeset
216 + * accessible by the device.
f07f6c6d6cd4 WIP on RX on e1000
Louis Opter <louis@lse.epitech.net>
parents: 78
diff changeset
217 + *
f07f6c6d6cd4 WIP on RX on e1000
Louis Opter <louis@lse.epitech.net>
parents: 78
diff changeset
218 + * The ugly casts in here are caused by the lack of CNorm unstrict.
76
51bea596df7f Start a patch for the Rx init
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
219 + */
77
892b3bc7e43b Wip on the RX init in the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents: 76
diff changeset
220 +
79
f07f6c6d6cd4 WIP on RX on e1000
Louis Opter <louis@lse.epitech.net>
parents: 78
diff changeset
221 + /* 1. Program the receive address */
f07f6c6d6cd4 WIP on RX on e1000
Louis Opter <louis@lse.epitech.net>
parents: 78
diff changeset
222 +
f07f6c6d6cd4 WIP on RX on e1000
Louis Opter <louis@lse.epitech.net>
parents: 78
diff changeset
223 + /* (We should use uint{32,16}_t but CNorm doesn't know them yet) */
77
892b3bc7e43b Wip on the RX init in the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents: 76
diff changeset
224 + 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
225 + *(unsigned int *)(${ctx}->net_dev->dev_addr));
51bea596df7f Start a patch for the Rx init
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
226 + /*
51bea596df7f Start a patch for the Rx init
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
227 + * 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
228 + * 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
229 + */
77
892b3bc7e43b Wip on the RX init in the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents: 76
diff changeset
230 + 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
231 + *(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
232 + 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
233 +
80
0354cceee710 WIP on e1000, try to add the code to free the RX ring when shutting the interface down
Louis Opter <louis@lse.epitech.net>
parents: 79
diff changeset
234 + {
0354cceee710 WIP on e1000, try to add the code to free the RX ring when shutting the interface down
Louis Opter <louis@lse.epitech.net>
parents: 79
diff changeset
235 + ${Log::info("setup_device: program receieve address done")};
0354cceee710 WIP on e1000, try to add the code to free the RX ring when shutting the interface down
Louis Opter <louis@lse.epitech.net>
parents: 79
diff changeset
236 + }
79
f07f6c6d6cd4 WIP on RX on e1000
Louis Opter <louis@lse.epitech.net>
parents: 78
diff changeset
237 +
f07f6c6d6cd4 WIP on RX on e1000
Louis Opter <louis@lse.epitech.net>
parents: 78
diff changeset
238 + /* 2. Initialize the MTA */
f07f6c6d6cd4 WIP on RX on e1000
Louis Opter <louis@lse.epitech.net>
parents: 78
diff changeset
239 +
76
51bea596df7f Start a patch for the Rx init
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
240 + 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
241 + 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
242 + 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
243 +
80
0354cceee710 WIP on e1000, try to add the code to free the RX ring when shutting the interface down
Louis Opter <louis@lse.epitech.net>
parents: 79
diff changeset
244 + {
0354cceee710 WIP on e1000, try to add the code to free the RX ring when shutting the interface down
Louis Opter <louis@lse.epitech.net>
parents: 79
diff changeset
245 + ${Log::info("setup_device: MTA init done")};
0354cceee710 WIP on e1000, try to add the code to free the RX ring when shutting the interface down
Louis Opter <louis@lse.epitech.net>
parents: 79
diff changeset
246 + }
79
f07f6c6d6cd4 WIP on RX on e1000
Louis Opter <louis@lse.epitech.net>
parents: 78
diff changeset
247 +
f07f6c6d6cd4 WIP on RX on e1000
Louis Opter <louis@lse.epitech.net>
parents: 78
diff changeset
248 + /* 4. Setup the receive descriptor ring */
f07f6c6d6cd4 WIP on RX on e1000
Louis Opter <louis@lse.epitech.net>
parents: 78
diff changeset
249 +
f07f6c6d6cd4 WIP on RX on e1000
Louis Opter <louis@lse.epitech.net>
parents: 78
diff changeset
250 + /* Allocate the descriptors */
77
892b3bc7e43b Wip on the RX init in the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents: 76
diff changeset
251 + 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
252 + hw_ctx->rx_ring.size = ALIGN(hw_ctx->rx_ring.size, 4096);
79
f07f6c6d6cd4 WIP on RX on e1000
Louis Opter <louis@lse.epitech.net>
parents: 78
diff changeset
253 + hw_ctx->rx_ring.base = dma_alloc_coherent(
f07f6c6d6cd4 WIP on RX on e1000
Louis Opter <louis@lse.epitech.net>
parents: 78
diff changeset
254 + &${ctx}->pci_dev->dev,
f07f6c6d6cd4 WIP on RX on e1000
Louis Opter <louis@lse.epitech.net>
parents: 78
diff changeset
255 + hw_ctx->rx_ring.size,
f07f6c6d6cd4 WIP on RX on e1000
Louis Opter <louis@lse.epitech.net>
parents: 78
diff changeset
256 + (dma_addr_t *)&hw_ctx->rx_ring.dma_base,
f07f6c6d6cd4 WIP on RX on e1000
Louis Opter <louis@lse.epitech.net>
parents: 78
diff changeset
257 + GFP_KERNEL);
f07f6c6d6cd4 WIP on RX on e1000
Louis Opter <louis@lse.epitech.net>
parents: 78
diff changeset
258 + if (!hw_ctx->rx_ring.base)
77
892b3bc7e43b Wip on the RX init in the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents: 76
diff changeset
259 + {
79
f07f6c6d6cd4 WIP on RX on e1000
Louis Opter <louis@lse.epitech.net>
parents: 78
diff changeset
260 + ${Log::info("cannot allocate the descriptors for the rx ring")};
77
892b3bc7e43b Wip on the RX init in the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents: 76
diff changeset
261 + 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
262 + }
892b3bc7e43b Wip on the RX init in the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents: 76
diff changeset
263 +
80
0354cceee710 WIP on e1000, try to add the code to free the RX ring when shutting the interface down
Louis Opter <louis@lse.epitech.net>
parents: 79
diff changeset
264 + {
0354cceee710 WIP on e1000, try to add the code to free the RX ring when shutting the interface down
Louis Opter <louis@lse.epitech.net>
parents: 79
diff changeset
265 + ${Log::info("setup_device: descriptors allocated")};
0354cceee710 WIP on e1000, try to add the code to free the RX ring when shutting the interface down
Louis Opter <louis@lse.epitech.net>
parents: 79
diff changeset
266 + }
79
f07f6c6d6cd4 WIP on RX on e1000
Louis Opter <louis@lse.epitech.net>
parents: 78
diff changeset
267 +
f07f6c6d6cd4 WIP on RX on e1000
Louis Opter <louis@lse.epitech.net>
parents: 78
diff changeset
268 + /*
f07f6c6d6cd4 WIP on RX on e1000
Louis Opter <louis@lse.epitech.net>
parents: 78
diff changeset
269 + * Allocate the skbuffs, map them for DMA, and write their address
f07f6c6d6cd4 WIP on RX on e1000
Louis Opter <louis@lse.epitech.net>
parents: 78
diff changeset
270 + * in the corresponding descriptor.
f07f6c6d6cd4 WIP on RX on e1000
Louis Opter <louis@lse.epitech.net>
parents: 78
diff changeset
271 + */
77
892b3bc7e43b Wip on the RX init in the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents: 76
diff changeset
272 + i = 0;
892b3bc7e43b Wip on the RX init in the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents: 76
diff changeset
273 + 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
274 + {
79
f07f6c6d6cd4 WIP on RX on e1000
Louis Opter <louis@lse.epitech.net>
parents: 78
diff changeset
275 + hw_ctx->rx_ring.skbuffs[i] = netdev_alloc_skb(
f07f6c6d6cd4 WIP on RX on e1000
Louis Opter <louis@lse.epitech.net>
parents: 78
diff changeset
276 + ${ctx}->net_dev,
77
892b3bc7e43b Wip on the RX init in the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents: 76
diff changeset
277 + ${config.rx_buffer_len});
892b3bc7e43b Wip on the RX init in the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents: 76
diff changeset
278 + 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
279 + {
79
f07f6c6d6cd4 WIP on RX on e1000
Louis Opter <louis@lse.epitech.net>
parents: 78
diff changeset
280 + ${Log::info("cannot allocate a skbuff for the rx ring")};
77
892b3bc7e43b Wip on the RX init in the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents: 76
diff changeset
281 + goto err_skbuffs_alloc;
892b3bc7e43b Wip on the RX init in the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents: 76
diff changeset
282 + }
79
f07f6c6d6cd4 WIP on RX on e1000
Louis Opter <louis@lse.epitech.net>
parents: 78
diff changeset
283 + hw_ctx->rx_ring.dma_skbuffs[i] = (void *)dma_map_single(
f07f6c6d6cd4 WIP on RX on e1000
Louis Opter <louis@lse.epitech.net>
parents: 78
diff changeset
284 + &${ctx}->pci_dev->dev,
77
892b3bc7e43b Wip on the RX init in the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents: 76
diff changeset
285 + 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
286 + ${config.rx_buffer_len},
892b3bc7e43b Wip on the RX init in the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents: 76
diff changeset
287 + DMA_FROM_DEVICE);
79
f07f6c6d6cd4 WIP on RX on e1000
Louis Opter <louis@lse.epitech.net>
parents: 78
diff changeset
288 + /*
f07f6c6d6cd4 WIP on RX on e1000
Louis Opter <louis@lse.epitech.net>
parents: 78
diff changeset
289 + * Either this fails because, when compiling with gcc because
f07f6c6d6cd4 WIP on RX on e1000
Louis Opter <louis@lse.epitech.net>
parents: 78
diff changeset
290 + * the last argument is not of the correct type (dma_addr_t).
f07f6c6d6cd4 WIP on RX on e1000
Louis Opter <louis@lse.epitech.net>
parents: 78
diff changeset
291 + * Or it fails because of the lack of CNorm Unstrict.
f07f6c6d6cd4 WIP on RX on e1000
Louis Opter <louis@lse.epitech.net>
parents: 78
diff changeset
292 + */
f07f6c6d6cd4 WIP on RX on e1000
Louis Opter <louis@lse.epitech.net>
parents: 78
diff changeset
293 + if (dma_mapping_error(&${ctx}->pci_dev->dev, (dma_addr_t)hw_ctx->rx_ring.dma_skbuffs[i]))
77
892b3bc7e43b Wip on the RX init in the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents: 76
diff changeset
294 + {
79
f07f6c6d6cd4 WIP on RX on e1000
Louis Opter <louis@lse.epitech.net>
parents: 78
diff changeset
295 + ${Log::info("cannot dma-map a skbuff for the rx ring")};
77
892b3bc7e43b Wip on the RX init in the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents: 76
diff changeset
296 + goto err_skbuffs_map;
892b3bc7e43b Wip on the RX init in the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents: 76
diff changeset
297 + }
79
f07f6c6d6cd4 WIP on RX on e1000
Louis Opter <louis@lse.epitech.net>
parents: 78
diff changeset
298 + hw_ctx->rx_ring.base[i].buff_addr = (unsigned long int)cpu_to_le64(
f07f6c6d6cd4 WIP on RX on e1000
Louis Opter <louis@lse.epitech.net>
parents: 78
diff changeset
299 + hw_ctx->rx_ring.dma_skbuffs[i]);
77
892b3bc7e43b Wip on the RX init in the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents: 76
diff changeset
300 + }
892b3bc7e43b Wip on the RX init in the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents: 76
diff changeset
301 +
80
0354cceee710 WIP on e1000, try to add the code to free the RX ring when shutting the interface down
Louis Opter <louis@lse.epitech.net>
parents: 79
diff changeset
302 + {
0354cceee710 WIP on e1000, try to add the code to free the RX ring when shutting the interface down
Louis Opter <louis@lse.epitech.net>
parents: 79
diff changeset
303 + ${Log::info("setup_device: skbuffs allocated")};
0354cceee710 WIP on e1000, try to add the code to free the RX ring when shutting the interface down
Louis Opter <louis@lse.epitech.net>
parents: 79
diff changeset
304 + }
79
f07f6c6d6cd4 WIP on RX on e1000
Louis Opter <louis@lse.epitech.net>
parents: 78
diff changeset
305 +
77
892b3bc7e43b Wip on the RX init in the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents: 76
diff changeset
306 + /*
79
f07f6c6d6cd4 WIP on RX on e1000
Louis Opter <louis@lse.epitech.net>
parents: 78
diff changeset
307 + * XXX: We can't return here since we are not in a function but in
f07f6c6d6cd4 WIP on RX on e1000
Louis Opter <louis@lse.epitech.net>
parents: 78
diff changeset
308 + * a chunk of code (injected in a function).
77
892b3bc7e43b Wip on the RX init in the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents: 76
diff changeset
309 + */
79
f07f6c6d6cd4 WIP on RX on e1000
Louis Opter <louis@lse.epitech.net>
parents: 78
diff changeset
310 + goto ok;
77
892b3bc7e43b Wip on the RX init in the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents: 76
diff changeset
311 +
79
f07f6c6d6cd4 WIP on RX on e1000
Louis Opter <louis@lse.epitech.net>
parents: 78
diff changeset
312 + /*
f07f6c6d6cd4 WIP on RX on e1000
Louis Opter <louis@lse.epitech.net>
parents: 78
diff changeset
313 + * Likewise, always the same problem with error handling, we don't
f07f6c6d6cd4 WIP on RX on e1000
Louis Opter <louis@lse.epitech.net>
parents: 78
diff changeset
314 + * know where we are at in the "parent context":
f07f6c6d6cd4 WIP on RX on e1000
Louis Opter <louis@lse.epitech.net>
parents: 78
diff changeset
315 + */
77
892b3bc7e43b Wip on the RX init in the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents: 76
diff changeset
316 + err_skbuffs_alloc:
892b3bc7e43b Wip on the RX init in the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents: 76
diff changeset
317 + while (i--)
892b3bc7e43b Wip on the RX init in the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents: 76
diff changeset
318 + {
79
f07f6c6d6cd4 WIP on RX on e1000
Louis Opter <louis@lse.epitech.net>
parents: 78
diff changeset
319 + dma_unmap_single(
f07f6c6d6cd4 WIP on RX on e1000
Louis Opter <louis@lse.epitech.net>
parents: 78
diff changeset
320 + &${ctx}->pci_dev->dev,
f07f6c6d6cd4 WIP on RX on e1000
Louis Opter <louis@lse.epitech.net>
parents: 78
diff changeset
321 + (dma_addr_t)hw_ctx->rx_ring.dma_skbuffs[i],
77
892b3bc7e43b Wip on the RX init in the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents: 76
diff changeset
322 + ${config.rx_buffer_len},
892b3bc7e43b Wip on the RX init in the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents: 76
diff changeset
323 + DMA_FROM_DEVICE);
892b3bc7e43b Wip on the RX init in the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents: 76
diff changeset
324 + err_skbuffs_map:
892b3bc7e43b Wip on the RX init in the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents: 76
diff changeset
325 + 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
326 + }
892b3bc7e43b Wip on the RX init in the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents: 76
diff changeset
327 +
892b3bc7e43b Wip on the RX init in the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents: 76
diff changeset
328 + dma_free_coherent(&${ctx}->pci_dev->dev, hw_ctx->rx_ring.size,
79
f07f6c6d6cd4 WIP on RX on e1000
Louis Opter <louis@lse.epitech.net>
parents: 78
diff changeset
329 + hw_ctx->rx_ring.base, (dma_addr_t)hw_ctx->rx_ring.dma_base);
77
892b3bc7e43b Wip on the RX init in the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents: 76
diff changeset
330 + err_rx_ring_alloc:
892b3bc7e43b Wip on the RX init in the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents: 76
diff changeset
331 + return -ENOMEM;
79
f07f6c6d6cd4 WIP on RX on e1000
Louis Opter <louis@lse.epitech.net>
parents: 78
diff changeset
332 +
f07f6c6d6cd4 WIP on RX on e1000
Louis Opter <louis@lse.epitech.net>
parents: 78
diff changeset
333 + ok:
77
892b3bc7e43b Wip on the RX init in the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents: 76
diff changeset
334 + }
892b3bc7e43b Wip on the RX init in the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents: 76
diff changeset
335 + }
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 + 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
338 + {
78
501bf9cf65dc wip on e1000 add some fixes for the generation and check that it works on tip
Louis Opter <louis@lse.epitech.net>
parents: 77
diff changeset
339 + chunk ::CALL()
77
892b3bc7e43b Wip on the RX init in the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents: 76
diff changeset
340 + {
80
0354cceee710 WIP on e1000, try to add the code to free the RX ring when shutting the interface down
Louis Opter <louis@lse.epitech.net>
parents: 79
diff changeset
341 + typedef unsigned long int dma_addr_t;
0354cceee710 WIP on e1000, try to add the code to free the RX ring when shutting the interface down
Louis Opter <louis@lse.epitech.net>
parents: 79
diff changeset
342 +
0354cceee710 WIP on e1000, try to add the code to free the RX ring when shutting the interface down
Louis Opter <louis@lse.epitech.net>
parents: 79
diff changeset
343 + typedef int ${e1000::Context};
0354cceee710 WIP on e1000, try to add the code to free the RX ring when shutting the interface down
Louis Opter <louis@lse.epitech.net>
parents: 79
diff changeset
344 + ${e1000::Context} hw_ctx;
0354cceee710 WIP on e1000, try to add the code to free the RX ring when shutting the interface down
Louis Opter <louis@lse.epitech.net>
parents: 79
diff changeset
345 + hw_ctx = &${ctx}->hw_ctx;
0354cceee710 WIP on e1000, try to add the code to free the RX ring when shutting the interface down
Louis Opter <louis@lse.epitech.net>
parents: 79
diff changeset
346 +
0354cceee710 WIP on e1000, try to add the code to free the RX ring when shutting the interface down
Louis Opter <louis@lse.epitech.net>
parents: 79
diff changeset
347 + /* Free the rx ring: */
0354cceee710 WIP on e1000, try to add the code to free the RX ring when shutting the interface down
Louis Opter <louis@lse.epitech.net>
parents: 79
diff changeset
348 int i = 0;
0354cceee710 WIP on e1000, try to add the code to free the RX ring when shutting the interface down
Louis Opter <louis@lse.epitech.net>
parents: 79
diff changeset
349 - for (i = 0; i != 64; ++i)
0354cceee710 WIP on e1000, try to add the code to free the RX ring when shutting the interface down
Louis Opter <louis@lse.epitech.net>
parents: 79
diff changeset
350 - rtx_e1000_register_write32(&${ctx}->hw_ctx, E1000_CRCERRS + i * 4, 0);
0354cceee710 WIP on e1000, try to add the code to free the RX ring when shutting the interface down
Louis Opter <louis@lse.epitech.net>
parents: 79
diff changeset
351 + for (i = 0; i != ${config.rx_ring_size}; ++i)
0354cceee710 WIP on e1000, try to add the code to free the RX ring when shutting the interface down
Louis Opter <louis@lse.epitech.net>
parents: 79
diff changeset
352 + {
0354cceee710 WIP on e1000, try to add the code to free the RX ring when shutting the interface down
Louis Opter <louis@lse.epitech.net>
parents: 79
diff changeset
353 + dma_unmap_single(
0354cceee710 WIP on e1000, try to add the code to free the RX ring when shutting the interface down
Louis Opter <louis@lse.epitech.net>
parents: 79
diff changeset
354 + &${ctx}->pci_dev->dev,
0354cceee710 WIP on e1000, try to add the code to free the RX ring when shutting the interface down
Louis Opter <louis@lse.epitech.net>
parents: 79
diff changeset
355 + (dma_addr_t)hw_ctx->rx_ring.dma_skbuffs[i],
0354cceee710 WIP on e1000, try to add the code to free the RX ring when shutting the interface down
Louis Opter <louis@lse.epitech.net>
parents: 79
diff changeset
356 + ${config.rx_buffer_len},
0354cceee710 WIP on e1000, try to add the code to free the RX ring when shutting the interface down
Louis Opter <louis@lse.epitech.net>
parents: 79
diff changeset
357 + DMA_FROM_DEVICE);
0354cceee710 WIP on e1000, try to add the code to free the RX ring when shutting the interface down
Louis Opter <louis@lse.epitech.net>
parents: 79
diff changeset
358 + dev_kfree_skb(hw_ctx->rx_ring.skbuffs[i]);
0354cceee710 WIP on e1000, try to add the code to free the RX ring when shutting the interface down
Louis Opter <louis@lse.epitech.net>
parents: 79
diff changeset
359 + }
0354cceee710 WIP on e1000, try to add the code to free the RX ring when shutting the interface down
Louis Opter <louis@lse.epitech.net>
parents: 79
diff changeset
360 + dma_free_coherent(&${ctx}->pci_dev->dev, hw_ctx->rx_ring.size,
0354cceee710 WIP on e1000, try to add the code to free the RX ring when shutting the interface down
Louis Opter <louis@lse.epitech.net>
parents: 79
diff changeset
361 + hw_ctx->rx_ring.base, (dma_addr_t)hw_ctx->rx_ring.dma_base);
77
892b3bc7e43b Wip on the RX init in the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents: 76
diff changeset
362 +
76
51bea596df7f Start a patch for the Rx init
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
363 }
51bea596df7f Start a patch for the Rx init
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
364 }
51bea596df7f Start a patch for the Rx init
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
365
51bea596df7f Start a patch for the Rx init
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
366 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
367 --- a/rathaxes/samples/e1000/e1000.rti
51bea596df7f Start a patch for the Rx init
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
368 +++ 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
369 @@ -1,6 +1,9 @@
76
51bea596df7f Start a patch for the Rx init
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
370 interface e1000 : Socket, Ethernet, PCI, LKM
51bea596df7f Start a patch for the Rx init
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
371 {
51bea596df7f Start a patch for the Rx init
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
372 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
373 + provided type e1000::RxDescriptor;
892b3bc7e43b Wip on the RX init in the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents: 76
diff changeset
374 + provided type e1000::RxRing;
76
51bea596df7f Start a patch for the Rx init
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
375 +
51bea596df7f Start a patch for the Rx init
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
376 /*
51bea596df7f Start a patch for the Rx init
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
377 * 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
378 */
78
501bf9cf65dc wip on e1000 add some fixes for the generation and check that it works on tip
Louis Opter <louis@lse.epitech.net>
parents: 77
diff changeset
379 @@ -55,6 +58,11 @@
501bf9cf65dc wip on e1000 add some fixes for the generation and check that it works on tip
Louis Opter <louis@lse.epitech.net>
parents: 77
diff changeset
380 provided chunk ::CALL();
77
892b3bc7e43b Wip on the RX init in the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents: 76
diff changeset
381 }
892b3bc7e43b Wip on the RX init in the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents: 76
diff changeset
382
892b3bc7e43b Wip on the RX init in the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents: 76
diff changeset
383 + 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
384 + {
78
501bf9cf65dc wip on e1000 add some fixes for the generation and check that it works on tip
Louis Opter <louis@lse.epitech.net>
parents: 77
diff changeset
385 + provided chunk ::CALL();
77
892b3bc7e43b Wip on the RX init in the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents: 76
diff changeset
386 + }
892b3bc7e43b Wip on the RX init in the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents: 76
diff changeset
387 +
892b3bc7e43b Wip on the RX init in the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents: 76
diff changeset
388 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
389 {
78
501bf9cf65dc wip on e1000 add some fixes for the generation and check that it works on tip
Louis Opter <louis@lse.epitech.net>
parents: 77
diff changeset
390 provided chunk ::CALL();
77
892b3bc7e43b Wip on the RX init in the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents: 76
diff changeset
391 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
392 --- 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
393 +++ b/rathaxes/samples/e1000/ethernet.blt
79
f07f6c6d6cd4 WIP on RX on e1000
Louis Opter <louis@lse.epitech.net>
parents: 78
diff changeset
394 @@ -64,7 +64,6 @@
f07f6c6d6cd4 WIP on RX on e1000
Louis Opter <louis@lse.epitech.net>
parents: 78
diff changeset
395 static int rtx_ethernet_open(struct net_device *dev)
f07f6c6d6cd4 WIP on RX on e1000
Louis Opter <louis@lse.epitech.net>
parents: 78
diff changeset
396 {
f07f6c6d6cd4 WIP on RX on e1000
Louis Opter <louis@lse.epitech.net>
parents: 78
diff changeset
397 struct rtx_ethernet_dev* rtx_ether_dev = netdev_priv(dev);
f07f6c6d6cd4 WIP on RX on e1000
Louis Opter <louis@lse.epitech.net>
parents: 78
diff changeset
398 - struct rtx_e1000_ctx* ctx = &rtx_ether_dev->hw_ctx;
f07f6c6d6cd4 WIP on RX on e1000
Louis Opter <louis@lse.epitech.net>
parents: 78
diff changeset
399
f07f6c6d6cd4 WIP on RX on e1000
Louis Opter <louis@lse.epitech.net>
parents: 78
diff changeset
400 ${cast local.rtx_ether_dev as Ethernet::Device};
f07f6c6d6cd4 WIP on RX on e1000
Louis Opter <louis@lse.epitech.net>
parents: 78
diff changeset
401 ${pointcut ::IMPLEMENTATION(local.rtx_ether_dev)};
f07f6c6d6cd4 WIP on RX on e1000
Louis Opter <louis@lse.epitech.net>
parents: 78
diff changeset
402 @@ -105,8 +104,7 @@
77
892b3bc7e43b Wip on the RX init in the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents: 76
diff changeset
403 {
892b3bc7e43b Wip on the RX init in the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents: 76
diff changeset
404 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
405 {
892b3bc7e43b Wip on the RX init in the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents: 76
diff changeset
406 - struct rtx_ethernet_dev* rtx_ether_dev = netdev_priv(dev);
79
f07f6c6d6cd4 WIP on RX on e1000
Louis Opter <louis@lse.epitech.net>
parents: 78
diff changeset
407 - struct rtx_e1000_ctx* ctx = &rtx_ether_dev->hw_ctx;
77
892b3bc7e43b Wip on the RX init in the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents: 76
diff changeset
408 + 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
409
78
501bf9cf65dc wip on e1000 add some fixes for the generation and check that it works on tip
Louis Opter <louis@lse.epitech.net>
parents: 77
diff changeset
410 ${cast local.rtx_ether_dev as Ethernet::Device};
79
f07f6c6d6cd4 WIP on RX on e1000
Louis Opter <louis@lse.epitech.net>
parents: 78
diff changeset
411 ${pointcut ::IMPLEMENTATION(local.rtx_ether_dev)};
77
892b3bc7e43b Wip on the RX init in the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents: 76
diff changeset
412 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
413 --- 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
414 +++ 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
415 @@ -24,7 +24,17 @@
892b3bc7e43b Wip on the RX init in the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents: 76
diff changeset
416 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
417 {
892b3bc7e43b Wip on the RX init in the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents: 76
diff changeset
418 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
419 +
892b3bc7e43b Wip on the RX init in the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents: 76
diff changeset
420 + /*
892b3bc7e43b Wip on the RX init in the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents: 76
diff changeset
421 + * 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
422 + * 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
423 + * 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
424 + */
892b3bc7e43b Wip on the RX init in the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents: 76
diff changeset
425 + 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
426 + 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
427 +
892b3bc7e43b Wip on the RX init in the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents: 76
diff changeset
428 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
429 + 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
430 }
892b3bc7e43b Wip on the RX init in the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents: 76
diff changeset
431
892b3bc7e43b Wip on the RX init in the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents: 76
diff changeset
432 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
433 @@ -61,4 +71,11 @@
892b3bc7e43b Wip on the RX init in the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents: 76
diff changeset
434 PCI::set_master = true;
892b3bc7e43b Wip on the RX init in the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents: 76
diff changeset
435
892b3bc7e43b Wip on the RX init in the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents: 76
diff changeset
436 Ethernet::ifname = "rtx%d";
892b3bc7e43b Wip on the RX init in the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents: 76
diff changeset
437 +
892b3bc7e43b Wip on the RX init in the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents: 76
diff changeset
438 + 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
439 + /*
892b3bc7e43b Wip on the RX init in the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents: 76
diff changeset
440 + * 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
441 + * 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
442 + */
892b3bc7e43b Wip on the RX init in the e1000 sample
Louis Opter <louis@lse.epitech.net>
parents: 76
diff changeset
443 + 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
444 }
79
f07f6c6d6cd4 WIP on RX on e1000
Louis Opter <louis@lse.epitech.net>
parents: 78
diff changeset
445 diff --git a/rathaxes/samples/e1000/socket.blt b/rathaxes/samples/e1000/socket.blt
f07f6c6d6cd4 WIP on RX on e1000
Louis Opter <louis@lse.epitech.net>
parents: 78
diff changeset
446 --- a/rathaxes/samples/e1000/socket.blt
f07f6c6d6cd4 WIP on RX on e1000
Louis Opter <louis@lse.epitech.net>
parents: 78
diff changeset
447 +++ b/rathaxes/samples/e1000/socket.blt
f07f6c6d6cd4 WIP on RX on e1000
Louis Opter <louis@lse.epitech.net>
parents: 78
diff changeset
448 @@ -4,7 +4,11 @@
f07f6c6d6cd4 WIP on RX on e1000
Louis Opter <louis@lse.epitech.net>
parents: 78
diff changeset
449 {
f07f6c6d6cd4 WIP on RX on e1000
Louis Opter <louis@lse.epitech.net>
parents: 78
diff changeset
450 chunk LKM::includes()
f07f6c6d6cd4 WIP on RX on e1000
Louis Opter <louis@lse.epitech.net>
parents: 78
diff changeset
451 {
f07f6c6d6cd4 WIP on RX on e1000
Louis Opter <louis@lse.epitech.net>
parents: 78
diff changeset
452 + typedef int ${Socket::SKBuff};
f07f6c6d6cd4 WIP on RX on e1000
Louis Opter <louis@lse.epitech.net>
parents: 78
diff changeset
453 +
f07f6c6d6cd4 WIP on RX on e1000
Louis Opter <louis@lse.epitech.net>
parents: 78
diff changeset
454 #include <linux/skbuff.h>
f07f6c6d6cd4 WIP on RX on e1000
Louis Opter <louis@lse.epitech.net>
parents: 78
diff changeset
455 +
f07f6c6d6cd4 WIP on RX on e1000
Louis Opter <louis@lse.epitech.net>
parents: 78
diff changeset
456 + static const ${Socket::SKBuff} force_rtx_lnux_skbuf_decl;
f07f6c6d6cd4 WIP on RX on e1000
Louis Opter <louis@lse.epitech.net>
parents: 78
diff changeset
457 }
f07f6c6d6cd4 WIP on RX on e1000
Louis Opter <louis@lse.epitech.net>
parents: 78
diff changeset
458
f07f6c6d6cd4 WIP on RX on e1000
Louis Opter <louis@lse.epitech.net>
parents: 78
diff changeset
459 chunk ::decl()