Parcourir la source

Arbitrary alignment is now available.

Use shared symbols.
Correct other symbol violations.
tags/v0.9.3
Michael Brown il y a 19 ans
Parent
révision
3c2851e563
1 fichiers modifiés avec 28 ajouts et 52 suppressions
  1. 28
    52
      src/drivers/net/r8169.c

+ 28
- 52
src/drivers/net/r8169.c Voir le fichier

@@ -282,34 +282,32 @@ struct RxDesc {
282 282
 	u32 buf_Haddr;
283 283
 };
284 284
 
285
-/* The descriptors for this card are required to be aligned on
286
-256 byte boundaries.  As the align attribute does not do more than
287
-16 bytes of alignment it requires some extra steps.  Add 256 to the 
288
-size of the array and the init_ring adjusts the alignment */
289
-
290
-/* Define the TX Descriptor */
291
-static u8 tx_ring[NUM_TX_DESC * sizeof(struct TxDesc) + 256];
292
-
293
-/* Create a static buffer of size RX_BUF_SZ for each
294
-TX Descriptor.  All descriptors point to a
295
-part of this buffer */
296
-static unsigned char txb[NUM_TX_DESC * RX_BUF_SIZE];
297
-
298
-/* Define the RX Descriptor */
299
-static u8 rx_ring[NUM_RX_DESC * sizeof(struct TxDesc) + 256];
300
-
301
-/* Create a static buffer of size RX_BUF_SZ for each
302
-RX Descriptor   All descriptors point to a
303
-part of this buffer */
304
-static unsigned char rxb[NUM_RX_DESC * RX_BUF_SIZE];
305
-
306
-struct rtl8169_private {
285
+/* The descriptors for this card are required to be aligned on 256
286
+ * byte boundaries.  As the align attribute does not do more than 16
287
+ * bytes of alignment it requires some extra steps.  Add 256 to the
288
+ * size of the array and the init_ring adjusts the alignment.
289
+ *
290
+ * UPDATE: This is no longer true; we can request arbitrary alignment.
291
+ */
292
+
293
+/* Define the TX and RX Descriptors and Buffers */
294
+#define __align_256 __attribute__ (( aligned ( 256 ) ))
295
+struct {
296
+	struct TxDesc tx_ring[NUM_TX_DESC] __align_256;
297
+	unsigned char txb[NUM_TX_DESC * RX_BUF_SIZE];
298
+	struct RxDesc rx_ring[NUM_RX_DESC] __align_256;
299
+	unsigned char rxb[NUM_RX_DESC * RX_BUF_SIZE];
300
+} r8169_bufs __shared;
301
+#define tx_ring r8169_bufs.tx_ring
302
+#define rx_ring r8169_bufs.rx_ring
303
+#define txb r8169_bufs.txb
304
+#define rxb r8169_bufs.rxb
305
+
306
+static struct rtl8169_private {
307 307
 	void *mmio_addr;	/* memory map physical address */
308 308
 	int chipset;
309 309
 	unsigned long cur_rx;	/* Index into the Rx descriptor buffer of next Rx pkt. */
310 310
 	unsigned long cur_tx;	/* Index into the Tx descriptor buffer of next Rx pkt. */
311
-	unsigned char *TxDescArrays;	/* Index of Tx Descriptor buffer */
312
-	unsigned char *RxDescArrays;	/* Index of Rx Descriptor buffer */
313 311
 	struct TxDesc *TxDescArray;	/* Index of 256-alignment Tx Descriptor buffer */
314 312
 	struct RxDesc *RxDescArray;	/* Index of 256-alignment Rx Descriptor buffer */
315 313
 	unsigned char *RxBufferRing[NUM_RX_DESC];	/* Index of Rx Buffer array */
@@ -324,7 +322,7 @@ static const u16 rtl8169_intr_mask =
324 322
 static const unsigned int rtl8169_rx_config =
325 323
     (RX_FIFO_THRESH << RxCfgFIFOShift) | (RX_DMA_BURST << RxCfgDMAShift);
326 324
 
327
-void mdio_write(int RegAddr, int value)
325
+static void mdio_write(int RegAddr, int value)
328 326
 {
329 327
 	int i;
330 328
 
@@ -341,7 +339,7 @@ void mdio_write(int RegAddr, int value)
341 339
 	}
342 340
 }
343 341
 
344
-int mdio_read(int RegAddr)
342
+static int mdio_read(int RegAddr)
345 343
 {
346 344
 	int i, value = -1;
347 345
 
@@ -416,7 +414,7 @@ static int rtl8169_init_board(struct pci_device *pdev)
416 414
 /**************************************************************************
417 415
 IRQ - Wait for a frame
418 416
 ***************************************************************************/
419
-void r8169_irq ( struct nic *nic __unused, irq_action_t action ) {
417
+static void r8169_irq ( struct nic *nic __unused, irq_action_t action ) {
420 418
 	int intr_status = 0;
421 419
 	int interested = RxUnderrun | RxOverflow | RxFIFOOver | RxErr | RxOK;
422 420
  
@@ -641,29 +639,9 @@ RESET - Finish setting up the ethernet interface
641 639
 static void r8169_reset(struct nic *nic)
642 640
 {
643 641
 	int i;
644
-	u8 diff;
645
-	u32 TxPhyAddr, RxPhyAddr;
646
-
647
-	tpc->TxDescArrays = tx_ring;
648
-	if (tpc->TxDescArrays == 0)
649
-		printf("Allot Error");
650
-	/* Tx Desscriptor needs 256 bytes alignment; */
651
-	TxPhyAddr = virt_to_bus(tpc->TxDescArrays);
652
-	diff = 256 - (TxPhyAddr - ((TxPhyAddr >> 8) << 8));
653
-	TxPhyAddr += diff;
654
-	tpc->TxDescArray = (struct TxDesc *) (tpc->TxDescArrays + diff);
655
-
656
-	tpc->RxDescArrays = rx_ring;
657
-	/* Rx Desscriptor needs 256 bytes alignment; */
658
-	RxPhyAddr = virt_to_bus(tpc->RxDescArrays);
659
-	diff = 256 - (RxPhyAddr - ((RxPhyAddr >> 8) << 8));
660
-	RxPhyAddr += diff;
661
-	tpc->RxDescArray = (struct RxDesc *) (tpc->RxDescArrays + diff);
662
-
663
-	if (tpc->TxDescArrays == NULL || tpc->RxDescArrays == NULL) {
664
-		printf("Allocate RxDescArray or TxDescArray failed\n");
665
-		return;
666
-	}
642
+
643
+	tpc->TxDescArray = tx_ring;
644
+	tpc->RxDescArray = rx_ring;
667 645
 
668 646
 	rtl8169_init_ring(nic);
669 647
 	rtl8169_hw_start(nic);
@@ -693,8 +671,6 @@ static void r8169_disable ( struct nic *nic __unused ) {
693 671
 
694 672
 	RTL_W32(RxMissed, 0);
695 673
 
696
-	tpc->TxDescArrays = NULL;
697
-	tpc->RxDescArrays = NULL;
698 674
 	tpc->TxDescArray = NULL;
699 675
 	tpc->RxDescArray = NULL;
700 676
 	for (i = 0; i < NUM_RX_DESC; i++) {

Chargement…
Annuler
Enregistrer