annotate rathaxes_change_the_abstract_type_notation_in_the_e1000_sample.patch @ 108:7efe3212db3a

Put the patches on e1000 above the patches on the compiler
author Louis Opter <louis@lse.epita.fr>
date Sun, 31 Mar 2013 20:00:09 -0700
parents f42751b8ca99
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
104
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
1 # HG changeset patch
108
7efe3212db3a Put the patches on e1000 above the patches on the compiler
Louis Opter <louis@lse.epita.fr>
parents: 107
diff changeset
2 # Parent e201e5967e6fdec65fff42256b9a1418bc24b9be
104
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
3 rathaxes: change the abstract type notation in the e1000 sample
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
4
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
5 Starting with ra24db32bf134 Rathaxes types are generated differently: you
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
6 don't define entire structures anymore, but only the fields. And the
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
7 compiler generate a typedef'ed structure on top of it.
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
8
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
9 This works fine, except for "abstract types" (the types defined by —and
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
10 used to interact with— the kernel). We need to define these types as
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
11 Rathaxes types to interact with them, in Rathaxes, but with
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
12 ra24db32bf134 it means that we loose (hide) the original type from the
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
13 kernel, making it very difficult to use "abstract types" with the
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
14 kernels APIs.
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
15
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
16 For example, here the hypothetical generated struct for the abstract
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
17 type "struct net_device" from Linux would be:
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
18
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
19 typedef struct {
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
20 struct net_device data;
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
21 } rtx_GeneratedType;
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
22
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
23 And here is how we have to use it:
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
24
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
25 rtx_GeneratedType *my_struct;
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
26 kernel_api_function(&my_struct->data);
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
27
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
28 This &my_struct->data is actually always a nop, but it's confusing and
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
29 hard to understand.
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
30
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
31 This changeset changes the notation to:
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
32
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
33 rtx_GeneratedType *my_struct;
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
34 kernel_api_function((struct net_device *)my_struct);
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
35
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
36 Which is, I believe, more intuitive and coherent with how you would
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
37 initialize the my_struct pointer here with a return value from the
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
38 kernel (i.e: with a cast into rtx_GeneratedType *).
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
39
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
40 diff --git a/rathaxes/samples/e1000/device.blt b/rathaxes/samples/e1000/device.blt
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
41 --- a/rathaxes/samples/e1000/device.blt
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
42 +++ b/rathaxes/samples/e1000/device.blt
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
43 @@ -18,7 +18,7 @@
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
44
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
45 map
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
46 {
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
47 - data: ${self}->data;
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
48 + k_device: ((struct device *)${self});
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
49 }
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
50 }
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
51 }
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
52 diff --git a/rathaxes/samples/e1000/device.rti b/rathaxes/samples/e1000/device.rti
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
53 --- a/rathaxes/samples/e1000/device.rti
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
54 +++ b/rathaxes/samples/e1000/device.rti
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
55 @@ -5,6 +5,6 @@
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
56 decl data_types();
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
57 chunk LKM::includes();
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
58 method init();
106
976a4b87803f Fix the resolution and the e1000 sample with the new scalar ref feature
David Pineau <dav.pineau@gmail.com>
parents: 105
diff changeset
59 - attribute Builtin::symbol.scalar data;
976a4b87803f Fix the resolution and the e1000 sample with the new scalar ref feature
David Pineau <dav.pineau@gmail.com>
parents: 105
diff changeset
60 + attribute Builtin::symbol.scalar k_device;
104
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
61 }
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
62 }
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
63 diff --git a/rathaxes/samples/e1000/e1000.blt b/rathaxes/samples/e1000/e1000.blt
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
64 --- a/rathaxes/samples/e1000/e1000.blt
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
65 +++ b/rathaxes/samples/e1000/e1000.blt
108
7efe3212db3a Put the patches on e1000 above the patches on the compiler
Louis Opter <louis@lse.epita.fr>
parents: 107
diff changeset
66 @@ -171,8 +171,8 @@
104
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
67
108
7efe3212db3a Put the patches on e1000 above the patches on the compiler
Louis Opter <louis@lse.epita.fr>
parents: 107
diff changeset
68 static int rtx_e1000_tx_ring_tso_cksum_offload(${e1000::TxRing.ref} self, ${Socket::SKBuff.ref} skb)
104
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
69 {
108
7efe3212db3a Put the patches on e1000 above the patches on the compiler
Louis Opter <louis@lse.epita.fr>
parents: 107
diff changeset
70 - ${Socket::AbstractSKBuff.ref} abs_skb = skb->skbuff;
104
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
71 - return skb_is_gso(&${local.abs_skb.data}) || ${local.abs_skb.data}.ip_summed == CHECKSUM_PARTIAL;
108
7efe3212db3a Put the patches on e1000 above the patches on the compiler
Louis Opter <louis@lse.epita.fr>
parents: 107
diff changeset
72 + ${Socket::AbstractSKBuff.ref} k_skb = skb->skbuff;
104
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
73 + return skb_is_gso(${local.k_skb.k_sk_buff}) || ${local.k_skb.k_sk_buff}->ip_summed == CHECKSUM_PARTIAL;
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
74 }
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
75
108
7efe3212db3a Put the patches on e1000 above the patches on the compiler
Louis Opter <louis@lse.epita.fr>
parents: 107
diff changeset
76 static void rtx_e1000_tx_ring_put(${e1000::TxRing.ref} self, ${Socket::SKBuff.ref} skb)
7efe3212db3a Put the patches on e1000 above the patches on the compiler
Louis Opter <louis@lse.epita.fr>
parents: 107
diff changeset
77 @@ -187,16 +187,16 @@
104
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
78 * code shouldn't be aware of it and use something more
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
79 * abstract.
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
80 */
108
7efe3212db3a Put the patches on e1000 above the patches on the compiler
Louis Opter <louis@lse.epita.fr>
parents: 107
diff changeset
81 - ${Socket::AbstractSKBuff.ref} abs_skb = skb->skbuff;
7efe3212db3a Put the patches on e1000 above the patches on the compiler
Louis Opter <louis@lse.epita.fr>
parents: 107
diff changeset
82 + ${Socket::AbstractSKBuff.ref} k_skb = skb->skbuff;
7efe3212db3a Put the patches on e1000 above the patches on the compiler
Louis Opter <louis@lse.epita.fr>
parents: 107
diff changeset
83 ${e1000::TxDescriptor.ref} tx_desc = &self->base[self->tail];
104
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
84 tx_desc->lower.data = cpu_to_le32(
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
85 E1000_TXD_CMD_EOP |
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
86 E1000_TXD_CMD_IFCS |
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
87 E1000_TXD_CMD_RS |
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
88 - skb_headlen(&${local.abs_skb.data}));
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
89 + skb_headlen(${local.k_skb.k_sk_buff}));
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
90 tx_desc->upper.data = 0;
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
91 tx_desc->buff_addr = cpu_to_le64(skb->dma_handle);
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
92 - memcpy(&self->skbuffs[self->tail], skb, sizeof(*skb));
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
93 + memcpy(&self->skbuffs[self->tail], ${local.k_skb.k_sk_buff}, sizeof(*${local.k_skb.k_sk_buff}));
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
94 self->tail = (self->tail + 1) % ${config.tx_ring_size};
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
95 }
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
96
108
7efe3212db3a Put the patches on e1000 above the patches on the compiler
Louis Opter <louis@lse.epita.fr>
parents: 107
diff changeset
97 @@ -732,7 +732,7 @@
104
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
98 hw_ctx->rx_ring.size = ${config.rx_ring_size} * sizeof(*hw_ctx->rx_ring.base);
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
99 hw_ctx->rx_ring.size = ALIGN(hw_ctx->rx_ring.size, 4096);
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
100 hw_ctx->rx_ring.base = dma_alloc_coherent(
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
101 - &${rtx_ether_ctx.device},
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
102 + ${rtx_ether_ctx.device},
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
103 hw_ctx->rx_ring.size,
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
104 &hw_ctx->rx_ring.dma_base,
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
105 GFP_KERNEL);
108
7efe3212db3a Put the patches on e1000 above the patches on the compiler
Louis Opter <louis@lse.epita.fr>
parents: 107
diff changeset
106 @@ -750,11 +750,10 @@
104
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
107 * Allocate the skbuffs, map them for DMA, and write their address
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
108 * in the corresponding descriptor.
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
109 */
108
7efe3212db3a Put the patches on e1000 above the patches on the compiler
Louis Opter <louis@lse.epita.fr>
parents: 107
diff changeset
110 - ${Ethernet::AbstractDevice.ref} rtx_ether_dev = ${rtx_ether_ctx.net_device};
104
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
111 for (i = 0; i != ${config.rx_ring_size}; ++i)
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
112 {
108
7efe3212db3a Put the patches on e1000 above the patches on the compiler
Louis Opter <louis@lse.epita.fr>
parents: 107
diff changeset
113 - hw_ctx->rx_ring.skbuffs[i].skbuff = (${Socket::AbstractSKBuff.ref})netdev_alloc_skb(
104
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
114 - &${rtx_ether_dev.netdev},
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
115 + hw_ctx->rx_ring.skbuffs[i].skbuff = (${Socket::AbstractSKBuff}*)netdev_alloc_skb(
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
116 + ${rtx_ether_ctx.net_device.k_net_dev}, /* XXX: .k_net_dev isn't expanded here */
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
117 ${config.rx_buffer_len});
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
118 if (!hw_ctx->rx_ring.skbuffs[i].skbuff)
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
119 {
108
7efe3212db3a Put the patches on e1000 above the patches on the compiler
Louis Opter <louis@lse.epita.fr>
parents: 107
diff changeset
120 @@ -762,11 +761,11 @@
104
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
121 goto err_skbuffs_alloc;
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
122 }
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
123 hw_ctx->rx_ring.skbuffs[i].dma_handle = dma_map_single(
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
124 - &${rtx_ether_ctx.device},
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
125 - &hw_ctx->rx_ring.skbuffs[i].skbuff->data,
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
126 + ${rtx_ether_ctx.device},
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
127 + (struct sk_buff *)hw_ctx->rx_ring.skbuffs[i].skbuff, /* XXX leaking cast */
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
128 ${config.rx_buffer_len},
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
129 DMA_FROM_DEVICE);
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
130 - int dma_error = dma_mapping_error(&${rtx_ether_ctx.device},
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
131 + int dma_error = dma_mapping_error(${rtx_ether_ctx.device},
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
132 hw_ctx->rx_ring.skbuffs[i].dma_handle);
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
133 if (dma_error)
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
134 {
108
7efe3212db3a Put the patches on e1000 above the patches on the compiler
Louis Opter <louis@lse.epita.fr>
parents: 107
diff changeset
135 @@ -818,7 +817,7 @@
104
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
136 hw_ctx->tx_ring.size = ${config.tx_ring_size} * sizeof(*hw_ctx->tx_ring.base);
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
137 hw_ctx->tx_ring.size = ALIGN(hw_ctx->tx_ring.size, 4096);
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
138 hw_ctx->tx_ring.base = dma_alloc_coherent(
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
139 - &${rtx_ether_ctx.device},
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
140 + ${rtx_ether_ctx.device},
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
141 hw_ctx->tx_ring.size,
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
142 &hw_ctx->tx_ring.dma_base,
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
143 GFP_KERNEL);
108
7efe3212db3a Put the patches on e1000 above the patches on the compiler
Louis Opter <louis@lse.epita.fr>
parents: 107
diff changeset
144 @@ -861,15 +860,16 @@
104
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
145 while (i--)
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
146 {
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
147 dma_unmap_single(
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
148 - &${rtx_ether_ctx.device},
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
149 + ${rtx_ether_ctx.device},
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
150 hw_ctx->rx_ring.skbuffs[i].dma_handle,
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
151 ${config.rx_buffer_len},
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
152 DMA_FROM_DEVICE);
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
153 err_skbuffs_map:
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
154 - dev_kfree_skb(&hw_ctx->rx_ring.skbuffs[i].skbuff->data);
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
155 + /* XXX leaking cast: */
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
156 + dev_kfree_skb((struct sk_buff *)hw_ctx->rx_ring.skbuffs[i].skbuff);
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
157 }
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
158
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
159 - dma_free_coherent(&${rtx_ether_ctx.device}, hw_ctx->rx_ring.size,
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
160 + dma_free_coherent(${rtx_ether_ctx.device}, hw_ctx->rx_ring.size,
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
161 hw_ctx->rx_ring.base, hw_ctx->rx_ring.dma_base);
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
162 err_rx_ring_alloc:
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
163 return -ENOMEM;
108
7efe3212db3a Put the patches on e1000 above the patches on the compiler
Louis Opter <louis@lse.epita.fr>
parents: 107
diff changeset
164 @@ -887,8 +887,12 @@
104
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
165 {
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
166 chunk ::CALL()
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
167 {
108
7efe3212db3a Put the patches on e1000 above the patches on the compiler
Louis Opter <louis@lse.epita.fr>
parents: 107
diff changeset
168 - ${e1000::Context.ref} hw_ctx;
104
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
169 - hw_ctx = &${rtx_ether_ctx}->hw_ctx;
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
170 + /*
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
171 + * XXX: Not generated if named "hw_ctx" (which is funny because
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
172 + * it's used and works in the template right above this one):
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
173 + */
108
7efe3212db3a Put the patches on e1000 above the patches on the compiler
Louis Opter <louis@lse.epita.fr>
parents: 107
diff changeset
174 + ${e1000::Context.ref} hw_ctx_;
104
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
175 + hw_ctx_ = &${rtx_ether_ctx}->hw_ctx;
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
176
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
177 /*
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
178 * Free the rx ring:
108
7efe3212db3a Put the patches on e1000 above the patches on the compiler
Louis Opter <louis@lse.epita.fr>
parents: 107
diff changeset
179 @@ -898,22 +902,26 @@
104
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
180 for (int i = 0; i != ${config.rx_ring_size}; ++i)
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
181 {
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
182 dma_unmap_single(
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
183 - &${rtx_ether_ctx.device},
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
184 - (dma_addr_t)hw_ctx->rx_ring.skbuffs[i].dma_handle,
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
185 + ${rtx_ether_ctx.device},
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
186 + (dma_addr_t)hw_ctx_->rx_ring.skbuffs[i].dma_handle,
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
187 ${config.rx_buffer_len},
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
188 DMA_FROM_DEVICE);
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
189 - dev_kfree_skb(&hw_ctx->rx_ring.skbuffs[i].skbuff->data);
108
7efe3212db3a Put the patches on e1000 above the patches on the compiler
Louis Opter <louis@lse.epita.fr>
parents: 107
diff changeset
190 + /* XXX Leaking cast
7efe3212db3a Put the patches on e1000 above the patches on the compiler
Louis Opter <louis@lse.epita.fr>
parents: 107
diff changeset
191 + * (We should go through the rtx types (Socket::SKBuff,
7efe3212db3a Put the patches on e1000 above the patches on the compiler
Louis Opter <louis@lse.epita.fr>
parents: 107
diff changeset
192 + * AbstractSKBuff)
7efe3212db3a Put the patches on e1000 above the patches on the compiler
Louis Opter <louis@lse.epita.fr>
parents: 107
diff changeset
193 + */
7efe3212db3a Put the patches on e1000 above the patches on the compiler
Louis Opter <louis@lse.epita.fr>
parents: 107
diff changeset
194 + dev_kfree_skb((struct sk_buff *)hw_ctx_->rx_ring.skbuffs[i].skbuff);
104
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
195 }
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
196 - dma_free_coherent(&${rtx_ether_ctx.device}, hw_ctx->rx_ring.size,
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
197 - hw_ctx->rx_ring.base, hw_ctx->rx_ring.dma_base);
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
198 + dma_free_coherent(${rtx_ether_ctx.device}, hw_ctx_->rx_ring.size,
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
199 + hw_ctx_->rx_ring.base, hw_ctx_->rx_ring.dma_base);
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
200 ${Log::info("free_rx_tx: rx ring free'ed")};
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
201
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
202 /*
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
203 * Free the tx ring:
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
204 * - Free the descriptors array.
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
205 */
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
206 - dma_free_coherent(&${rtx_ether_ctx.device}, hw_ctx->tx_ring.size,
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
207 - hw_ctx->tx_ring.base, hw_ctx->tx_ring.dma_base);
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
208 + dma_free_coherent(${rtx_ether_ctx.device}, hw_ctx_->tx_ring.size,
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
209 + hw_ctx_->tx_ring.base, hw_ctx_->tx_ring.dma_base);
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
210 ${Log::info("free_rx_tx: tx ring free'ed")};
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
211 }
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
212 }
108
7efe3212db3a Put the patches on e1000 above the patches on the compiler
Louis Opter <louis@lse.epita.fr>
parents: 107
diff changeset
213 @@ -971,13 +979,13 @@
104
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
214 ${local.skb.init(kernel_skb)};
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
215 hw_ctx = &${rtx_ether_ctx}->hw_ctx;
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
216 tx_ring = &hw_ctx->tx_ring;
108
7efe3212db3a Put the patches on e1000 above the patches on the compiler
Louis Opter <louis@lse.epita.fr>
parents: 107
diff changeset
217 - devp = (${Device::AbstractDevice.ref})&${rtx_ether_ctx.device};
7efe3212db3a Put the patches on e1000 above the patches on the compiler
Louis Opter <louis@lse.epita.fr>
parents: 107
diff changeset
218 + devp = (${Device::AbstractDevice.ref})${rtx_ether_ctx.device};
104
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
219
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
220 ${Log::info("xmit: skbuff details:")};
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
221 /*
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
222 - * skb is not expand on the bound C variable (should be rtx_skbuff),
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
223 - * which is funny because it works for the sequence template call
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
224 - * right after.
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
225 + * skb does not expand on the bound C variable (should be
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
226 + * rtx_skbuff), which is funny because it works for the
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
227 + * sequence template call right after.
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
228 */
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
229 /*
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
230 * XXX: doesn't work (I tried to pass self explicitely too):
108
7efe3212db3a Put the patches on e1000 above the patches on the compiler
Louis Opter <louis@lse.epita.fr>
parents: 107
diff changeset
231 @@ -1010,8 +1018,8 @@
104
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
232
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
233 /* 2. Map the data */
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
234
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
235 - /* XXX: ${local.skb.map_to(local.devp)}; */
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
236 - if (rtx_socket_skbuff_map(&skb, &${devp.data}, DMA_TO_DEVICE))
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
237 + /* XXX: ${local.skb.map_to(devp.k_device)}; */
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
238 + if (rtx_socket_skbuff_map(&skb, ${devp.k_device}, DMA_TO_DEVICE))
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
239 {
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
240 ${Log::info("xmit: can't DMA map a SKbuff")};
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
241 goto err_skb_map_to;
108
7efe3212db3a Put the patches on e1000 above the patches on the compiler
Louis Opter <louis@lse.epita.fr>
parents: 107
diff changeset
242 @@ -1030,7 +1038,7 @@
104
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
243 err_offload:
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
244 err_skb_map_to:
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
245 /* XXX: ${local.skb.unmap_to_and_free(local.dev)}; */
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
246 - rtx_socket_skbuff_unmap_and_free(&skb, &${devp.data}, DMA_TO_DEVICE);
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
247 + rtx_socket_skbuff_unmap_and_free(&skb, ${devp.k_device}, DMA_TO_DEVICE);
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
248 return NETDEV_TX_OK;
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
249 }
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
250 }
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
251 diff --git a/rathaxes/samples/e1000/ethernet.blt b/rathaxes/samples/e1000/ethernet.blt
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
252 --- a/rathaxes/samples/e1000/ethernet.blt
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
253 +++ b/rathaxes/samples/e1000/ethernet.blt
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
254 @@ -51,7 +51,7 @@
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
255 {
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
256 decl data_types()
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
257 {
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
258 - struct net_device ndev;
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
259 + struct net_device data;
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
260 }
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
261
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
262 chunk LKM::includes()
107
f42751b8ca99 Fix the interrupt handler refactoring patch and update the abstract type notation patch accordingly
Louis Opter <louis@lse.epita.fr>
parents: 106
diff changeset
263 @@ -59,11 +59,16 @@
104
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
264 #include <linux/netdevice.h>
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
265 }
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
266
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
267 + method init(Builtin::symbol dev)
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
268 + {
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
269 + ${self} = (${Ethernet::AbstractDevice} *)${dev};
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
270 + }
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
271 +
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
272 map
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
273 {
107
f42751b8ca99 Fix the interrupt handler refactoring patch and update the abstract type notation patch accordingly
Louis Opter <louis@lse.epita.fr>
parents: 106
diff changeset
274 - netdev: ${self}->ndev;
104
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
275 + k_net_dev: ((struct net_device *)${self});
107
f42751b8ca99 Fix the interrupt handler refactoring patch and update the abstract type notation patch accordingly
Louis Opter <louis@lse.epita.fr>
parents: 106
diff changeset
276 /* This could be another init method for Ethernet::Device: */
f42751b8ca99 Fix the interrupt handler refactoring patch and update the abstract type notation patch accordingly
Louis Opter <louis@lse.epita.fr>
parents: 106
diff changeset
277 - rtx_ether_ctx: netdev_priv(&${self}->ndev);
104
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
278 + rtx_ether_ctx: netdev_priv((struct net_device *)${self});
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
279 }
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
280 }
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
281
107
f42751b8ca99 Fix the interrupt handler refactoring patch and update the abstract type notation patch accordingly
Louis Opter <louis@lse.epita.fr>
parents: 106
diff changeset
282 @@ -90,25 +95,33 @@
104
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
283 #include <linux/etherdevice.h>
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
284 }
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
285
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
286 - method init(Ethernet::AbstractDevice net_dev, PCI::AbstractDevice pci_dev)
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
287 + /* XXX: if the first arg is not called rtx_net_dev, it breaks. */
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
288 + method init(Ethernet::AbstractDevice rtx_net_dev, PCI::AbstractDevice pci_dev)
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
289 {
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
290 - ${self} = netdev_priv(&${net_dev.netdev});
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
291 + ${self} = ${rtx_net_dev.rtx_ether_ctx};
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
292 /*
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
293 * We can use -> because we know that ${self} will be always a
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
294 * pointer, but the ambiguity sucks.
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
295 */
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
296 ${self}->pci_dev = ${pci_dev};
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
297 - ${self}->net_dev = ${net_dev};
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
298 + ${self}->net_dev = ${rtx_net_dev};
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
299 }
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
300
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
301 map
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
302 {
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
303 - device: ${self}->pci_dev->data.dev;
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
304 + /*
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
305 + * XXX: I'd like to be able to do things like:
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
306 + * device: ${self.pci_dev.k_pci_dev}->dev;
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
307 + *
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
308 + * Also, using ${PCI::AbstractDevice} instead of directly struct
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
309 + * pci_dev doesn't work.
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
310 + */
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
311 + device: (&((struct pci_dev *)(${self})->pci_dev)->dev);
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
312 pci_device: ${self}->pci_dev;
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
313 net_device: ${self}->net_dev;
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
314 - perm_addr: ${self}->net_dev->ndev.perm_addr;
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
315 - dev_addr: ${self}->net_dev->ndev.dev_addr;
105
fb20f01ea997 Wip, note: the interrupt handler refactoring patch is broken, I have to find the fix from the abstract type notation patch
Louis Opter <louis@lse.epita.fr>
parents: 104
diff changeset
316 - irq: ${self}->pci_dev->data.irq;
104
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
317 + perm_addr: ((struct net_device *)(${self})->net_dev)->perm_addr;
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
318 + dev_addr: ((struct net_device *)(${self})->net_dev)->dev_addr;
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
319 + irq: ((struct pci_dev *)(${self})->pci_dev)->irq;
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
320 }
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
321 }
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
322
108
7efe3212db3a Put the patches on e1000 above the patches on the compiler
Louis Opter <louis@lse.epita.fr>
parents: 107
diff changeset
323 @@ -128,7 +141,15 @@
104
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
324 {
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
325 static int rtx_ethernet_open(struct net_device *dev)
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
326 {
108
7efe3212db3a Put the patches on e1000 above the patches on the compiler
Louis Opter <louis@lse.epita.fr>
parents: 107
diff changeset
327 - ${Ethernet::Device.ref} rtx_ether_ctx = netdev_priv(dev);
104
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
328 + /*
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
329 + * XXX The casts are here because the compiler doesn't resolve
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
330 + * "enclosed" type (e.g: local.var.enclosed) correctly.
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
331 + */
108
7efe3212db3a Put the patches on e1000 above the patches on the compiler
Louis Opter <louis@lse.epita.fr>
parents: 107
diff changeset
332 + ${Ethernet::AbstractDevice.ref} rtx_net_dev;
104
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
333 + { /* XXX: I end up with a placeholder if I don't open a scope */
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
334 + ${local.rtx_net_dev.init(local.dev)};
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
335 + }
108
7efe3212db3a Put the patches on e1000 above the patches on the compiler
Louis Opter <louis@lse.epita.fr>
parents: 107
diff changeset
336 + ${Ethernet::Device.ref} rtx_ether_ctx = ${local.rtx_net_dev.rtx_ether_ctx};
104
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
337
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
338 int error;
108
7efe3212db3a Put the patches on e1000 above the patches on the compiler
Louis Opter <louis@lse.epita.fr>
parents: 107
diff changeset
339 {
7efe3212db3a Put the patches on e1000 above the patches on the compiler
Louis Opter <louis@lse.epita.fr>
parents: 107
diff changeset
340 @@ -181,7 +202,12 @@
104
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
341 {
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
342 static int rtx_ethernet_close(struct net_device *dev)
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
343 {
108
7efe3212db3a Put the patches on e1000 above the patches on the compiler
Louis Opter <louis@lse.epita.fr>
parents: 107
diff changeset
344 - ${Ethernet::Device.ref} rtx_ether_ctx = netdev_priv(dev);
7efe3212db3a Put the patches on e1000 above the patches on the compiler
Louis Opter <louis@lse.epita.fr>
parents: 107
diff changeset
345 + ${Ethernet::AbstractDevice.ref} rtx_net_dev;
104
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
346 + { /* XXX: I end up with a placeholder if I don't open a scope */
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
347 + ${local.rtx_net_dev.init(local.dev)};
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
348 + }
108
7efe3212db3a Put the patches on e1000 above the patches on the compiler
Louis Opter <louis@lse.epita.fr>
parents: 107
diff changeset
349 +
7efe3212db3a Put the patches on e1000 above the patches on the compiler
Louis Opter <louis@lse.epita.fr>
parents: 107
diff changeset
350 + ${Ethernet::Device.ref} rtx_ether_ctx = ${local.rtx_net_dev.rtx_ether_ctx};
104
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
351
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
352 /* TODO: change this pointcut into a pointcut/adapter/callback: */
108
7efe3212db3a Put the patches on e1000 above the patches on the compiler
Louis Opter <louis@lse.epita.fr>
parents: 107
diff changeset
353 {
7efe3212db3a Put the patches on e1000 above the patches on the compiler
Louis Opter <louis@lse.epita.fr>
parents: 107
diff changeset
354 @@ -246,22 +272,24 @@
104
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
355 */
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
356 chunk PCI::pci_probe_hook(PCI::Device rtx_pci_dev)
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
357 {
108
7efe3212db3a Put the patches on e1000 above the patches on the compiler
Louis Opter <louis@lse.epita.fr>
parents: 107
diff changeset
358 + ${Ethernet::AbstractDevice.ref} rtx_net_dev;
7efe3212db3a Put the patches on e1000 above the patches on the compiler
Louis Opter <louis@lse.epita.fr>
parents: 107
diff changeset
359 ${Ethernet::Device.ref} rtx_ether_ctx;
7efe3212db3a Put the patches on e1000 above the patches on the compiler
Louis Opter <louis@lse.epita.fr>
parents: 107
diff changeset
360 - ${Ethernet::AbstractDevice.ref} net_dev;
104
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
361
108
7efe3212db3a Put the patches on e1000 above the patches on the compiler
Louis Opter <louis@lse.epita.fr>
parents: 107
diff changeset
362 - net_dev = (${Ethernet::AbstractDevice.ref})alloc_etherdev(sizeof(*rtx_ether_ctx));
104
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
363 - if (!net_dev)
108
7efe3212db3a Put the patches on e1000 above the patches on the compiler
Louis Opter <louis@lse.epita.fr>
parents: 107
diff changeset
364 + rtx_net_dev = (${Ethernet::AbstractDevice.ref})alloc_etherdev(sizeof(*rtx_ether_ctx));
104
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
365 + if (!rtx_net_dev)
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
366 {
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
367 ${Log::info("cannot allocate the ethernet device context")};
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
368 error = -ENOMEM;
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
369 goto fail;
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
370 }
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
371 - SET_NETDEV_DEV(&${local.net_dev.netdev}, ${rtx_pci_dev.device});
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
372 - strlcpy(${local.net_dev.netdev}.name, ${config.ifname}, sizeof(${local.net_dev.netdev}.name));
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
373 - ${local.net_dev.netdev}.irq = ${rtx_pci_dev.irq};
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
374 - ${local.net_dev.netdev}.netdev_ops = &rtx_ether_ops;
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
375 + SET_NETDEV_DEV(${local.rtx_net_dev.k_net_dev}, ${rtx_pci_dev.device});
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
376 + strlcpy(${local.rtx_net_dev.k_net_dev}->name,
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
377 + ${config.ifname},
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
378 + sizeof(${local.rtx_net_dev.k_net_dev}->name));
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
379 + ${local.rtx_net_dev.k_net_dev}->irq = ${rtx_pci_dev.irq};
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
380 + ${local.rtx_net_dev.k_net_dev}->netdev_ops = &rtx_ether_ops;
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
381
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
382 - error = register_netdev(&${local.net_dev.netdev});
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
383 + error = register_netdev(${local.rtx_net_dev.k_net_dev});
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
384 if (error)
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
385 {
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
386 ${Log::info("cannot register the driver in the net subsystem")};
108
7efe3212db3a Put the patches on e1000 above the patches on the compiler
Louis Opter <louis@lse.epita.fr>
parents: 107
diff changeset
387 @@ -273,13 +301,11 @@
104
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
388 * XXX: the cast is here because the compiler resolve the
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
389 * type of rtx_pci_dev.pci_device to the type of
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
390 * rtx_pci_dev instead of the type of rtx_pci_dev.pci_device.
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
391 - *
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
392 - * Also, I'm getting placeholder in the generated code if
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
393 - * I don't open a scope here.
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
394 */
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
395 - {
108
7efe3212db3a Put the patches on e1000 above the patches on the compiler
Louis Opter <louis@lse.epita.fr>
parents: 107
diff changeset
396 - ${PCI::AbstractDevice.ref} rtx_pdev = ${rtx_pci_dev.pci_device};
104
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
397 - ${local.rtx_ether_ctx.init(local.net_dev, local.rtx_pdev)};
108
7efe3212db3a Put the patches on e1000 above the patches on the compiler
Louis Opter <louis@lse.epita.fr>
parents: 107
diff changeset
398 + ${PCI::AbstractDevice.ref} workaround = ${rtx_pci_dev.pci_device};
104
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
399 + ${cast local.workaround as PCI::AbstractDevice};
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
400 + { /* XXX: I end up with a placeholder if I don't open a scope */
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
401 + ${local.rtx_ether_ctx.init(local.rtx_net_dev, local.workaround)};
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
402 }
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
403
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
404 /* Register ourselves in the parent context: */
108
7efe3212db3a Put the patches on e1000 above the patches on the compiler
Louis Opter <louis@lse.epita.fr>
parents: 107
diff changeset
405 @@ -300,7 +326,7 @@
104
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
406 ${pointcut Ethernet::adapter_load_mac_address(local.rtx_ether_ctx)};
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
407 memcpy(${local.rtx_ether_ctx.perm_addr},
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
408 ${local.rtx_ether_ctx.dev_addr},
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
409 - ${local.net_dev.netdev}.addr_len);
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
410 + ${local.rtx_net_dev.k_net_dev}->addr_len);
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
411 }
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
412
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
413 /* This chunk should be removed (see #26) */
108
7efe3212db3a Put the patches on e1000 above the patches on the compiler
Louis Opter <louis@lse.epita.fr>
parents: 107
diff changeset
414 @@ -317,13 +343,12 @@
104
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
415 */
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
416 chunk PCI::pci_remove_hook(PCI::Device rtx_pci_dev)
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
417 {
108
7efe3212db3a Put the patches on e1000 above the patches on the compiler
Louis Opter <louis@lse.epita.fr>
parents: 107
diff changeset
418 - ${Ethernet::Device.ref} rtx_ether_ctx = ${rtx_pci_dev.context};
7efe3212db3a Put the patches on e1000 above the patches on the compiler
Louis Opter <louis@lse.epita.fr>
parents: 107
diff changeset
419 - ${Ethernet::AbstractDevice.ref} rtx_ether_dev = (${Ethernet::AbstractDevice.ref})${local.rtx_ether_ctx.net_device};
104
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
420 -
108
7efe3212db3a Put the patches on e1000 above the patches on the compiler
Louis Opter <louis@lse.epita.fr>
parents: 107
diff changeset
421 + ${Ethernet::Device.ref} rtx_ether_ctx = ${rtx_pci_dev.rtx_drv_context};
104
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
422 BUG_ON(!rtx_ether_ctx);
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
423
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
424 - unregister_netdev(&${local.rtx_ether_dev.netdev});
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
425 - free_netdev(&${local.rtx_ether_dev.netdev});
108
7efe3212db3a Put the patches on e1000 above the patches on the compiler
Louis Opter <louis@lse.epita.fr>
parents: 107
diff changeset
426 + ${Ethernet::AbstractDevice.ref} rtx_net_dev = ${local.rtx_ether_ctx.net_device};
104
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
427 + unregister_netdev(${local.rtx_net_dev.k_net_dev});
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
428 + free_netdev(${local.rtx_net_dev.k_net_dev});
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
429 }
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
430
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
431 /* This chunk should be removed (see #26) */
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
432 diff --git a/rathaxes/samples/e1000/ethernet.rti b/rathaxes/samples/e1000/ethernet.rti
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
433 --- a/rathaxes/samples/e1000/ethernet.rti
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
434 +++ b/rathaxes/samples/e1000/ethernet.rti
107
f42751b8ca99 Fix the interrupt handler refactoring patch and update the abstract type notation patch accordingly
Louis Opter <louis@lse.epita.fr>
parents: 106
diff changeset
435 @@ -16,13 +16,14 @@
104
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
436 provided type AbstractDevice
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
437 {
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
438 chunk LKM::includes();
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
439 + method init(Builtin::symbol);
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
440 decl data_types();
106
976a4b87803f Fix the resolution and the e1000 sample with the new scalar ref feature
David Pineau <dav.pineau@gmail.com>
parents: 105
diff changeset
441 - attribute Builtin::symbol.scalar netdev;
107
f42751b8ca99 Fix the interrupt handler refactoring patch and update the abstract type notation patch accordingly
Louis Opter <louis@lse.epita.fr>
parents: 106
diff changeset
442 + attribute Builtin::symbol.scalar k_net_dev;
f42751b8ca99 Fix the interrupt handler refactoring patch and update the abstract type notation patch accordingly
Louis Opter <louis@lse.epita.fr>
parents: 106
diff changeset
443 /*
f42751b8ca99 Fix the interrupt handler refactoring patch and update the abstract type notation patch accordingly
Louis Opter <louis@lse.epita.fr>
parents: 106
diff changeset
444 * XXX: should be a Ethernet::Device, but that causes a circular
f42751b8ca99 Fix the interrupt handler refactoring patch and update the abstract type notation patch accordingly
Louis Opter <louis@lse.epita.fr>
parents: 106
diff changeset
445 * dependency:
f42751b8ca99 Fix the interrupt handler refactoring patch and update the abstract type notation patch accordingly
Louis Opter <louis@lse.epita.fr>
parents: 106
diff changeset
446 */
108
7efe3212db3a Put the patches on e1000 above the patches on the compiler
Louis Opter <louis@lse.epita.fr>
parents: 107
diff changeset
447 - attribute Builtin::symbol.scalar rtx_ether_ctx;
107
f42751b8ca99 Fix the interrupt handler refactoring patch and update the abstract type notation patch accordingly
Louis Opter <louis@lse.epita.fr>
parents: 106
diff changeset
448 + attribute Builtin::symbol.scalar rtx_ether_ctx;
104
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
449 }
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
450
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
451 provided type Device
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
452 diff --git a/rathaxes/samples/e1000/pci.blt b/rathaxes/samples/e1000/pci.blt
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
453 --- a/rathaxes/samples/e1000/pci.blt
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
454 +++ b/rathaxes/samples/e1000/pci.blt
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
455 @@ -16,15 +16,15 @@
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
456 {
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
457 }
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
458
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
459 - method set_context(Builtin::symbol ctx)
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
460 + method set_rtx_context(Builtin::symbol ctx)
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
461 {
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
462 - pci_set_drvdata(&${self}->data, ${ctx});
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
463 + pci_set_drvdata(${self.k_pci_dev}, ${ctx});
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
464 }
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
465
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
466 map
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
467 {
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
468 - data: ${self}->data;
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
469 - drv_data: pci_get_drvdata(&${self}->data);
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
470 + k_pci_dev: ((struct pci_dev *)${self});
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
471 + rtx_pci_ctx: pci_get_drvdata((struct pci_dev *)${self});
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
472 }
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
473 }
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
474
108
7efe3212db3a Put the patches on e1000 above the patches on the compiler
Louis Opter <louis@lse.epita.fr>
parents: 107
diff changeset
475 @@ -51,13 +51,13 @@
7efe3212db3a Put the patches on e1000 above the patches on the compiler
Louis Opter <louis@lse.epita.fr>
parents: 107
diff changeset
476 {
104
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
477 int error;
108
7efe3212db3a Put the patches on e1000 above the patches on the compiler
Louis Opter <louis@lse.epita.fr>
parents: 107
diff changeset
478 ${PCI::AbstractDevice.ref} enable_pdev = self->pdev;
104
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
479 - error = pci_enable_device(&${local.enable_pdev.data});
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
480 + error = pci_enable_device(${local.enable_pdev.k_pci_dev});
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
481 if (error)
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
482 return error;
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
483 - error = pci_request_selected_regions(&${local.enable_pdev.data}, self->bars, ${config.name});
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
484 + error = pci_request_selected_regions(${local.enable_pdev.k_pci_dev}, self->bars, ${config.name});
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
485 if (error)
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
486 return error;
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
487 - pci_set_master(&${local.enable_pdev.data});
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
488 + pci_set_master(${local.enable_pdev.k_pci_dev});
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
489 return 0;
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
490 }
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
491
108
7efe3212db3a Put the patches on e1000 above the patches on the compiler
Louis Opter <louis@lse.epita.fr>
parents: 107
diff changeset
492 @@ -66,8 +66,8 @@
7efe3212db3a Put the patches on e1000 above the patches on the compiler
Louis Opter <louis@lse.epita.fr>
parents: 107
diff changeset
493 ${PCI::AbstractDevice.ref} disable_pdev = self->pdev;
104
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
494 if (self->ioaddr)
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
495 iounmap(self->ioaddr);
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
496 - pci_release_selected_regions(&${local.disable_pdev.data}, self->bars);
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
497 - pci_disable_device(&${local.disable_pdev.data});
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
498 + pci_release_selected_regions(${local.disable_pdev.k_pci_dev}, self->bars);
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
499 + pci_disable_device(${local.disable_pdev.k_pci_dev});
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
500 }
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
501 }
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
502
108
7efe3212db3a Put the patches on e1000 above the patches on the compiler
Louis Opter <louis@lse.epita.fr>
parents: 107
diff changeset
503 @@ -75,7 +75,7 @@
7efe3212db3a Put the patches on e1000 above the patches on the compiler
Louis Opter <louis@lse.epita.fr>
parents: 107
diff changeset
504 {
7efe3212db3a Put the patches on e1000 above the patches on the compiler
Louis Opter <louis@lse.epita.fr>
parents: 107
diff changeset
505 ${PCI::AbstractDevice.ref} workaround = (${PCI::AbstractDevice.ref})pdev;
104
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
506 ${self}->pdev = ${pdev};
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
507 - ${self}->bars = pci_select_bars(&${local.workaround.data}, IORESOURCE_MEM);
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
508 + ${self}->bars = pci_select_bars(${local.workaround.k_pci_dev}, IORESOURCE_MEM);
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
509 ${self}->ioaddr = NULL;
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
510 ${self}->context = NULL;
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
511 }
108
7efe3212db3a Put the patches on e1000 above the patches on the compiler
Louis Opter <louis@lse.epita.fr>
parents: 107
diff changeset
512 @@ -93,20 +93,20 @@
7efe3212db3a Put the patches on e1000 above the patches on the compiler
Louis Opter <louis@lse.epita.fr>
parents: 107
diff changeset
513 method select_ioaddr(Builtin::number bar)
104
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
514 {
108
7efe3212db3a Put the patches on e1000 above the patches on the compiler
Louis Opter <louis@lse.epita.fr>
parents: 107
diff changeset
515 ${PCI::AbstractDevice.ref} select_ioaddr_pdev = ${self}->pdev;
104
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
516 - ${self}->ioaddr = pci_ioremap_bar(&${local.select_ioaddr_pdev.data}, ${bar});
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
517 + ${self}->ioaddr = pci_ioremap_bar(${local.select_ioaddr_pdev.k_pci_dev}, ${bar});
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
518 }
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
519
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
520 - method set_context(Builtin::symbol ctx)
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
521 + method set_rtx_drv_context(Builtin::symbol ctx)
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
522 {
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
523 ${self}->context = ctx;
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
524 }
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
525
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
526 map
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
527 {
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
528 - context: ${self}->context;
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
529 - device: &${self}->pdev->data.dev;
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
530 + rtx_drv_context: ${self}->context;
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
531 + device: &((struct pci_dev *)(${self})->pdev)->dev;
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
532 pci_device: ${self}->pdev;
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
533 - irq: ${self}->pdev->data.irq;
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
534 + irq: ((struct pci_dev *)(${self})->pdev)->irq;
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
535 bars: ${self}->bars;
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
536 ioaddr: ${self}->ioaddr;
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
537 BAR_0: 0;
108
7efe3212db3a Put the patches on e1000 above the patches on the compiler
Louis Opter <louis@lse.epita.fr>
parents: 107
diff changeset
538 @@ -146,7 +146,7 @@
104
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
539 ${local.rtx_pci_dev.init(local.rtx_pdev)};
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
540 }
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
541
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
542 - /* ${local.pdev.set_context(local.rtx_pci_dev)}; */
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
543 + /* ${local.pdev.set_rtx_context(local.rtx_pci_dev)}; */
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
544 pci_set_drvdata(pdev, rtx_pci_dev);
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
545
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
546 /* ${local.rtx_pci_dev.enable()}; */
108
7efe3212db3a Put the patches on e1000 above the patches on the compiler
Louis Opter <louis@lse.epita.fr>
parents: 107
diff changeset
547 @@ -173,7 +173,7 @@
104
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
548 return 0;
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
549
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
550 fail:
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
551 - /* ${local.pdev.set_context(NULL)}; */
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
552 + /* ${local.pdev.set_rtx_drv_context(NULL)}; */
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
553 pci_set_drvdata(pdev, NULL);
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
554 kfree(rtx_pci_dev);
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
555 return error;
108
7efe3212db3a Put the patches on e1000 above the patches on the compiler
Louis Opter <louis@lse.epita.fr>
parents: 107
diff changeset
556 @@ -198,8 +198,7 @@
7efe3212db3a Put the patches on e1000 above the patches on the compiler
Louis Opter <louis@lse.epita.fr>
parents: 107
diff changeset
557 static void rtx_pci_remove(struct pci_dev *pdev)
104
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
558 {
108
7efe3212db3a Put the patches on e1000 above the patches on the compiler
Louis Opter <louis@lse.epita.fr>
parents: 107
diff changeset
559 ${PCI::AbstractDevice.ref} rtx_pdev = (${PCI::AbstractDevice.ref})pdev;
7efe3212db3a Put the patches on e1000 above the patches on the compiler
Louis Opter <louis@lse.epita.fr>
parents: 107
diff changeset
560 - ${PCI::Device.ref} rtx_pci_dev = ${rtx_pdev.drv_data};
7efe3212db3a Put the patches on e1000 above the patches on the compiler
Louis Opter <louis@lse.epita.fr>
parents: 107
diff changeset
561 -
7efe3212db3a Put the patches on e1000 above the patches on the compiler
Louis Opter <louis@lse.epita.fr>
parents: 107
diff changeset
562 + ${PCI::Device.ref} rtx_pci_dev = ${rtx_pdev.rtx_pci_ctx};
104
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
563 BUG_ON(!rtx_pci_dev);
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
564
108
7efe3212db3a Put the patches on e1000 above the patches on the compiler
Louis Opter <louis@lse.epita.fr>
parents: 107
diff changeset
565 ${pointcut PCI::pci_remove_hook(local.rtx_pci_dev)};
104
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
566 diff --git a/rathaxes/samples/e1000/pci.rti b/rathaxes/samples/e1000/pci.rti
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
567 --- a/rathaxes/samples/e1000/pci.rti
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
568 +++ b/rathaxes/samples/e1000/pci.rti
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
569 @@ -10,10 +10,15 @@
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
570
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
571 chunk LKM::includes();
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
572 method init(PCI::AbstractDevice);
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
573 - method set_context(Builtin::symbol);
106
976a4b87803f Fix the resolution and the e1000 sample with the new scalar ref feature
David Pineau <dav.pineau@gmail.com>
parents: 105
diff changeset
574 -
976a4b87803f Fix the resolution and the e1000 sample with the new scalar ref feature
David Pineau <dav.pineau@gmail.com>
parents: 105
diff changeset
575 - attribute Builtin::symbol.scalar data;
976a4b87803f Fix the resolution and the e1000 sample with the new scalar ref feature
David Pineau <dav.pineau@gmail.com>
parents: 105
diff changeset
576 - attribute Builtin::symbol.scalar drv_data;
104
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
577 + /*
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
578 + * XXX: the argument should be a PCI::Device but that causes a circular
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
579 + * dependency:
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
580 + */
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
581 + method set_rtx_context(Builtin::symbol);
106
976a4b87803f Fix the resolution and the e1000 sample with the new scalar ref feature
David Pineau <dav.pineau@gmail.com>
parents: 105
diff changeset
582 +
976a4b87803f Fix the resolution and the e1000 sample with the new scalar ref feature
David Pineau <dav.pineau@gmail.com>
parents: 105
diff changeset
583 + attribute Builtin::symbol.scalar k_pci_dev;
104
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
584 + /* XXX: should be PCI::Device (see above point) */
106
976a4b87803f Fix the resolution and the e1000 sample with the new scalar ref feature
David Pineau <dav.pineau@gmail.com>
parents: 105
diff changeset
585 + attribute Builtin::symbol.scalar rtx_pci_ctx;
104
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
586 }
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
587
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
588 provided type PCI::Device
106
976a4b87803f Fix the resolution and the e1000 sample with the new scalar ref feature
David Pineau <dav.pineau@gmail.com>
parents: 105
diff changeset
589 @@ -27,9 +32,10 @@
104
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
590 method enable();
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
591 method disable();
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
592 method select_ioaddr(Builtin::number);
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
593 - method set_context(Builtin::symbol);
106
976a4b87803f Fix the resolution and the e1000 sample with the new scalar ref feature
David Pineau <dav.pineau@gmail.com>
parents: 105
diff changeset
594
976a4b87803f Fix the resolution and the e1000 sample with the new scalar ref feature
David Pineau <dav.pineau@gmail.com>
parents: 105
diff changeset
595 - attribute Builtin::symbol.scalar context;
104
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
596 + method set_rtx_drv_context(Builtin::symbol);
106
976a4b87803f Fix the resolution and the e1000 sample with the new scalar ref feature
David Pineau <dav.pineau@gmail.com>
parents: 105
diff changeset
597 +
976a4b87803f Fix the resolution and the e1000 sample with the new scalar ref feature
David Pineau <dav.pineau@gmail.com>
parents: 105
diff changeset
598 + attribute Builtin::symbol.scalar rtx_drv_context;
976a4b87803f Fix the resolution and the e1000 sample with the new scalar ref feature
David Pineau <dav.pineau@gmail.com>
parents: 105
diff changeset
599 attribute Device::AbstractDevice.ref device;
976a4b87803f Fix the resolution and the e1000 sample with the new scalar ref feature
David Pineau <dav.pineau@gmail.com>
parents: 105
diff changeset
600 attribute PCI::AbstractDevice.ref pci_device;
976a4b87803f Fix the resolution and the e1000 sample with the new scalar ref feature
David Pineau <dav.pineau@gmail.com>
parents: 105
diff changeset
601 attribute Builtin::symbol.ref ioaddr;
104
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
602 diff --git a/rathaxes/samples/e1000/socket.blt b/rathaxes/samples/e1000/socket.blt
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
603 --- a/rathaxes/samples/e1000/socket.blt
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
604 +++ b/rathaxes/samples/e1000/socket.blt
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
605 @@ -14,7 +14,7 @@
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
606
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
607 map
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
608 {
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
609 - data: ${self}->data;
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
610 + k_sk_buff: ((struct sk_buff *)${self});
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
611 }
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
612 }
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
613
108
7efe3212db3a Put the patches on e1000 above the patches on the compiler
Louis Opter <louis@lse.epita.fr>
parents: 107
diff changeset
614 @@ -45,11 +45,11 @@
7efe3212db3a Put the patches on e1000 above the patches on the compiler
Louis Opter <louis@lse.epita.fr>
parents: 107
diff changeset
615 * arguments yet.
104
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
616 */
108
7efe3212db3a Put the patches on e1000 above the patches on the compiler
Louis Opter <louis@lse.epita.fr>
parents: 107
diff changeset
617 ${Socket::AbstractSKBuff.ref} skb = self->skbuff;
104
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
618 - ${Ethernet::ProtocolId} ethernet_proto = { .id = be16_to_cpu(${local.skb.data}.protocol) };
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
619 + ${Ethernet::ProtocolId} ethernet_proto = { .id = be16_to_cpu(${local.skb.k_sk_buff}->protocol) };
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
620 static const char * const ip_summed_values[] = {
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
621 "none", "unnecessary", "complete", "partial"
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
622 };
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
623 - struct skb_shared_info *shinfo = skb_shinfo(&${local.skb.data});
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
624 + struct skb_shared_info *shinfo = skb_shinfo(${local.skb.k_sk_buff});
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
625
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
626 pr_info(
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
627 "\t protocol = %#-5x (%s) ip_summed = %d (%s)\n"
108
7efe3212db3a Put the patches on e1000 above the patches on the compiler
Louis Opter <louis@lse.epita.fr>
parents: 107
diff changeset
628 @@ -58,8 +58,8 @@
104
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
629 "\t gso_size = %-5u gso_segs = %-5u gso_type = %-5u",
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
630 /* XXX: can't use ${local.ethernet_proto.id} here (issue #52): */
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
631 ethernet_proto.id, ${local.ethernet_proto.str},
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
632 - ${local.skb.data}.ip_summed, ip_summed_values[${local.skb.data}.ip_summed],
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
633 - ${local.skb.data}.len, ${local.skb.data}.data_len, skb_headlen(&${local.skb.data}),
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
634 + ${local.skb.k_sk_buff}->ip_summed, ip_summed_values[${local.skb.k_sk_buff}->ip_summed],
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
635 + ${local.skb.k_sk_buff}->len, ${local.skb.k_sk_buff}->data_len, skb_headlen(${local.skb.k_sk_buff}),
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
636 shinfo->nr_frags, shinfo->gso_size, shinfo->gso_segs, shinfo->gso_type
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
637 );
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
638 }
108
7efe3212db3a Put the patches on e1000 above the patches on the compiler
Louis Opter <louis@lse.epita.fr>
parents: 107
diff changeset
639 @@ -70,14 +70,13 @@
7efe3212db3a Put the patches on e1000 above the patches on the compiler
Louis Opter <louis@lse.epita.fr>
parents: 107
diff changeset
640 {
7efe3212db3a Put the patches on e1000 above the patches on the compiler
Louis Opter <louis@lse.epita.fr>
parents: 107
diff changeset
641 ${Socket::AbstractSKBuff.ref} skb = self->skbuff;
104
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
642
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
643 - WARN_ON(!skb);
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
644 - WARN_ON(!${local.skb.data}.data);
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
645 + WARN_ON(!${local.skb.k_sk_buff});
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
646 WARN_ON(self->dma_handle);
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
647
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
648 self->dma_handle = dma_map_single(
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
649 dev,
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
650 - &${local.skb.data}.data,
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
651 - skb_headlen(&${local.skb.data}),
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
652 + ${local.skb.k_sk_buff},
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
653 + skb_headlen(${local.skb.k_sk_buff}),
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
654 direction);
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
655 int err = dma_mapping_error(dev, self->dma_handle);
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
656 if (err)
108
7efe3212db3a Put the patches on e1000 above the patches on the compiler
Louis Opter <louis@lse.epita.fr>
parents: 107
diff changeset
657 @@ -94,18 +93,17 @@
7efe3212db3a Put the patches on e1000 above the patches on the compiler
Louis Opter <louis@lse.epita.fr>
parents: 107
diff changeset
658 {
7efe3212db3a Put the patches on e1000 above the patches on the compiler
Louis Opter <louis@lse.epita.fr>
parents: 107
diff changeset
659 ${Socket::AbstractSKBuff.ref} skb = self->skbuff;
104
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
660
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
661 - WARN_ON(!${local.skb});
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
662 - WARN_ON(!${local.skb.data}.data);
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
663 + WARN_ON(!${local.skb.k_sk_buff});
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
664
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
665 if (self->dma_handle)
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
666 {
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
667 dma_unmap_single(dev,
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
668 self->dma_handle,
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
669 - skb_headlen(&${local.skb.data}),
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
670 + skb_headlen(${local.skb.k_sk_buff}),
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
671 direction);
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
672 self->dma_handle = 0;
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
673 }
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
674 - dev_kfree_skb_any(&${local.skb.data});
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
675 + dev_kfree_skb_any(${local.skb.k_sk_buff});
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
676 self->skbuff = 0;
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
677 }
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
678 }
108
7efe3212db3a Put the patches on e1000 above the patches on the compiler
Louis Opter <louis@lse.epita.fr>
parents: 107
diff changeset
679 @@ -128,22 +126,22 @@
104
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
680
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
681 method map_to(Device::AbstractDevice dev)
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
682 {
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
683 - rtx_socket_skbuff_map(${self}, &${dev.data}, DMA_TO_DEVICE);
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
684 + rtx_socket_skbuff_map(${self}, ${dev.k_device}, DMA_TO_DEVICE);
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
685 }
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
686
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
687 method map_from(Device::AbstractDevice dev)
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
688 {
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
689 - rtx_socket_skbuff_map(${self}, &${dev.data}, DMA_FROM_DEVICE);
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
690 + rtx_socket_skbuff_map(${self}, ${dev.k_device}, DMA_FROM_DEVICE);
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
691 }
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
692
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
693 method unmap_to_and_free(Device::AbstractDevice dev)
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
694 {
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
695 - rtx_socket_skbuff_unmap_and_free(${self}, &${dev.data}, DMA_TO_DEVICE);
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
696 + rtx_socket_skbuff_unmap_and_free(${self}, ${dev.k_device}, DMA_TO_DEVICE);
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
697 }
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
698
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
699 method unmap_from_and_free(Device::AbstractDevice dev)
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
700 {
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
701 - rtx_socket_skbuff_unmap_and_free(${self}, &${dev.data}, DMA_FROM_DEVICE);
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
702 + rtx_socket_skbuff_unmap_and_free(${self}, ${dev.k_device}, DMA_FROM_DEVICE);
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
703 }
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
704
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
705 map
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
706 diff --git a/rathaxes/samples/e1000/socket.rti b/rathaxes/samples/e1000/socket.rti
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
707 --- a/rathaxes/samples/e1000/socket.rti
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
708 +++ b/rathaxes/samples/e1000/socket.rti
106
976a4b87803f Fix the resolution and the e1000 sample with the new scalar ref feature
David Pineau <dav.pineau@gmail.com>
parents: 105
diff changeset
709 @@ -5,7 +5,7 @@
104
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
710 {
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
711 chunk LKM::includes();
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
712 decl data_types();
106
976a4b87803f Fix the resolution and the e1000 sample with the new scalar ref feature
David Pineau <dav.pineau@gmail.com>
parents: 105
diff changeset
713 - attribute Builtin::symbol.scalar data;
976a4b87803f Fix the resolution and the e1000 sample with the new scalar ref feature
David Pineau <dav.pineau@gmail.com>
parents: 105
diff changeset
714 + attribute Builtin::symbol.scalar k_sk_buff;
104
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
715 }
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
716
c4c33ac02b93 First try at splitting the type nightmare and the refactoring
Louis Opter <louis@lse.epita.fr>
parents:
diff changeset
717 provided type SKBuff