1246 }
1247
1248 if (!GoodPacket)
1249 {
1250 // drop this packet!!!
1251 switch (db->io_mode)
1252 {
1253 case DM9KS_BYTE_MODE:
1254 for (i=0; i 1256 break; 1257 case DM9KS_WORD_MODE: 1258 tmplen = (rx.desc.length + 1) / 2; 1259 for (i = 0; i < tmplen; i++) 1260 inw(db->io_data); 1261 break; 1262 case DM9KS_DWORD_MODE: 1263 tmplen = (rx.desc.length + 3) / 4; 1264 for (i = 0; i < tmplen; i++) 1265 inl(db->io_data); 1266 break; 1267 } 1268 continue;/*next the packet*/ 1269 } 1270 1271 skb = dev_alloc_skb(rx.desc.length+4); 1272 if (skb == NULL ) 1273 { 1274 printk(KERN_INFO '%s: Memory squeeze.n', dev->name); 1275 /*re-load the value into Memory data read address register*/ 1276 iow(db,DM9KS_MDRAH,MDRAH); 1277 iow(db,DM9KS_MDRAL,MDRAL); 1278 return; 1279 } 1280 else 1281 { 1282 /* Move data from DM9000 */ 1283 skb->dev = dev; 1284 skb_reserve(skb, 2); 1285 rdptr = (u8*)skb_put(skb, rx.desc.length - 4); 1286 1287 /* Read received packet from RX SARM */ 1288 switch (db->io_mode) 1289 { 1290 case DM9KS_BYTE_MODE: 1291 for (i=0; i 1293 break; 1294 case DM9KS_WORD_MODE: 1295 tmplen = (rx.desc.length + 1) / 2; 1296 for (i = 0; i < tmplen; i++) 1297 ((u16 *)rdptr)[i] = inw(db->io_data); 1298 break; 1299 case DM9KS_DWORD_MODE: 1300 tmplen = (rx.desc.length + 3) / 4; 1301 for (i = 0; i < tmplen; i++) 1302 ((u32 *)rdptr)[i] = inl(db->io_data); 1303 break; 1304 } 1305 1306 /* Pass to upper layer */ 1307 skb->protocol = eth_type_trans(skb,dev); 1308 1309 #ifdef CHECKSUM 1310 if((rxbyte&0xe0)==0) /* receive packet no checksum fail */ 1311 skb->ip_summed = CHECKSUM_UNNECESSARY; 1312 #endif 1313 1314 netif_rx(skb); 1315 dev->last_rx=jiffies; 1316 db->stats.rx_packets++; 1317 db->stats.rx_bytes += rx.desc.length; 1318 db->cont_rx_pkt_cnt++; 1319 #ifdef RDBG /* check RX FIFO pointer */ 1320 u16 MDRAH1, MDRAL1; 1321 u16 tmp_ptr; 1322 MDRAH1 = ior(db,DM9KS_MDRAH); 1323 MDRAL1 = ior(db,DM9KS_MDRAL); 1324 tmp_ptr = (MDRAH<<8)|MDRAL; 1325 switch (db->io_mode) 1326 { 1327 case DM9KS_BYTE_MODE: 1328 tmp_ptr += rx.desc.length+4; 1329 break; 1330 case DM9KS_WORD_MODE: 1331 tmp_ptr += ((rx.desc.length+1)/2)*2+4; 1332 break; 1333 case DM9KS_DWORD_MODE: 1334 tmp_ptr += ((rx.desc.length+3)/4)*4+4; 1335 break; 1336 } 1337 if (tmp_ptr >=0x4000) 1338 tmp_ptr = (tmp_ptr - 0x4000) + 0xc00; 1339 if (tmp_ptr != ((MDRAH1<<8)|MDRAL1)) 1340 printk('[dm9ks:RX FIFO ERRORn'); 1341 #endif 1342 1343 if (db->cont_rx_pkt_cnt>=CONT_RX_PKT_CNT) 1344 { 1345 dmfe_tx_done(0); 1346 break; 1347 } 1348 } 1349 1350 }while((rxbyte & 0x01) == DM9KS_PKT_RDY); 1351 DMFE_DBUG(0, '[END]dmfe_packet_receive()', 0); 1352 1353 } 1354 1355 /* 1356 Read a word data from SROM 1357 */ 1358 static u16 read_srom_word(board_info_t *db, int offset) 1359 { 1360 iow(db, DM9KS_EPAR, offset); 1361 iow(db, DM9KS_EPCR, 0x4); 1362 while(ior(db, DM9KS_EPCR)&0x1); /* Wait read complete */ 1363 iow(db, DM9KS_EPCR, 0x0); 1364 return (ior(db, DM9KS_EPDRL) + (ior(db, DM9KS_EPDRH) << 8) ); 1365 } 1366 1367 /* 1368 Set DM9000/DM9010 multicast address 1369 */ 1370 static void dm9000_hash_table(struct net_device *dev) 1371 { 1372 board_info_t *db = (board_info_t *)dev->priv; 1373 struct dev_mc_list *mcptr = dev->mc_list; 1374 int mc_cnt = dev->mc_count; 1375 u32 hash_val; 1376 u16 i, oft, hash_table[4]; 1377 1378 DMFE_DBUG(0, 'dm9000_hash_table()', 0); 1379 1380 /* enable promiscuous mode */ 1381 if (dev->flags & IFF_PROMISC){ 1382 //printk(KERN_INFO 'DM9KS:enable promiscuous moden'); 1383 iow(db, DM9KS_RXCR, ior(db,DM9KS_RXCR)|(1<<1)); 1384 return; 1385 }else{ 1386 //printk(KERN_INFO 'DM9KS:disable promiscuous moden'); 1387 iow(db, DM9KS_RXCR, ior(db,DM9KS_RXCR)&(~(1<<1))); 1388 } 1389 1390 /* Receive all multicast packets */ 1391 if (dev->flags & IFF_ALLMULTI){
上一篇:s3c2440的USB热插拔驱动问题
下一篇:S3C实现DMA驱动程序编写
推荐阅读最新更新时间:2024-11-10 08:47