comparison rathaxes_samples_e1000_split_set_up_device.patch @ 130:6359457dce75

wip
author Louis Opter <louis@lse.epita.fr>
date Sun, 01 Dec 2013 17:39:26 -0800
parents 518d9c8ac70c
children
comparison
equal deleted inserted replaced
129:518d9c8ac70c 130:6359457dce75
1 # HG changeset patch 1 # HG changeset patch
2 # Parent 2bb3ee06ef16e410c364238ccdccf43a6a2acceb 2 # Parent 39b6e7f1b2937f596ed9523741dba01745e50b9d
3 rathaxes: split and refactor e1000::set_up_device in {Rx,Tx}Ring methods 3 rathaxes: split and refactor e1000::set_up_device in {Rx,Tx}Ring methods
4 4
5 diff --git a/rathaxes/samples/e1000/e1000.blt b/rathaxes/samples/e1000/e1000.blt 5 diff --git a/rathaxes/samples/e1000/e1000.blt b/rathaxes/samples/e1000/e1000.blt
6 --- a/rathaxes/samples/e1000/e1000.blt 6 --- a/rathaxes/samples/e1000/e1000.blt
7 +++ b/rathaxes/samples/e1000/e1000.blt 7 +++ b/rathaxes/samples/e1000/e1000.blt
9 -with e1000, Ethernet, Socket, PCI, LKM, Log, Builtin 9 -with e1000, Ethernet, Socket, PCI, LKM, Log, Builtin
10 +with e1000, Ethernet, Socket, DMA, PCI, LKM, Log, Builtin 10 +with e1000, Ethernet, Socket, DMA, PCI, LKM, Log, Builtin
11 { 11 {
12 template type e1000::RxDescriptor() 12 template type e1000::RxDescriptor()
13 { 13 {
14 @@ -96,8 +96,164 @@ 14 @@ -96,8 +96,165 @@
15 { 15 {
16 } 16 }
17 17
18 + chunk Ethernet::adapter_init_rx(Ethernet::Device rtx_ether_ctx) 18 + chunk Ethernet::adapter_init_rx(Ethernet::Device rtx_ether_ctx)
19 + { 19 + {
115 + goto err_skbuffs_map; 115 + goto err_skbuffs_map;
116 + } 116 + }
117 + hw_ctx->rx_ring.base[i].buff_addr = cpu_to_le64(${local.skbuff.sk_buff}); 117 + hw_ctx->rx_ring.base[i].buff_addr = cpu_to_le64(${local.skbuff.sk_buff});
118 + } 118 + }
119 + 119 +
120 + ${Log::info("adapter_init_rx: skbuffs allocated")}; 120 + // ${Log::info("adapter_init_rx: skbuffs allocated};
121 + pr_info("adapter_init_rx: skbuffs allocated, headlen=%d", skb_headlen((struct sk_buff *)hw_ctx->rx_ring.skbuffs[i].skbuff));
121 + 122 +
122 + /* 5. Save the emplacement and the size of the ring in RDBA/RDLEN */ 123 + /* 5. Save the emplacement and the size of the ring in RDBA/RDLEN */
123 + rtx_e1000_register_write32(hw_ctx, E1000_RDBAL, hw_ctx->rx_ring.dma_base & 0xffffffff); 124 + rtx_e1000_register_write32(hw_ctx, E1000_RDBAL, hw_ctx->rx_ring.dma_base & 0xffffffff);
124 + rtx_e1000_register_write32(hw_ctx, E1000_RDBAH, hw_ctx->rx_ring.dma_base >> 32); 125 + rtx_e1000_register_write32(hw_ctx, E1000_RDBAH, hw_ctx->rx_ring.dma_base >> 32);
125 + rtx_e1000_register_write32(hw_ctx, E1000_RDLEN, hw_ctx->rx_ring.size); 126 + rtx_e1000_register_write32(hw_ctx, E1000_RDLEN, hw_ctx->rx_ring.size);
174 + size: ((${self}).size); 175 + size: ((${self}).size);
175 + dma_base: ((${self}).dma_base); 176 + dma_base: ((${self}).dma_base);
176 } 177 }
177 } 178 }
178 179
179 @@ -195,7 +351,7 @@ 180 @@ -195,7 +352,7 @@
180 E1000_TXD_CMD_RS | 181 E1000_TXD_CMD_RS |
181 skb_headlen(${local.k_skb.k_sk_buff})); 182 skb_headlen(${local.k_skb.k_sk_buff}));
182 tx_desc->upper.data = 0; 183 tx_desc->upper.data = 0;
183 - tx_desc->buff_addr = cpu_to_le64(skb->dma_handle); 184 - tx_desc->buff_addr = cpu_to_le64(skb->dma_handle);
184 + tx_desc->buff_addr = cpu_to_le64(${local.skb.dma_handle.k_dma_handle}); 185 + tx_desc->buff_addr = cpu_to_le64(${local.skb.dma_handle.k_dma_handle});
185 memcpy(&self->skbuffs[self->tail], ${local.k_skb.k_sk_buff}, sizeof(*${local.k_skb.k_sk_buff})); 186 memcpy(&self->skbuffs[self->tail], ${local.k_skb.k_sk_buff}, sizeof(*${local.k_skb.k_sk_buff}));
186 self->tail = (self->tail + 1) % ${config.tx_ring_size}; 187 self->tail = (self->tail + 1) % ${config.tx_ring_size};
187 } 188 }
188 @@ -208,7 +364,62 @@ 189 @@ -208,7 +365,62 @@
189 } 190 }
190 } 191 }
191 192
192 - method clean() 193 - method clean()
193 + chunk Ethernet::adapter_init_tx(Ethernet::Device rtx_ether_ctx) 194 + chunk Ethernet::adapter_init_tx(Ethernet::Device rtx_ether_ctx)
247 + 248 +
248 + method clean() 249 + method clean()
249 { 250 {
250 rtx_e1000_tx_ring_clean(${self}); 251 rtx_e1000_tx_ring_clean(${self});
251 } 252 }
252 @@ -247,9 +458,8 @@ 253 @@ -247,9 +459,8 @@
253 { 254 {
254 int bars; 255 int bars;
255 unsigned char /* __iomem */ *ioaddr; 256 unsigned char /* __iomem */ *ioaddr;
256 - 257 -
257 - ${e1000::RxRing} rx_ring; 258 - ${e1000::RxRing} rx_ring;
259 + ${e1000::RxRing.scalar} rx_ring; 260 + ${e1000::RxRing.scalar} rx_ring;
260 + ${e1000::TxRing.scalar} tx_ring; 261 + ${e1000::TxRing.scalar} tx_ring;
261 } 262 }
262 263
263 chunk Ethernet::HardwareContext() 264 chunk Ethernet::HardwareContext()
264 @@ -309,10 +519,53 @@ 265 @@ -309,10 +520,53 @@
265 } 266 }
266 } 267 }
267 268
268 + chunk Ethernet::adapter_setup(Ethernet::Device rtx_ether_ctx) 269 + chunk Ethernet::adapter_setup(Ethernet::Device rtx_ether_ctx)
269 + { 270 + {
294 + E1000_CMD_VME); 295 + E1000_CMD_VME);
295 + rtx_e1000_register_write32(hw_ctx, E1000_FCAH, 0); 296 + rtx_e1000_register_write32(hw_ctx, E1000_FCAH, 0);
296 + rtx_e1000_register_write32(hw_ctx, E1000_FCAL, 0); 297 + rtx_e1000_register_write32(hw_ctx, E1000_FCAL, 0);
297 + rtx_e1000_register_write32(hw_ctx, E1000_FCT, 0); 298 + rtx_e1000_register_write32(hw_ctx, E1000_FCT, 0);
298 + rtx_e1000_register_write32(hw_ctx, E1000_FCTTV, 0); 299 + rtx_e1000_register_write32(hw_ctx, E1000_FCTTV, 0);
299 + /* 300 + /*
300 + * XXX: Using int i clashes with another int i from the 301 + * XXX: Using int i clashes with another int i from the
301 + * "parent" chunk: 302 + * "parent" chunk:
302 + */ 303 + */
303 + for (int j = 0; j != 64; ++j) 304 + for (int j = 0; j != 64; ++j)
304 + rtx_e1000_register_write32(hw_ctx, E1000_CRCERRS + j * 4, 0); 305 + rtx_e1000_register_write32(hw_ctx, E1000_CRCERRS + j * 4, 0);
314 } 315 }
315 - 316 -
316 } 317 }
317 318
318 template type e1000::Register() 319 template type e1000::Register()
319 @@ -615,269 +868,6 @@ 320 @@ -615,269 +869,6 @@
320 } 321 }
321 } 322 }
322 323
323 - /* TODO: refactor 324 - /* TODO: refactor
324 - * 325 - *
584 - } 585 - }
585 - 586 -
586 /* TODO: 587 /* TODO:
587 * 588 *
588 * Refactor into two methods (one in RxRing and one in TxRing) and make use 589 * Refactor into two methods (one in RxRing and one in TxRing) and make use
589 @@ -901,15 +891,18 @@ 590 @@ -901,15 +892,18 @@
590 */ 591 */
591 for (int i = 0; i != ${config.rx_ring_size}; ++i) 592 for (int i = 0; i != ${config.rx_ring_size}; ++i)
592 { 593 {
593 + /* 594 + /*
594 + * XXX Leaking casts: 595 + * XXX Leaking casts: