annotate e1000_initialize_reception.patch @ 76:51bea596df7f

Start a patch for the Rx init
author Louis Opter <louis@lse.epitech.net>
date Sun, 04 Mar 2012 15:27:34 +0100
parents
children 892b3bc7e43b
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
51bea596df7f Start a patch for the Rx init
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
20 @@ -36,6 +36,25 @@
51bea596df7f Start a patch for the Rx init
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
21 }
51bea596df7f Start a patch for the Rx init
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
22 }
51bea596df7f Start a patch for the Rx init
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
23
51bea596df7f Start a patch for the Rx init
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
24 + template type e1000::RingRx()
51bea596df7f Start a patch for the Rx init
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
25 + {
51bea596df7f Start a patch for the Rx init
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
26 + chunk LKM::includes()
51bea596df7f Start a patch for the Rx init
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
27 + {
51bea596df7f Start a patch for the Rx init
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
28 + }
51bea596df7f Start a patch for the Rx init
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
29 +
51bea596df7f Start a patch for the Rx init
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
30 + chunk ::decl()
51bea596df7f Start a patch for the Rx init
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
31 + {
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 ::init()
51bea596df7f Start a patch for the Rx init
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
35 + {
51bea596df7f Start a patch for the Rx init
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
36 + }
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 + map
51bea596df7f Start a patch for the Rx init
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
39 + {
51bea596df7f Start a patch for the Rx init
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
40 + }
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 +
51bea596df7f Start a patch for the Rx init
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
43 template type e1000::Register()
51bea596df7f Start a patch for the Rx init
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
44 {
51bea596df7f Start a patch for the Rx init
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
45 chunk LKM::includes()
51bea596df7f Start a patch for the Rx init
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
46 @@ -64,6 +83,9 @@
51bea596df7f Start a patch for the Rx init
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
47 E1000_FCT = 0x00030, /* Flow Control Type */
51bea596df7f Start a patch for the Rx init
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
48 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
49 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
50 + E1000_RAL = 0x05400, /* Receive Address Low */
51bea596df7f Start a patch for the Rx init
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
51 + E1000_RAH = 0x05404, /* Receive Address High */
51bea596df7f Start a patch for the Rx init
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
52 + E1000_MTA = 0x05200, /* Multicast Table Array */
51bea596df7f Start a patch for the Rx init
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
53 };
51bea596df7f Start a patch for the Rx init
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
54 }
51bea596df7f Start a patch for the Rx init
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
55
51bea596df7f Start a patch for the Rx init
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
56 @@ -132,7 +154,8 @@
51bea596df7f Start a patch for the Rx init
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
57 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
58 E1000_INTR_RXO = 0x00000040, /* rx overrun */
51bea596df7f Start a patch for the Rx init
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
59 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
60 - E1000_INTR_MDAC = 0x00000200 /* MDIO access complete */
51bea596df7f Start a patch for the Rx init
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
61 + E1000_INTR_MDAC = 0x00000200, /* MDIO access complete */
51bea596df7f Start a patch for the Rx init
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
62 + 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
63 };
51bea596df7f Start a patch for the Rx init
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
64 }
51bea596df7f Start a patch for the Rx init
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
65
51bea596df7f Start a patch for the Rx init
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
66 @@ -491,9 +514,32 @@
51bea596df7f Start a patch for the Rx init
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
67 rtx_e1000_register_write32(&${ctx}->hw_ctx, E1000_FCAL, 0);
51bea596df7f Start a patch for the Rx init
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
68 rtx_e1000_register_write32(&${ctx}->hw_ctx, E1000_FCT, 0);
51bea596df7f Start a patch for the Rx init
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
69 rtx_e1000_register_write32(&${ctx}->hw_ctx, E1000_FCTTV, 0);
51bea596df7f Start a patch for the Rx init
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
70 - int i = 0;
51bea596df7f Start a patch for the Rx init
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
71 + 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
72 for (i = 0; i != 64; ++i)
51bea596df7f Start a patch for the Rx init
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
73 rtx_e1000_register_write32(&${ctx}->hw_ctx, E1000_CRCERRS + i * 4, 0);
51bea596df7f Start a patch for the Rx init
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
74 +
51bea596df7f Start a patch for the Rx init
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
75 + /*
51bea596df7f Start a patch for the Rx init
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
76 + * Receive initialization
51bea596df7f Start a patch for the Rx init
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
77 + *
51bea596df7f Start a patch for the Rx init
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
78 + * - Program the receive address, in RAL/RAH;
51bea596df7f Start a patch for the Rx init
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
79 + * - Initialize the Multicast Table Array;
51bea596df7f Start a patch for the Rx init
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
80 + * - Program the interrupt mask register (done in
51bea596df7f Start a patch for the Rx init
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
81 + * e1000::activate_device_interruption);
51bea596df7f Start a patch for the Rx init
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
82 + *
51bea596df7f Start a patch for the Rx init
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
83 + * (We should use uint{32,16}_t but CNorm doesn't know them yet)
51bea596df7f Start a patch for the Rx init
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
84 + */
51bea596df7f Start a patch for the Rx init
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
85 + rtx_e1000_register_write32(&${ctx}->hw_ctx, E1000_RAL,
51bea596df7f Start a patch for the Rx init
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
86 + *(unsigned int *)(${ctx}->net_dev->dev_addr));
51bea596df7f Start a patch for the Rx init
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
87 + /*
51bea596df7f Start a patch for the Rx init
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
88 + * 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
89 + * 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
90 + */
51bea596df7f Start a patch for the Rx init
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
91 + rtx_e1000_register_write32(&${ctx}->hw_ctx, E1000_RAH,
51bea596df7f Start a patch for the Rx init
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
92 + *(unsigned short *)(&${ctx}->net_dev->dev_addr[4]));
51bea596df7f Start a patch for the Rx init
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
93 + rtx_e1000_register_set32(&${ctx}->hw_ctx, E1000_RAH, E1000_RAH_AV);
51bea596df7f Start a patch for the Rx init
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
94 + 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
95 + for (i = 0; i != 128; ++i)
51bea596df7f Start a patch for the Rx init
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
96 + rtx_e1000_register_write32(&${ctx}->hw_ctx, E1000_MTA + i * 4, 0);
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 }
51bea596df7f Start a patch for the Rx init
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
99
51bea596df7f Start a patch for the Rx init
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
100 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
101 --- a/rathaxes/samples/e1000/e1000.rti
51bea596df7f Start a patch for the Rx init
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
102 +++ b/rathaxes/samples/e1000/e1000.rti
51bea596df7f Start a patch for the Rx init
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
103 @@ -1,6 +1,8 @@
51bea596df7f Start a patch for the Rx init
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
104 interface e1000 : Socket, Ethernet, PCI, LKM
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 provided type e1000::Context;
51bea596df7f Start a patch for the Rx init
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
107 + provided type e1000::RingRx;
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 * 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
111 */