hc
2024-11-01 2f529f9b558ca1c1bd74be7437a84e4711743404
kernel/drivers/net/ethernet/realtek/r8168/r8168_n.c
....@@ -115,6 +115,8 @@
115115 #define FIRMWARE_8168FP_3 "rtl_nic/rtl8168fp-3.fw"
116116 #define FIRMWARE_8168FP_4 "rtl_nic/rtl8168fp-4.fw"
117117
118
+static int my_id=1;
119
+
118120 /* Maximum number of multicast addresses to filter (vs. Rx-all-multicast).
119121 The RTL chips use a 64 element hash table based on the Ethernet CRC. */
120122 static const int multicast_filter_limit = 32;
....@@ -24055,12 +24057,18 @@
2405524057 free_netdev(dev);
2405624058 }
2405724059
24060
+extern ssize_t at24_mac1_read(unsigned char* mac);
24061
+extern ssize_t at24_mac2_read(unsigned char* mac);
24062
+extern ssize_t at24_mac3_read(unsigned char* mac);
24063
+
24064
+
2405824065 static int
2405924066 rtl8168_get_mac_address(struct net_device *dev)
2406024067 {
2406124068 struct rtl8168_private *tp = netdev_priv(dev);
2406224069 int i;
2406324070 u8 mac_addr[MAC_ADDR_LEN];
24071
+ unsigned char mac[6];
2406424072
2406524073 for (i = 0; i < MAC_ADDR_LEN; i++)
2406624074 mac_addr[i] = RTL_R8(tp, MAC0 + i);
....@@ -24115,6 +24123,32 @@
2411524123 }
2411624124 }
2411724125 }
24126
+
24127
+
24128
+ if (my_id == 1)
24129
+ at24_mac1_read(mac);
24130
+ if (my_id == 2)
24131
+ at24_mac2_read(mac);
24132
+ if (my_id == 3)
24133
+ at24_mac3_read(mac);
24134
+ if ((mac[0] == 0x68) && (mac[1] == 0xed))
24135
+ {
24136
+ for (i = 0; i < ETH_ALEN; i++)
24137
+ mac_addr[i] = mac[i];
24138
+ my_id+=1;
24139
+ netif_err(tp, probe, dev, "Get ether addr form at24 %pM\n",
24140
+ mac_addr);
24141
+ }
24142
+ else{
24143
+ printk("rtl811h mac read from eeprom error!! \n");
24144
+ mac_addr[0] = 0x66;
24145
+ mac_addr[1] = 0xED;
24146
+ mac_addr[2] = 0xB5;
24147
+ mac_addr[3] = 0x64;
24148
+ mac_addr[4] = 0x72;
24149
+ mac_addr[5] = my_id;
24150
+ my_id+=1;
24151
+ }
2411824152
2411924153 if (!is_valid_ether_addr(mac_addr)) {
2412024154 netif_err(tp, probe, dev, "Invalid ether addr %pM\n",
....@@ -28739,5 +28773,6 @@
2873928773 #endif
2874028774 }
2874128775
28742
-module_init(rtl8168_init_module);
28776
+//module_init(rtl8168_init_module);
28777
+late_initcall(rtl8168_init_module);
2874328778 module_exit(rtl8168_cleanup_module);